Skip to content

Commit 340d3b8

Browse files
committed
Minor ruleset adjustments.
1 parent 4b52f79 commit 340d3b8

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

build/Source.ruleset

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,33 @@
3232
<Rule Id="CA2263" Action="None" />
3333
</Rules>
3434
<Rules AnalyzerId="SonarAnalyzer.CSharp" RuleNamespace="SonarAnalyzer.CSharp">
35-
<!-- "Sonar Way" rules to match SonarQube scans. -->
35+
<!-- Methods should not have too many parameters. -->
3636
<Rule Id="S107" Action="Warning" />
3737
<!-- Do not use obsolete members - Autofac maintains deprecated APIs for backward compat. -->
3838
<Rule Id="S1133" Action="None" />
39+
<!-- String literals should not be duplicated. -->
3940
<Rule Id="S1192" Action="Warning" />
41+
<!-- IP addresses should not be hardcoded. -->
4042
<Rule Id="S1313" Action="Warning" />
43+
<!-- Null pointers should not be dereferenced. -->
4144
<Rule Id="S2259" Action="Warning" />
45+
<!-- Conditionally executed code should be reachable. -->
4246
<Rule Id="S2583" Action="Warning" />
47+
<!-- Boolean expressions should not be gratuitous. -->
4348
<Rule Id="S2589" Action="Warning" />
4449
<!-- Verify reflection accessibility bypass - DI containers do extensive reflection by design. -->
4550
<Rule Id="S3011" Action="None" />
4651
<!-- Loops should use LINQ - DI container hot paths intentionally avoid LINQ allocations. -->
4752
<Rule Id="S3267" Action="None" />
53+
<!-- Cognitive complexity (must be explicitly enabled). -->
4854
<Rule Id="S3776" Action="Warning" />
4955
<!-- IDisposable pattern - Autofac uses non-standard dispose patterns for container lifecycle. -->
5056
<Rule Id="S3881" Action="None" />
5157
<!-- Split method for params check + iterator - overly prescriptive for our patterns. -->
5258
<Rule Id="S4456" Action="None" />
59+
<!-- Collection contents should not be updated while being enumerated. -->
5360
<Rule Id="S6418" Action="Warning" />
61+
<!-- Private fields should be initialized before use. -->
5462
<Rule Id="S6444" Action="Warning" />
5563
</Rules>
5664
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">

build/Test.ruleset

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
<Rule Id="CA1515" Action="None" />
2323
<!-- Remove underscores from member name - test naming conventions use underscore. -->
2424
<Rule Id="CA1707" Action="None" />
25-
<!-- Internal class that appears to never be instantiated - false positives from DI. -->
2625
<!-- Identifiers should not have incorrect suffix - test classes use Impl, Handler, etc. -->
2726
<Rule Id="CA1711" Action="None" />
2827
<!-- Property names should not match get methods - aggregate service tests intentionally test both. -->
2928
<Rule Id="CA1721" Action="None" />
29+
<!-- Internal class that appears to never be instantiated - false positives from DI. -->
3030
<Rule Id="CA1812" Action="None" />
3131
<!-- Change Dispose() to call GC.SuppressFinalize - unimportant in tests. -->
3232
<Rule Id="CA1816" Action="None" />
@@ -42,9 +42,9 @@
4242
<Rule Id="CA1863" Action="None" />
4343
<!-- Call ConfigureAwait - shouldn't in test libraries; XUnit has opposing analyzer. -->
4444
<Rule Id="CA2007" Action="None" />
45-
<!-- Implement serialization constructors - false positive in .NET Core. -->
4645
<!-- Do not raise reserved exception types - tests use generic exceptions for simulation. -->
4746
<Rule Id="CA2201" Action="None" />
47+
<!-- Implement serialization constructors - false positive in .NET Core. -->
4848
<Rule Id="CA2229" Action="None" />
4949
<!-- Use Uri instead of string parameters - strings are easier for testing. -->
5050
<Rule Id="CA2234" Action="None" />
@@ -58,9 +58,9 @@
5858
<Rules AnalyzerId="SonarAnalyzer.CSharp" RuleNamespace="SonarAnalyzer.CSharp">
5959
<!-- Don't use hardcoded paths or URIs - needed in several test cases. -->
6060
<Rule Id="S1075" Action="None" />
61-
<!-- Utility class should not be instantiated - test fixture classes with nested tests can't be static. -->
6261
<!-- Sections of code should not be commented out - test files may retain commented examples. -->
6362
<Rule Id="S125" Action="None" />
63+
<!-- Utility class should not be instantiated - test fixture classes with nested tests can't be static. -->
6464
<Rule Id="S1118" Action="None" />
6565
<!-- Don't call GC.Collect - required for weak reference and disposal tests. -->
6666
<Rule Id="S1215" Action="None" />
@@ -137,11 +137,6 @@
137137
<!-- Don't copy/paste documentation. -->
138138
<Rule Id="SA1625" Action="None" />
139139
</Rules>
140-
<Rules AnalyzerId="xUnit" RuleNamespace="xUnit">
141-
<!-- Use Assert.Single when there's only one collection entry. -->
142-
<Rule Id="xUnit2023" Action="Warning" />
143-
</Rules>
144-
<!-- IDE rules for test assemblies. -->
145140
<Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp" RuleNamespace="Microsoft.CodeAnalysis.CSharp">
146141
<!-- Private member is unused - tests for reflection require members that may not get used. -->
147142
<Rule Id="IDE0051" Action="None" />

0 commit comments

Comments
 (0)