Skip to content

Commit 700b8ec

Browse files
Per Kopsperkops
authored andcommitted
chore: upgrade coding-rules
1 parent b8e653f commit 700b8ec

File tree

5 files changed

+82
-5
lines changed

5 files changed

+82
-5
lines changed

.editorconfig

Lines changed: 54 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,12 +464,58 @@ 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.CA1308.severity = suggestion # Normalize strings to uppercase
468+
dotnet_diagnostic.CA1510.severity = suggestion # Use ArgumentNullException throw helper
469+
dotnet_diagnostic.CA1511.severity = suggestion # Use ArgumentException throw helper
470+
dotnet_diagnostic.CA1512.severity = suggestion # Use ArgumentOutOfRangeException throw helper
471+
dotnet_diagnostic.CA1513.severity = suggestion # Use ObjectDisposedException throw helper
472+
dotnet_diagnostic.CA1514.severity = error # Avoid redundant length argument
473+
dotnet_diagnostic.CA1515.severity = suggestion # Because an application's API isn't typically referenced from outside the assembly, types can be made internal (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1515)
467474
dotnet_diagnostic.CA1707.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1707.md
468475
dotnet_diagnostic.CA1812.severity = none
469476
dotnet_diagnostic.CA1822.severity = suggestion
477+
dotnet_diagnostic.CA1849.severity = error # Call async methods when in an async method
478+
dotnet_diagnostic.CA1854.severity = suggestion # Prefer the 'IDictionary.TryGetValue(TKey, out TValue)' method
479+
dotnet_diagnostic.CA1855.severity = suggestion # Prefer 'Clear' over 'Fill'
480+
dotnet_diagnostic.CA1856.severity = error # Incorrect usage of ConstantExpected attribute
481+
dotnet_diagnostic.CA1857.severity = suggestion # A constant is expected for the parameter
482+
dotnet_diagnostic.CA1858.severity = suggestion # Use 'StartsWith' instead of 'IndexOf'
483+
dotnet_diagnostic.CA1859.severity = suggestion # Use concrete types when possible for improved performance
484+
dotnet_diagnostic.CA1860.severity = suggestion # Avoid using 'Enumerable.Any()' extension method
485+
dotnet_diagnostic.CA1861.severity = suggestion # Avoid constant arrays as arguments
486+
dotnet_diagnostic.CA1862.severity = error # Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
487+
dotnet_diagnostic.CA1863.severity = suggestion # Use 'CompositeFormat'
488+
dotnet_diagnostic.CA1864.severity = suggestion # Prefer the 'IDictionary.TryAdd(TKey, TValue)' method
489+
dotnet_diagnostic.CA1865.severity = suggestion # Use char overload
490+
dotnet_diagnostic.CA1866.severity = suggestion # Use char overload
491+
dotnet_diagnostic.CA1867.severity = suggestion # Use char overload
492+
dotnet_diagnostic.CA1868.severity = suggestion # Unnecessary call to 'Contains(item)'
493+
dotnet_diagnostic.CA1869.severity = suggestion # Cache and reuse 'JsonSerializerOptions' instances
494+
dotnet_diagnostic.CA1870.severity = suggestion # Use a cached 'SearchValues' instance
470495
dotnet_diagnostic.CA2007.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA2007.md
496+
dotnet_diagnostic.CA2017.severity = error # Parameter count mismatch
497+
dotnet_diagnostic.CA2018.severity = error # The count argument to Buffer.BlockCopy should specify the number of bytes to copy
498+
dotnet_diagnostic.CA2019.severity = error # ThreadStatic fields should not use inline initialization
499+
dotnet_diagnostic.CA2021.severity = error # Don't call Enumerable.Cast<T> or Enumerable.OfType<T> with incompatible types
500+
dotnet_diagnostic.CA2250.severity = suggestion # Use ThrowIfCancellationRequested
501+
dotnet_diagnostic.CA2252.severity = suggestion # Opt-in to preview features should be used with caution
502+
dotnet_diagnostic.CA2253.severity = error # Named placeholders should not be numeric values
503+
dotnet_diagnostic.CA2254.severity = suggestion # Template should be a static expression
504+
dotnet_diagnostic.CA2255.severity = suggestion # The ModuleInitializer attribute should not be used in libraries
505+
dotnet_diagnostic.CA2259.severity = error # Ensure ThreadStatic is only used with static fields
506+
dotnet_diagnostic.CA2260.severity = error # Implement generic math interfaces correctly
507+
dotnet_diagnostic.CA2261.severity = error # Do not use ConfigureAwaitOptions.SuppressThrowing with Task<TResult>
471508
dotnet_diagnostic.IDE0005.severity = warning # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/IDE0005.md
509+
dotnet_diagnostic.IDE0010.severity = suggestion # Populate switch
510+
dotnet_diagnostic.IDE0028.severity = suggestion # Collection initialization can be simplified
511+
dotnet_diagnostic.IDE0021.severity = suggestion # Use expression body for constructor
512+
dotnet_diagnostic.IDE0055.severity = none # Fix formatting
472513
dotnet_diagnostic.IDE0058.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/IDE0058.md
514+
dotnet_diagnostic.IDE0061.severity = suggestion # Use expression body for local function
515+
dotnet_diagnostic.IDE0130.severity = suggestion # Namespace does not match folder structure
516+
dotnet_diagnostic.IDE0290.severity = none # Use primary constructor
517+
dotnet_diagnostic.IDE0301.severity = suggestion # Use collection expression for empty
518+
dotnet_diagnostic.IDE0305.severity = suggestion # Collection initialization can be simplified
473519

474520

475521
# Microsoft - Compiler Errors
@@ -484,6 +530,7 @@ dotnet_diagnostic.CS4014.severity = error # https://github.com/atc-net/
484530
# StyleCop
485531
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers
486532
dotnet_diagnostic.SA1009.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/StyleCop/SA1009.md
533+
dotnet_diagnostic.SA1010.severity = none # False positive when using collection initializers
487534
dotnet_diagnostic.SA1101.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/StyleCop/SA1101.md
488535
dotnet_diagnostic.SA1122.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/StyleCop/SA1122.md
489536
dotnet_diagnostic.SA1133.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/StyleCop/SA1133.md
@@ -505,6 +552,11 @@ dotnet_diagnostic.SA1649.severity = error # https://github.com/atc-net
505552
# SonarAnalyzer.CSharp
506553
# https://rules.sonarsource.com/csharp
507554
dotnet_diagnostic.S1135.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/SonarAnalyzerCSharp/S1135.md
555+
dotnet_diagnostic.S2629.severity = none # Don't use string interpolation in logging message templates.
556+
dotnet_diagnostic.S3358.severity = none # Extract this nested ternary operation into an independent statement.
557+
dotnet_diagnostic.S6602.severity = none # "Find" method should be used instead of the "FirstOrDefault"
558+
dotnet_diagnostic.S6603.severity = none # The collection-specific "TrueForAll" method should be used instead of the "All"
559+
dotnet_diagnostic.S6605.severity = none # Collection-specific "Exists" method should be used instead of the "Any"
508560

509561

510562
##########################################

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<ItemGroup Label="Code Analyzers">
4444
<PackageReference Include="AsyncFixer" Version="1.6.0" PrivateAssets="All" />
4545
<PackageReference Include="Asyncify" Version="0.9.7" PrivateAssets="All" />
46-
<PackageReference Include="Meziantou.Analyzer" Version="2.0.147" PrivateAssets="All" />
46+
<PackageReference Include="Meziantou.Analyzer" Version="2.0.256" PrivateAssets="All" />
4747
<PackageReference Include="SecurityCodeScan.VS2019" Version="5.6.7" PrivateAssets="All" />
4848
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435" PrivateAssets="All" />
4949
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.23.1.88495" PrivateAssets="All" />
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# ATC coding rules - https://github.com/atc-net/atc-coding-rules
2+
# Version: 1.0.0
3+
# Updated: 11-04-2024
4+
# Location: cli
5+
# Distribution: Frameworks
6+
7+
##########################################
8+
# Code Analyzers Rules
9+
##########################################
10+
[*.{cs}]
11+
12+
dotnet_diagnostic.CA1031.severity = none # Do not catch general exception types
13+
dotnet_diagnostic.CA1303.severity = none # Do not pass literals as localized parameters
14+
dotnet_diagnostic.CA1819.severity = none # Properties should not return arrays
15+
dotnet_diagnostic.CA1848.severity = none # Use the LoggerMessage delegates
16+
dotnet_diagnostic.CA2000.severity = none # Dispose objects before losing scope
17+
dotnet_diagnostic.CA2254.severity = none # Template should be a static expression
18+
19+
dotnet_diagnostic.MA0076.severity = none # Do not use implicit culture-sensitive ToString in interpolated strings
20+
21+
dotnet_diagnostic.S2629.severity = none # Don't use string interpolation in logging message templates.
22+
23+
##########################################
24+
# Custom - Code Analyzers Rules
25+
##########################################

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@
5252

5353
<ItemGroup>
5454
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
55-
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" PrivateAssets="All" />
55+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.9.50" PrivateAssets="All" />
5656
</ItemGroup>
5757
</Project>

test/.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# https://www.meziantou.net/enforcing-asynchronous-code-good-practices-using-a-roslyn-analyzer.htm
2323
dotnet_diagnostic.MA0004.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0004.md
2424
dotnet_diagnostic.MA0016.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0016.md
25-
25+
dotnet_diagnostic.MA0051.severity = none # Method Length
2626

2727
# Microsoft - Code Analysis
2828
# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/

0 commit comments

Comments
 (0)