Skip to content

Commit 64c2e29

Browse files
Strengthen analyzer ruleset: promote correctness-critical rules to warning (#157)
1 parent 7afd59f commit 64c2e29

7 files changed

Lines changed: 79 additions & 1026 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,3 +485,4 @@ $RECYCLE.BIN/
485485

486486
# Build output
487487
.output/
488+
.claude/settings.local.json

Workleap.DotNet.CodingStandards.nuspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<dependency id="Meziantou.Analyzer" version="3.0.29" />
1717
<dependency id="Microsoft.CodeAnalysis.BannedApiAnalyzers" version="3.3.4" />
1818
<dependency id="Microsoft.CodeAnalysis.NetAnalyzers" version="10.0.201" />
19-
<dependency id="StyleCop.Analyzers" version="1.2.0-beta.556" />
2019
</dependencies>
2120
</metadata>
2221
<files>

src/files/analyzers/Analyzer.Meziantou.Analyzer.editorconfig

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
is_global = true
33
global_level = 0
44

5+
MA0048.only_validate_first_type = true
6+
MA0048.allow_oft_for_all_generic_types = true
7+
58
# MA0001: StringComparison is missing
69
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0001.md
710
# Enabled: True, Severity: suggestion
@@ -75,7 +78,8 @@ dotnet_diagnostic.MA0014.severity = none
7578
# MA0015: Specify the parameter name in ArgumentException
7679
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0015.md
7780
# Enabled: True, Severity: warning
78-
dotnet_diagnostic.MA0015.severity = suggestion
81+
dotnet_diagnostic.MA0015.severity = warning
82+
dotnet_code_quality.MA0015.consider_member_access_as_parameter = true
7983

8084
# MA0016: Prefer using collection abstraction instead of implementation
8185
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0016.md
@@ -95,7 +99,7 @@ dotnet_diagnostic.MA0018.severity = none
9599
# MA0019: Use EventArgs.Empty
96100
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0019.md
97101
# Enabled: True, Severity: warning
98-
dotnet_diagnostic.MA0019.severity = suggestion
102+
dotnet_diagnostic.MA0019.severity = warning
99103

100104
# MA0020: Use direct methods instead of LINQ methods
101105
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0020.md
@@ -150,7 +154,7 @@ dotnet_diagnostic.MA0029.severity = suggestion
150154
# MA0030: Remove useless OrderBy call
151155
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0030.md
152156
# Enabled: True, Severity: warning
153-
dotnet_diagnostic.MA0030.severity = suggestion
157+
dotnet_diagnostic.MA0030.severity = warning
154158

155159
# MA0031: Optimize Enumerable.Count() usage
156160
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0031.md
@@ -195,7 +199,7 @@ dotnet_diagnostic.MA0039.severity = none
195199
# MA0040: Forward the CancellationToken parameter to methods that take one
196200
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0040.md
197201
# Enabled: True, Severity: suggestion
198-
dotnet_diagnostic.MA0040.severity = suggestion
202+
dotnet_diagnostic.MA0040.severity = warning
199203

200204
# MA0041: Make property static (deprecated, use CA1822 instead)
201205
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0041.md
@@ -235,7 +239,7 @@ dotnet_diagnostic.MA0047.severity = none
235239
# MA0048: File name must match type name
236240
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0048.md
237241
# Enabled: True, Severity: warning
238-
dotnet_diagnostic.MA0048.severity = none
242+
dotnet_diagnostic.MA0048.severity = warning
239243

240244
# MA0049: Type name should not match containing namespace
241245
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0049.md
@@ -245,7 +249,7 @@ dotnet_diagnostic.MA0049.severity = none
245249
# MA0050: Validate arguments correctly in iterator methods
246250
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0050.md
247251
# Enabled: True, Severity: suggestion
248-
dotnet_diagnostic.MA0050.severity = none
252+
dotnet_diagnostic.MA0050.severity = suggestion
249253

250254
# MA0051: Method is too long
251255
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0051.md
@@ -255,7 +259,7 @@ dotnet_diagnostic.MA0051.severity = none
255259
# MA0052: Replace constant Enum.ToString with nameof
256260
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0052.md
257261
# Enabled: True, Severity: suggestion
258-
dotnet_diagnostic.MA0052.severity = suggestion
262+
dotnet_diagnostic.MA0052.severity = warning
259263

260264
# MA0053: Make class or record sealed
261265
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0053.md
@@ -310,22 +314,22 @@ dotnet_diagnostic.MA0062.severity = none
310314
# MA0063: Use Where before OrderBy
311315
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0063.md
312316
# Enabled: True, Severity: suggestion
313-
dotnet_diagnostic.MA0063.severity = suggestion
317+
dotnet_diagnostic.MA0063.severity = warning
314318

315319
# MA0064: Avoid locking on publicly accessible instance
316320
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0064.md
317321
# Enabled: True, Severity: warning
318-
dotnet_diagnostic.MA0064.severity = none
322+
dotnet_diagnostic.MA0064.severity = warning
319323

320324
# MA0065: Default ValueType.Equals or HashCode is used for struct equality
321325
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0065.md
322326
# Enabled: True, Severity: warning
323-
dotnet_diagnostic.MA0065.severity = none
327+
dotnet_diagnostic.MA0065.severity = warning
324328

325329
# MA0066: Hash table unfriendly type is used in a hash table
326330
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0066.md
327331
# Enabled: True, Severity: warning
328-
dotnet_diagnostic.MA0066.severity = none
332+
dotnet_diagnostic.MA0066.severity = warning
329333

330334
# MA0067: Use Guid.Empty
331335
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0067.md
@@ -340,7 +344,7 @@ dotnet_diagnostic.MA0068.severity = warning
340344
# MA0069: Non-constant static fields should not be visible
341345
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0069.md
342346
# Enabled: True, Severity: warning
343-
dotnet_diagnostic.MA0069.severity = none
347+
dotnet_diagnostic.MA0069.severity = warning
344348

345349
# MA0070: Obsolete attributes should include explanations
346350
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0070.md
@@ -380,7 +384,7 @@ dotnet_diagnostic.MA0076.severity = none
380384
# MA0077: A class that provides Equals(T) should implement IEquatable<T>
381385
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0077.md
382386
# Enabled: True, Severity: warning
383-
dotnet_diagnostic.MA0077.severity = none
387+
dotnet_diagnostic.MA0077.severity = warning
384388

385389
# MA0078: Use 'Cast' instead of 'Select' to cast
386390
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0078.md
@@ -410,7 +414,7 @@ dotnet_diagnostic.MA0082.severity = warning
410414
# MA0083: ConstructorArgument parameters should exist in constructors
411415
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0083.md
412416
# Enabled: True, Severity: warning
413-
dotnet_diagnostic.MA0083.severity = none
417+
dotnet_diagnostic.MA0083.severity = warning
414418

415419
# MA0084: Local variables should not hide other symbols
416420
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0084.md
@@ -430,12 +434,12 @@ dotnet_diagnostic.MA0086.severity = warning
430434
# MA0087: Parameters with [DefaultParameterValue] attributes should also be marked [Optional]
431435
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0087.md
432436
# Enabled: True, Severity: warning
433-
dotnet_diagnostic.MA0087.severity = suggestion
437+
dotnet_diagnostic.MA0087.severity = warning
434438

435439
# MA0088: Use [DefaultParameterValue] instead of [DefaultValue]
436440
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0088.md
437441
# Enabled: True, Severity: warning
438-
dotnet_diagnostic.MA0088.severity = suggestion
442+
dotnet_diagnostic.MA0088.severity = warning
439443

440444
# MA0089: Optimize string method usage
441445
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0089.md
@@ -465,17 +469,17 @@ dotnet_diagnostic.MA0093.severity = suggestion
465469
# MA0094: A class that provides CompareTo(T) should implement IComparable<T>
466470
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0094.md
467471
# Enabled: True, Severity: warning
468-
dotnet_diagnostic.MA0094.severity = none
472+
dotnet_diagnostic.MA0094.severity = warning
469473

470474
# MA0095: A class that implements IEquatable<T> should override Equals(object)
471475
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0095.md
472476
# Enabled: True, Severity: warning
473-
dotnet_diagnostic.MA0095.severity = none
477+
dotnet_diagnostic.MA0095.severity = warning
474478

475479
# MA0096: A class that implements IComparable<T> should also implement IEquatable<T>
476480
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0096.md
477481
# Enabled: True, Severity: warning
478-
dotnet_diagnostic.MA0096.severity = none
482+
dotnet_diagnostic.MA0096.severity = warning
479483

480484
# MA0097: A class that implements IComparable<T> or IComparable should override comparison operators
481485
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0097.md
@@ -510,7 +514,7 @@ dotnet_diagnostic.MA0102.severity = none
510514
# MA0103: Use SequenceEqual instead of equality operator
511515
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0103.md
512516
# Enabled: True, Severity: warning
513-
dotnet_diagnostic.MA0103.severity = suggestion
517+
dotnet_diagnostic.MA0103.severity = warning
514518

515519
# MA0104: Do not create a type with a name from the BCL
516520
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0104.md
@@ -520,7 +524,7 @@ dotnet_diagnostic.MA0104.severity = none
520524
# MA0105: Use the lambda parameters instead of using a closure
521525
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0105.md
522526
# Enabled: True, Severity: suggestion
523-
dotnet_diagnostic.MA0105.severity = none
527+
dotnet_diagnostic.MA0105.severity = suggestion
524528

525529
# MA0106: Avoid closure by using an overload with the 'factoryArgument' parameter
526530
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0106.md
@@ -535,7 +539,7 @@ dotnet_diagnostic.MA0107.severity = none
535539
# MA0108: Remove redundant argument value
536540
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0108.md
537541
# Enabled: True, Severity: suggestion
538-
dotnet_diagnostic.MA0108.severity = suggestion
542+
dotnet_diagnostic.MA0108.severity = warning
539543

540544
# MA0109: Consider adding an overload with a Span<T> or Memory<T>
541545
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0109.md
@@ -650,7 +654,7 @@ dotnet_diagnostic.MA0130.severity = warning
650654
# MA0131: ArgumentNullException.ThrowIfNull should not be used with non-nullable types
651655
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0131.md
652656
# Enabled: True, Severity: warning
653-
dotnet_diagnostic.MA0131.severity = none
657+
dotnet_diagnostic.MA0131.severity = warning
654658

655659
# MA0132: Do not convert implicitly to DateTimeOffset
656660
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0132.md
@@ -770,7 +774,7 @@ dotnet_diagnostic.MA0154.severity = none
770774
# MA0155: Do not use async void methods
771775
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0155.md
772776
# Enabled: False, Severity: warning
773-
dotnet_diagnostic.MA0155.severity = none
777+
dotnet_diagnostic.MA0155.severity = warning
774778

775779
# MA0156: Use 'Async' suffix when a method returns IAsyncEnumerable<T>
776780
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0156.md
@@ -810,7 +814,7 @@ dotnet_diagnostic.MA0162.severity = none
810814
# MA0163: UseShellExecute must be false when redirecting standard input or output
811815
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0163.md
812816
# Enabled: True, Severity: warning
813-
dotnet_diagnostic.MA0163.severity = none
817+
dotnet_diagnostic.MA0163.severity = warning
814818

815819
# MA0164: Use parentheses to make not pattern clearer
816820
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0164.md
@@ -820,7 +824,7 @@ dotnet_diagnostic.MA0164.severity = none
820824
# MA0166: Forward the TimeProvider to methods that take one
821825
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0166.md
822826
# Enabled: True, Severity: suggestion
823-
dotnet_diagnostic.MA0166.severity = suggestion
827+
dotnet_diagnostic.MA0166.severity = warning
824828

825829
# MA0167: Use an overload with a TimeProvider argument
826830
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0167.md
@@ -880,7 +884,7 @@ dotnet_diagnostic.MA0177.severity = none
880884
# MA0178: Use TimeSpan.Zero instead of TimeSpan.FromXXX(0)
881885
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0178.md
882886
# Enabled: True, Severity: suggestion
883-
dotnet_diagnostic.MA0178.severity = suggestion
887+
dotnet_diagnostic.MA0178.severity = warning
884888

885889
# MA0179: Use Attribute.IsDefined instead of GetCustomAttribute(s)
886890
# Help link: https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0179.md

src/files/analyzers/Analyzer.Microsoft.CodeAnalysis.NetAnalyzers.editorconfig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,12 @@ dotnet_diagnostic.CA1308.severity = none
285285
# CA1309: Use ordinal string comparison
286286
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1309
287287
# Enabled: True, Severity: silent
288-
dotnet_diagnostic.CA1309.severity = suggestion
288+
dotnet_diagnostic.CA1309.severity = warning
289289

290290
# CA1310: Specify StringComparison for correctness
291291
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1310
292292
# Enabled: True, Severity: silent
293-
dotnet_diagnostic.CA1310.severity = suggestion
293+
dotnet_diagnostic.CA1310.severity = warning
294294

295295
# CA1311: Specify a culture or use an invariant version
296296
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1311
@@ -378,7 +378,7 @@ dotnet_diagnostic.CA1509.severity = none
378378
# CA1510: Use ArgumentNullException throw helper
379379
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1510
380380
# Enabled: True, Severity: suggestion
381-
dotnet_diagnostic.CA1510.severity = suggestion
381+
dotnet_diagnostic.CA1510.severity = warning
382382

383383
# CA1511: Use ArgumentException throw helper
384384
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1511
@@ -799,7 +799,7 @@ dotnet_diagnostic.CA1870.severity = warning
799799
# CA1871: Do not pass a nullable struct to 'ArgumentNullException.ThrowIfNull'
800800
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1871
801801
# Enabled: True, Severity: suggestion
802-
dotnet_diagnostic.CA1871.severity = suggestion
802+
dotnet_diagnostic.CA1871.severity = warning
803803

804804
# CA1872: Prefer 'Convert.ToHexString' and 'Convert.ToHexStringLower' over call chains based on 'BitConverter.ToString'
805805
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1872
@@ -952,7 +952,7 @@ dotnet_diagnostic.CA2200.severity = warning
952952
# CA2201: Do not raise reserved exception types
953953
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201
954954
# Enabled: True, Severity: silent
955-
dotnet_diagnostic.CA2201.severity = suggestion
955+
dotnet_diagnostic.CA2201.severity = warning
956956

957957
# CA2207: Initialize value type static fields inline
958958
# Help link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2207

0 commit comments

Comments
 (0)