-
Notifications
You must be signed in to change notification settings - Fork 864
Expand file tree
/
Copy pathSonarAnalyzer.CSharp.yml
More file actions
6999 lines (6999 loc) · 270 KB
/
SonarAnalyzer.CSharp.yml
File metadata and controls
6999 lines (6999 loc) · 270 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Origin:
AssemblyName: SonarAnalyzer.CSharp
Version: 9.12.0.78982
Diagnostics:
S100:
Metadata:
Category: Minor Code Smell
Title: Methods and properties should be named in PascalCase
Description: Shared naming conventions allow teams to collaborate efficiently.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-100
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 3
Attributes:
general:
Severity: None
Redundant: IDE1006
S1006:
Metadata:
Category: Critical Code Smell
Title: Method overrides should not change parameter defaults
Description: Default arguments are determined by the static type of the object.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1006
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 1
Attributes:
general:
Severity: Warning
S101:
Metadata:
Category: Minor Code Smell
Title: Types should be named in PascalCase
Description: Shared naming conventions allow teams to collaborate efficiently.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-101
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 3
Attributes:
general:
Severity: None
Redundant: IDE1006
S103:
Metadata:
Category: Major Code Smell
Title: Lines should not be too long
Description: Scrolling horizontally to see a full line of code lowers the code readability.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-103
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: Warning
S104:
Metadata:
Category: Major Code Smell
Title: Files should not have too many lines of code
Description: When a source file grows too much, it can accumulate numerous responsibilities and become challenging to understand and maintain.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-104
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: Warning
S1048:
Metadata:
Category: Blocker Bug
Title: Finalizers should not throw exceptions
Description: The finalizers are used to perform any necessary final clean-up when the garbage collector is collecting a class instance. The programmer has no control over when the finalizer is called; the garbage collector decides when to call it.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1048
CustomTags:
- C#
- MainSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 1
Attributes:
general:
Severity: None
Redundant: CA1065
S105:
Metadata:
Category: Minor Code Smell
Title: Tabulation characters should not be used
Description: The tab width can differ from one development environment to another. Using tabs may require other developers to configure their environment (text editor, preferences, etc.) to read source code.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-105
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 3
Attributes:
general:
Severity: None
Redundant: SA1027
S106:
Metadata:
Category: Major Code Smell
Title: Standard outputs should not be used directly to log anything
Description: 'When logging a message there are several important requirements which must be fulfilled:'
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-106
CustomTags:
- C#
- MainSourceScope
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: None
production:
Severity: Warning
S1066:
Metadata:
Category: Major Code Smell
Title: Collapsible "if" statements should be merged
Description: Merging collapsible if statements increases the code’s readability.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1066
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 3
Attributes:
general:
Severity: None
S1067:
Metadata:
Category: Critical Code Smell
Title: Expressions should not be too complex
Description: 'The complexity of an expression is defined by the number of &&, || and condition ? ifTrue : ifFalse operators it contains.'
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1067
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: Warning
S107:
Metadata:
Category: Major Code Smell
Title: Methods should not have too many parameters
Description: Methods with a long parameter list are difficult to use, as maintainers must figure out the role of each parameter and keep track of their position.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-107
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 3
Attributes:
general:
Severity: Warning
S1075:
Metadata:
Category: Minor Code Smell
Title: URIs should not be hardcoded
Description: 'Hardcoding a URI makes it difficult to test a program: path literals are not always portable across operating systems, a given absolute path may not exist on a specific test environment, a specified Internet URL may not be available when executing the tests, production environment filesystems usually differ from the development environment, …etc. For all those reasons, a URI should never be hardcoded. Instead, it should be replaced by customizable parameter.'
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1075
CustomTags:
- C#
- MainSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: Warning
S108:
Metadata:
Category: Major Code Smell
Title: Nested blocks of code should not be left empty
Description: An empty code block is confusing. It will require some effort from maintainers to determine if it is intentional or indicates the implementation is incomplete.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-108
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 3
Attributes:
general:
Severity: Warning
S109:
Metadata:
Category: Major Code Smell
Title: Magic numbers should not be used
Description: A magic number is a number that comes out of nowhere, and is directly used in a statement. Magic numbers are often used, for instance to limit the number of iterations of a loop, to test the value of a property, etc.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-109
CustomTags:
- C#
- MainSourceScope
DefaultSeverity: Warning
Tier: 3
Attributes:
general:
Severity: Warning
S110:
Metadata:
Category: Major Code Smell
Title: Inheritance tree of classes should not be too deep
Description: Inheritance is one of the most valuable concepts in object-oriented programming. It’s a way to categorize and reuse code by creating collections of attributes and behaviors called classes, which can be based on previously created classes.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-110
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 3
Attributes:
general:
Severity: Warning
S1104:
Metadata:
Category: Minor Code Smell
Title: Fields should not have public accessibility
Description: 'Public fields in public classes do not respect the encapsulation principle and has three main disadvantages:'
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1104
CustomTags:
- C#
- MainSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: None
Redundant: CA1051
S1109:
Metadata:
Category: Minor Code Smell
Title: A close curly brace should be located at the beginning of a line
Description: Shared coding conventions make it possible for a team to efficiently collaborate. This rule makes it mandatory to place a close curly brace at the beginning of a line.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1109
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: None
Redundant: SA1500
S1110:
Metadata:
Category: Major Code Smell
Title: Redundant pairs of parentheses should be removed
Description: The use of parentheses, even those not required to enforce a desired order of operations, can clarify the intent behind a piece of code. But redundant pairs of parentheses could be misleading, and should be removed.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1110
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: None
Redundant: SA1119
S1116:
Metadata:
Category: Minor Code Smell
Title: Empty statements should be removed
Description: 'Empty statements, i.e. ;, are usually introduced by mistake, for example because:'
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1116
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: None
Redundant: SA1106
S1117:
Metadata:
Category: Major Code Smell
Title: Local variables should not shadow class fields or properties
Description: Overriding or shadowing a field or a property declared in an outer scope can strongly impact the readability, and therefore the maintainability, of a piece of code. Developers may mistakenly assume they are modifying or accessing the class field/property when, in fact, they are working with the local variable.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1117
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 1
Attributes:
general:
Severity: Warning
S1118:
Metadata:
Category: Major Code Smell
Title: Utility classes should not have public constructors
Description: Utility classes, which are collections of static members, are not meant to be instantiated.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1118
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: None
Redundant: CA1052
S112:
Metadata:
Category: Major Code Smell
Title: General exceptions should never be thrown
Description: Throwing such general exceptions as Exception, SystemException, ApplicationException, IndexOutOfRangeException, NullReferenceException, OutOfMemoryException and ExecutionEngineException prevents calling methods from handling true, system-generated exceptions differently than application-generated errors.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-112
CustomTags:
- C#
- MainSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: None
Redundant: CA2219
S1121:
Metadata:
Category: Major Code Smell
Title: Assignments should not be made from within sub-expressions
Description: Assignments within sub-expressions are hard to spot and therefore make the code less readable. Ideally, sub-expressions should not have side-effects.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1121
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 1
Attributes:
general:
Severity: Warning
S1123:
Metadata:
Category: Major Code Smell
Title: '"Obsolete" attributes should include explanations'
Description: The Obsolete attribute can be applied with or without a message argument. Marking something Obsolete without including advice on why it’s obsolete or what to use instead will lead maintainers to waste time trying to figure those things out.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1123
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: None
Redundant: CA1041
S1125:
Metadata:
Category: Minor Code Smell
Title: Boolean literals should not be redundant
Description: Redundant Boolean literals should be removed from expressions to improve readability.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1125
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: Warning
S1128:
Metadata:
Category: Minor Code Smell
Title: Unused "using" should be removed
Description: 'Although unnecessary using won’t change anything to the produced application, removing them:'
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1128
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: Warning
S113:
Metadata:
Category: Minor Code Smell
Title: Files should contain an empty newline at the end
Description: Some tools work better when files end with an empty line.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-113
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 3
Attributes:
general:
Severity: None
S1134:
Metadata:
Category: Major Code Smell
Title: Track uses of "FIXME" tags
Description: FIXME tags are commonly used to mark places where a bug is suspected, but which the developer wants to deal with later.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1134
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 3
Attributes:
general:
Severity: Warning
S1135:
Metadata:
Category: Info Code Smell
Title: Track uses of "TODO" tags
Description: Developers often use TOOO tags to mark areas in the code where additional work or improvements are needed but are not implemented immediately. However, these TODO tags sometimes get overlooked or forgotten, leading to incomplete or unfinished code. This code smell class aims to identify and address such unattended TODO tags to ensure a clean and maintainable codebase. This description will explore why this is a problem and how it can be fixed to improve the overall code quality.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1135
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 1
Attributes:
general:
Severity: Warning
S1144:
Metadata:
Category: Major Code Smell
Title: Unused private types or members should be removed
Description: 'private or internal types or private members that are never executed or referenced are unused code: unnecessary, inoperative code that should be removed.'
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1144
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: Warning
S1145:
Metadata:
Category: Major Bug
Title: Useless "if(true) {...}" and "if(false){...}" blocks should be removed
Description: if statements with conditions that are always false have the effect of making blocks of code non-functional. if statements with conditions that are always true are completely redundant, and make the code less readable.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1145
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
Tier: 1
Attributes:
general:
Severity: Warning
S1147:
Metadata:
Category: Blocker Code Smell
Title: Exit methods should not be called
Description: Calling Environment.Exit(exitCode) or Application.Exit() terminates the process and returns an exit code to the operating system..
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1147
CustomTags:
- C#
- MainSourceScope
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: Warning
S1151:
Metadata:
Category: Major Code Smell
Title: '"switch case" clauses should not have too many lines of code'
Description: The switch statement should be used only to clearly define some new branches in the control flow. As soon as a case clause contains too many statements this highly decreases the readability of the overall control flow statement. In such case, the content of the case clause should be extracted into a dedicated method.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1151
CustomTags:
- C#
- MainSourceScope
DefaultSeverity: Warning
Tier: 3
Attributes:
general:
Severity: None
S1155:
Metadata:
Category: Minor Code Smell
Title: '"Any()" should be used to test for emptiness'
Description: 'Using .Count() to test for emptiness works, but using .Any() makes the intent clearer, and the code more readable. However, there are some cases where special attention should be paid:'
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1155
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 3
Attributes:
general:
Severity: Warning
S1163:
Metadata:
Category: Critical Code Smell
Title: Exceptions should not be thrown in finally blocks
Description: If an exception is already being thrown within the try block or caught in a catch block, throwing another exception in the finally block will override the original exception. This means that the original exception’s message and stack trace will be lost, potentially making it challenging to diagnose and troubleshoot the root cause of the problem.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1163
CustomTags:
- C#
- MainSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 1
Attributes:
general:
Severity: None
Redundant: CA2219
S1168:
Metadata:
Category: Major Code Smell
Title: Empty arrays and collections should be returned instead of null
Description: Returning null or default instead of an actual collection forces the method callers to explicitly test for null, making the code more complex and less readable.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1168
CustomTags:
- C#
- MainSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: Warning
S1172:
Metadata:
Category: Major Code Smell
Title: Unused method parameters should be removed
Description: Unused parameters are misleading. Whatever the values passed to such parameters, the behavior will be the same.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1172
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 3
Attributes:
general:
Severity: None
Redundant: IDE0060
S1185:
Metadata:
Category: Minor Code Smell
Title: Overriding members should do more than simply call the same member in the base class
Description: Overriding a method just to call the same method from the base class without performing any other actions is useless and misleading. The only time this is justified is in sealed overriding methods, where the effect is to lock in the parent class behavior. This rule ignores overrides of Equals and GetHashCode.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1185
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 3
Attributes:
general:
Severity: Warning
S1186:
Metadata:
Category: Critical Code Smell
Title: Methods should not be empty
Description: An empty method is generally considered bad practice and can lead to confusion, readability, and maintenance issues. Empty methods bring no functionality and are misleading to others as they might think the method implementation fulfills a specific and identified requirement.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1186
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: Warning
S1192:
Metadata:
Category: Minor Code Smell
Title: String literals should not be duplicated
Description: Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1192
CustomTags:
- C#
- MainSourceScope
DefaultSeverity: Warning
Tier: 3
Attributes:
general:
Severity: Suggestion
S1199:
Metadata:
Category: Minor Code Smell
Title: Nested code blocks should not be used
Description: Nested code blocks can be used to create a new scope and restrict the visibility of the variables defined inside it. Using this feature in a method typically indicates that the method has too many responsibilities, and should be refactored into smaller methods.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1199
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 3
Attributes:
general:
Severity: Warning
S1200:
Metadata:
Category: Major Code Smell
Title: Classes should not be coupled to too many other classes
Description: 'According to the Single Responsibility Principle, introduced by Robert C. Martin in his book "Principles of Object Oriented Design", a class should have only one responsibility:'
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1200
CustomTags:
- C#
- MainSourceScope
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: None
S1206:
Metadata:
Category: Minor Bug
Title: '"Equals(Object)" and "GetHashCode()" should be overridden in pairs'
Description: Suppose you override Object.Equals in a type, you must also override Object.GetHashCode. If two objects are equal according to the Equals method, then calling GetHashCode on each of them must yield the same integer. If this is not the case, many collections, such as a Hashtable or a Dictionary won’t handle class instances correctly.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1206
CustomTags:
- C#
- MainSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: None
Redundant: CS0659
S121:
Metadata:
Category: Critical Code Smell
Title: Control structures should use curly braces
Description: Control structures are code statements that impact the program’s control flow (e.g., if statements, for loops, etc.)
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-121
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: None
Redundant: SA1503
S1210:
Metadata:
Category: Minor Code Smell
Title: '"Equals" and the comparison operators should be overridden when implementing "IComparable"'
Description: When you implement IComparable or IComparable<T> on a class you should also override Equals(object) and overload the comparison operators (==, !=, <, <=, >, >=). That’s because the CLR cannot automatically call your CompareTo implementation from Equals(object) or from the base comparison operator implementations. Additionally, it is best practice to override GetHashCode along with Equals.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1210
CustomTags:
- C#
- MainSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: None
Redundant: CA1036
S1215:
Metadata:
Category: Critical Code Smell
Title: '"GC.Collect" should not be called'
Description: GC.Collect is a method that forces or suggests to the garbage collector to run a collection of objects in the managed heap that are no longer being used and free their memory.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1215
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 1
Attributes:
general:
Severity: None
performance:
Severity: Warning
S122:
Metadata:
Category: Major Code Smell
Title: Statements should be on separate lines
Description: Putting multiple statements on a single line lowers the code readability and makes debugging the code more complex.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-122
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: None
S1226:
Metadata:
Category: Minor Bug
Title: Method parameters, caught exceptions and foreach variables' initial values should not be ignored
Description: While it is technically correct to assign to parameters from within method bodies, doing so before the parameter value is read is likely a bug. Instead, initial values of parameters, caught exceptions, and foreach parameters should be, if not treated as final, then at least read before reassignment.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1226
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 1
Attributes:
general:
Severity: Warning
S1227:
Metadata:
Category: Minor Code Smell
Title: break statements should not be used except for switch cases
Description: break; is an unstructured control flow statement which makes code harder to read.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1227
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: None
S1244:
Metadata:
Category: Major Bug
Title: Floating point numbers should not be tested for equality
Description: Floating point math is imprecise because of the challenges of storing such values in a binary representation. Even worse, floating point math is not associative; push a float or a double through a series of simple mathematical operations and the answer will be different based on the order of those operation because of the rounding that takes place at each step.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1244
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 1
Attributes:
general:
Severity: Error
S125:
Metadata:
Category: Major Code Smell
Title: Sections of code should not be commented out
Description: Programmers should not comment out code as it bloats programs and reduces readability.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-125
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 3
Attributes:
general:
Severity: Warning
S126:
Metadata:
Category: Critical Code Smell
Title: '"if ... else if" constructs should end with "else" clauses'
Description: This rule applies whenever an if statement is followed by one or more else if statements; the final else if should be followed by an else statement.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-126
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: None
S1264:
Metadata:
Category: Minor Code Smell
Title: A "while" loop should be used instead of a "for" loop
Description: When only the condition expression is defined in a for loop, and the initialization and increment expressions are missing, a while loop should be used instead to increase readability.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1264
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: Warning
S127:
Metadata:
Category: Major Code Smell
Title: '"for" loop stop conditions should be invariant'
Description: A for loop stop condition should test the loop counter against an invariant value (i.e. one that is true at both the beginning and ending of every loop iteration). Ideally, this means that the stop condition is set to a local variable just before the loop begins.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-127
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 1
Attributes:
general:
Severity: Warning
S1301:
Metadata:
Category: Minor Code Smell
Title: '"switch" statements should have at least 3 "case" clauses'
Description: switch statements and expressions are useful when there are many different cases depending on the value of the same expression.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1301
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 3
Attributes:
general:
Severity: None
S1309:
Metadata:
Category: Info Code Smell
Title: Track uses of in-source issue suppressions
Description: 'This rule allows you to track the usage of the SuppressMessage attributes and #pragma warning disable mechanism.'
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1309
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 1
Attributes:
general:
Severity: None
Comment: Suppressions are frequently necessary.
S131:
Metadata:
Category: Critical Code Smell
Title: '"switch/Select" statements should contain a "default/Case Else" clauses'
Description: The requirement for a final default clause is defensive programming. The clause should either take appropriate action, or contain a suitable comment as to why no action is taken. Even when the switch covers all current values of an enum, a default case should still be used because there is no guarantee that the enum won’t be extended.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-131
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 1
Attributes:
general:
Severity: None
S1313:
Metadata:
Category: Major Security Hotspot
Title: Using hardcoded IP addresses is security-sensitive
Description: 'Hardcoding IP addresses is security-sensitive. It has led in the past to the following vulnerabilities:'
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1313
CustomTags:
- C#
- MainSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 1
Attributes:
general:
Severity: Warning
S134:
Metadata:
Category: Critical Code Smell
Title: Control flow statements "if", "switch", "for", "foreach", "while", "do" and "try" should not be nested too deeply
Description: Nested if, switch, for, foreach, while, do, and try statements are key ingredients for making what’s known as "Spaghetti code".
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-134
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 1
Attributes:
general:
Severity: None
S138:
Metadata:
Category: Major Code Smell
Title: Functions should not have too many lines of code
Description: A function that grows too large tends to aggregate too many responsibilities.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-138
CustomTags:
- C#
- MainSourceScope
DefaultSeverity: Warning
Tier: 3
Attributes:
general:
Severity: None
S1449:
Metadata:
Category: Minor Code Smell
Title: Culture should be specified for "string" operations
Description: string.ToLower(), ToUpper, IndexOf, LastIndexOf, and Compare are all culture-dependent, as are some (floating point number and DateTime-related) calls to ToString. Fortunately, all have variants which accept an argument specifying the culture or formatter to use. Leave that argument off and the call will use the system default culture, possibly creating problems with international characters.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1449
CustomTags:
- C#
- MainSourceScope
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: Warning
S1450:
Metadata:
Category: Minor Code Smell
Title: Private fields only used as local variables in methods should become local variables
Description: When the value of a private field is always assigned to in a class' methods before being read, then it is not being used to store class information. Therefore, it should become a local variable in the relevant methods to prevent any misunderstanding.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1450
CustomTags:
- C#
- MainSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 2
Attributes:
general:
Severity: Warning
S1451:
Metadata:
Category: Blocker Code Smell
Title: Track lack of copyright and license headers
Description: Each source file should start with a header stating file ownership and the license which must be used to distribute the application.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1451
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
DefaultSeverity: Warning
Tier: 1
Attributes:
general:
Severity: None
Redundant: IDE0073
S1479:
Metadata:
Category: Major Code Smell
Title: '"switch" statements should not have too many "case" clauses'
Description: When switch statements have large sets of case clauses, it is usually an attempt to map two sets of data. A Dictionary should be used instead to make the code more readable and maintainable.
HelpLinkUri: https://rules.sonarsource.com/csharp/RSPEC-1479
CustomTags:
- C#
- MainSourceScope
- TestSourceScope
- SonarWay
DefaultSeverity: Warning
Tier: 2
Attributes: