Skip to content

Commit 95f52a3

Browse files
authored
Merge pull request #81 from atc-net/feature/more_rules
feat: adding more CA rules to dotnet5-8
2 parents fc79f6b + 5f57b40 commit 95f52a3

File tree

4 files changed

+59
-8
lines changed

4 files changed

+59
-8
lines changed

distribution/dotnet5/.editorconfig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ATC coding rules - https://github.com/atc-net/atc-coding-rules
2-
# Version: 1.0.9
3-
# Updated: 01-02-2022
2+
# Version: 1.0.10
3+
# Updated: 03-06-2024
44
# Location: Root
55
# Distribution: DotNet5
66
# Inspired by: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options
@@ -460,7 +460,9 @@ dotnet_diagnostic.CA1305.severity = error
460460
dotnet_diagnostic.CA1707.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1707.md
461461
dotnet_diagnostic.CA1812.severity = none
462462
dotnet_diagnostic.CA1822.severity = suggestion
463+
dotnet_diagnostic.CA1849.severity = error # Call async methods when in an async method
463464
dotnet_diagnostic.CA2007.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA2007.md
465+
dotnet_diagnostic.CA2250.severity = suggestion # Use ThrowIfCancellationRequested
464466
dotnet_diagnostic.IDE0058.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/IDE0058.md
465467

466468

distribution/dotnet6/.editorconfig

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ATC coding rules - https://github.com/atc-net/atc-coding-rules
2-
# Version: 1.0.9
3-
# Updated: 01-02-2022
2+
# Version: 1.0.10
3+
# Updated: 03-06-2024
44
# Location: Root
55
# Distribution: DotNet6
66
# Inspired by: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options
@@ -466,7 +466,12 @@ dotnet_diagnostic.CA1305.severity = error
466466
dotnet_diagnostic.CA1707.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1707.md
467467
dotnet_diagnostic.CA1812.severity = none
468468
dotnet_diagnostic.CA1822.severity = suggestion
469+
dotnet_diagnostic.CA1849.severity = error # Call async methods when in an async method
469470
dotnet_diagnostic.CA2007.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA2007.md
471+
dotnet_diagnostic.CA2017.severity = error # Parameter count mismatch
472+
dotnet_diagnostic.CA2018.severity = error # The count argument to Buffer.BlockCopy should specify the number of bytes to copy
473+
dotnet_diagnostic.CA2019.severity = error # ThreadStatic fields should not use inline initialization
474+
dotnet_diagnostic.CA2250.severity = suggestion # Use ThrowIfCancellationRequested
470475
dotnet_diagnostic.IDE0058.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/IDE0058.md
471476

472477

distribution/dotnet7/.editorconfig

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ATC coding rules - https://github.com/atc-net/atc-coding-rules
2-
# Version: 1.0.9
3-
# Updated: 24-11-2022
2+
# Version: 1.0.10
3+
# Updated: 03-06-2024
44
# Location: Root
55
# Distribution: DotNet7
66
# Inspired by: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options
@@ -467,7 +467,16 @@ dotnet_diagnostic.CA1305.severity = error
467467
dotnet_diagnostic.CA1707.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1707.md
468468
dotnet_diagnostic.CA1812.severity = none
469469
dotnet_diagnostic.CA1822.severity = suggestion
470+
dotnet_diagnostic.CA1849.severity = error # Call async methods when in an async method
470471
dotnet_diagnostic.CA2007.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA2007.md
472+
dotnet_diagnostic.CA2017.severity = error # Parameter count mismatch
473+
dotnet_diagnostic.CA2018.severity = error # The count argument to Buffer.BlockCopy should specify the number of bytes to copy
474+
dotnet_diagnostic.CA2019.severity = error # ThreadStatic fields should not use inline initialization
475+
dotnet_diagnostic.CA2250.severity = suggestion # Use ThrowIfCancellationRequested
476+
dotnet_diagnostic.CA2252.severity = suggestion # Opt-in to preview features should be used with caution
477+
dotnet_diagnostic.CA2253.severity = error # Named placeholders should not be numeric values
478+
dotnet_diagnostic.CA2254.severity = suggestion # Template should be a static expression
479+
dotnet_diagnostic.CA2255.severity = suggestion # The ModuleInitializer attribute should not be used in libraries
471480
dotnet_diagnostic.IDE0005.severity = warning # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/IDE0005.md
472481
dotnet_diagnostic.IDE0058.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/IDE0058.md
473482

distribution/dotnet8/.editorconfig

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ATC coding rules - https://github.com/atc-net/atc-coding-rules
2-
# Version: 1.0.0
3-
# Updated: 25-09-2023
2+
# Version: 1.0.1
3+
# Updated: 03-06-2024
44
# Location: Root
55
# Distribution: DotNet8
66
# Inspired by: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options
@@ -464,10 +464,45 @@ dotnet_diagnostic.MA0048.severity = error # https://github.com/atc-net
464464
dotnet_diagnostic.CA1014.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1014.md
465465
dotnet_diagnostic.CA1068.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1068.md
466466
dotnet_diagnostic.CA1305.severity = error
467+
dotnet_diagnostic.CA1510.severity = suggestion # Use ArgumentNullException throw helper
468+
dotnet_diagnostic.CA1511.severity = suggestion # Use ArgumentException throw helper
469+
dotnet_diagnostic.CA1512.severity = suggestion # Use ArgumentOutOfRangeException throw helper
470+
dotnet_diagnostic.CA1513.severity = suggestion # Use ObjectDisposedException throw helper
471+
dotnet_diagnostic.CA1514.severity = error # Avoid redundant length argument
467472
dotnet_diagnostic.CA1707.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1707.md
468473
dotnet_diagnostic.CA1812.severity = none
469474
dotnet_diagnostic.CA1822.severity = suggestion
475+
dotnet_diagnostic.CA1849.severity = error # Call async methods when in an async method
476+
dotnet_diagnostic.CA1854.severity = suggestion # Prefer the 'IDictionary.TryGetValue(TKey, out TValue)' method
477+
dotnet_diagnostic.CA1855.severity = suggestion # Prefer 'Clear' over 'Fill'
478+
dotnet_diagnostic.CA1856.severity = error # Incorrect usage of ConstantExpected attribute
479+
dotnet_diagnostic.CA1857.severity = suggestion # A constant is expected for the parameter
480+
dotnet_diagnostic.CA1858.severity = suggestion # Use 'StartsWith' instead of 'IndexOf'
481+
dotnet_diagnostic.CA1859.severity = suggestion # Use concrete types when possible for improved performance
482+
dotnet_diagnostic.CA1860.severity = suggestion # Avoid using 'Enumerable.Any()' extension method
483+
dotnet_diagnostic.CA1861.severity = suggestion # Avoid constant arrays as arguments
484+
dotnet_diagnostic.CA1862.severity = error # Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
485+
dotnet_diagnostic.CA1863.severity = suggestion # Use 'CompositeFormat'
486+
dotnet_diagnostic.CA1864.severity = suggestion # Prefer the 'IDictionary.TryAdd(TKey, TValue)' method
487+
dotnet_diagnostic.CA1865.severity = suggestion # Use char overload
488+
dotnet_diagnostic.CA1866.severity = suggestion # Use char overload
489+
dotnet_diagnostic.CA1867.severity = suggestion # Use char overload
490+
dotnet_diagnostic.CA1868.severity = suggestion # Unnecessary call to 'Contains(item)'
491+
dotnet_diagnostic.CA1869.severity = suggestion # Cache and reuse 'JsonSerializerOptions' instances
492+
dotnet_diagnostic.CA1870.severity = suggestion # Use a cached 'SearchValues' instance
470493
dotnet_diagnostic.CA2007.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA2007.md
494+
dotnet_diagnostic.CA2017.severity = error # Parameter count mismatch
495+
dotnet_diagnostic.CA2018.severity = error # The count argument to Buffer.BlockCopy should specify the number of bytes to copy
496+
dotnet_diagnostic.CA2019.severity = error # ThreadStatic fields should not use inline initialization
497+
dotnet_diagnostic.CA2021.severity = error # Don't call Enumerable.Cast<T> or Enumerable.OfType<T> with incompatible types
498+
dotnet_diagnostic.CA2250.severity = suggestion # Use ThrowIfCancellationRequested
499+
dotnet_diagnostic.CA2252.severity = suggestion # Opt-in to preview features should be used with caution
500+
dotnet_diagnostic.CA2253.severity = error # Named placeholders should not be numeric values
501+
dotnet_diagnostic.CA2254.severity = suggestion # Template should be a static expression
502+
dotnet_diagnostic.CA2255.severity = suggestion # The ModuleInitializer attribute should not be used in libraries
503+
dotnet_diagnostic.CA2259.severity = error # Ensure ThreadStatic is only used with static fields
504+
dotnet_diagnostic.CA2260.severity = error # Implement generic math interfaces correctly
505+
dotnet_diagnostic.CA2261.severity = error # Do not use ConfigureAwaitOptions.SuppressThrowing with Task<TResult>
471506
dotnet_diagnostic.IDE0005.severity = warning # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/IDE0005.md
472507
dotnet_diagnostic.IDE0058.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/IDE0058.md
473508

0 commit comments

Comments
 (0)