-
Notifications
You must be signed in to change notification settings - Fork 7
/
check_contents.yml
1158 lines (1158 loc) · 215 KB
/
check_contents.yml
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
---
com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck:
Description: |
<p>Checks location of annotation on language elements.By default, Check enforce to locate annotations immediately after documentation blockand before target element, annotation should be located on separate line from targetelement. This check also verifies that the annotations are on the same indenting level asthe annotated element if they are not on the same line.</p><p>Attention: Elements that cannot have JavaDoc comments like local variables are not in thescope of this check even though a token type like <code>VARIABLE_DEF</code> would matchthem.</p><p>Attention: Annotations among modifiers are ignored (looks like false-negative)as there might be a problem with annotations for return types:</p><source>public @Nullable Long getStartTimeOrNull() { ... }</source><p>Such annotations are better to keep close to type.Due to limitations, Checkstyle can not examine the target of an annotation.</p><p>Example:</p><source><br>@Override<br>@Nullable<br>public String getNameIfPresent() { ... }<br> </source><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.annotation
com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationOnSameLineCheck:
Description: |
<p>Checks that annotations are located on the same line with their targets.Verifying with this check is not good practice, but it is using by some style guides.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.annotation
com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck:
Description: |
<p>Checks the style of elements in annotations.</p><p>Annotations have three element styles starting with the least verbose.</p><ul><li><code>ElementStyleOption.COMPACT_NO_ARRAY</code></li><li><code>ElementStyleOption.COMPACT</code></li><li><code>ElementStyleOption.EXPANDED</code></li></ul><p>To not enforce an element style a <code>ElementStyleOption.IGNORE</code> type is provided.The desired style can be set through the <code>elementStyle</code> property.</p><p>Using the <code>ElementStyleOption.EXPANDED</code> style is more verbose.The expanded version is sometimes referred to as "named parameters" in other languages.</p><p>Using the <code>ElementStyleOption.COMPACT</code> style is less verbose.This style can only be used when there is an element called 'value' which is eitherthe sole element or all other elements have default values.</p><p>Using the <code>ElementStyleOption.COMPACT_NO_ARRAY</code> style is less verbose.It is similar to the <code>ElementStyleOption.COMPACT</code> style but single value arraysare flagged.With annotations a single value array does not need to be placed in an array initializer.</p><p>The ending parenthesis are optional when using annotations with no elements.To always require ending parenthesis use the <code>ClosingParensOption.ALWAYS</code> type.To never have ending parenthesis use the <code>ClosingParensOption.NEVER</code> type.To not enforce a closing parenthesis preference a <code>ClosingParensOption.IGNORE</code>type is provided. Set this through the <code>closingParens</code> property.</p><p>Annotations also allow you to specify arrays of elements in a standard format.As with normal arrays, a trailing comma is optional.To always require a trailing comma use the <code>TrailingArrayCommaOption.ALWAYS</code>type.To never have a trailing comma use the <code>TrailingArrayCommaOption.NEVER</code> type.To not enforce a trailing array comma preference a<code>TrailingArrayCommaOption.IGNORE</code> type is provided.Set this through the <code>trailingArrayComma</code> property.</p><p>By default the <code>ElementStyleOption</code> is set to <code>COMPACT_NO_ARRAY</code>,the <code>TrailingArrayCommaOption</code> is set to <code>NEVER</code>,and the <code>ClosingParensOption</code> is set to <code>NEVER</code>.</p><p>According to the JLS, it is legal to include a trailing commain arrays used in annotations but Sun's Java 5 & 6 compilers will notcompile with this syntax. This may in be a bug in Sun's compilerssince eclipse 3.4's built-in compiler does allow this syntax asdefined in the JLS. Note: this was tested with compilers included withJDK versions 1.5.0.17 and 1.6.0.11 and the compiler included with eclipse 3.4.1.</p><p>See <a href="https://docs.oracle.com/javase/specs/jls/se11/html/jls-9.html#jls-9.7">Java Language specification, §9.7</a>.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.annotation
com.puppycrawl.tools.checkstyle.checks.annotation.MissingDeprecatedCheck:
Description: |
<p>Verifies that the annotation <code>@Deprecated</code> and the Javadoc tag<code>@deprecated</code> are both present when either of them is present.</p><p>Both ways of flagging deprecation serve their own purpose.The @Deprecated annotation is used for compilers and development tools.The @deprecated javadoc tag is used to document why something is deprecatedand what, if any, alternatives exist.</p><p>In order to properly mark something as deprecated both forms ofdeprecation should be present.</p><p>Package deprecation is a exception to the rule of always using thejavadoc tag and annotation to deprecate. It is not clear if thejavadoc tool will support it or not as newer versions keep flip floppingon if it is supported or will cause an error.See <a href="https://bugs.openjdk.java.net/browse/JDK-8160601">JDK-8160601</a>.The deprecated javadoc tag is currently the only way to say why the packageis deprecated and what to use instead. Until this is resolved, if youdon't want to print violations on package-info, you can use a<a href="config_filters.html">filter</a> to ignore these files untilthe javadoc tool faithfully supports it. An example config usingSuppressionSingleFilter is:</p><source><br><!-- required till https://bugs.openjdk.java.net/browse/JDK-8160601 --><br><module name="SuppressionSingleFilter"><br> <property name="checks" value="MissingDeprecatedCheck"/><br> <property name="files" value="package-info\.java"/><br></module><br> </source><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.annotation
com.puppycrawl.tools.checkstyle.checks.annotation.MissingOverrideCheck:
Description: |
<p>Verifies that the <code>@Override</code> annotation is presentwhen the <code>@inheritDoc</code> javadoc tag is present.</p><p>Rationale: The @Override annotation helpscompiler tools ensure that an override is actually occurring. It isquite easy to accidentally overload a method or hide a static methodand using the @Override annotation points out these problems.</p><p>This check will log a violation if using the @inheritDoc tag on a method thatis not valid (ex: private, or static method).</p><p>There is a slight difference between the @Override annotation in Java 5 versusJava 6 and above. In Java 5, any method overridden from an interface cannotbe annotated with @Override. In Java 6 this behavior is allowed.</p><p>As a result of the aforementioned difference between Java 5 and Java 6, aproperty called <code>javaFiveCompatibility</code> is available. Thisproperty will only check classes, interfaces, etc. that do not contain theextends or implements keyword or are not anonymous classes. This means itonly checks methods overridden from <code>java.lang.Object</code>.<b>Java 5 Compatibility mode severely limits this check. It is recommended toonly use it on Java 5 source.</b></p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.annotation
com.puppycrawl.tools.checkstyle.checks.annotation.PackageAnnotationCheck:
Description: |
<p>Checks that all package annotations are in the package-info.java file.</p><p>For Java SE8 and above, placement of package annotations in the package-info.javafile is enforced by the compiler and this check is not necessary.</p><p>For Java SE7 and below, the Java Language Specification highly recommendsbut doesn't require that annotations are placed in the package-info.java file,and this check can help to enforce that placement.</p><p>See <a href="https://docs.oracle.com/javase/specs/jls/se11/html/jls-7.html#jls-7.4.1">Java Language Specification, §7.4.1</a> for more info.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.annotation
com.puppycrawl.tools.checkstyle.checks.annotation.SuppressWarningsCheck:
Description: |
<p>Allows to specify what warnings that <code>@SuppressWarnings</code>is not allowed to suppress.You can also specify a list of TokenTypes thatthe configured warning(s) cannot be suppressed on.</p><p>Limitations: This check does not consider conditionalsinside the @SuppressWarnings annotation.</p><p>For example:<code>@SuppressWarnings((false) ? (true) ? "unchecked" : "foo" : "unused")</code>.According to the above example, the "unused" warning is being suppressednot the "unchecked" or "foo" warnings. All of these warnings will beconsidered and matched against regardless of what the conditionalevaluates to.The check also does not support code like <code>@SuppressWarnings("un" + "used")</code>,<code>@SuppressWarnings((String) "unused")</code> or<code>@SuppressWarnings({('u' + (char)'n') + (""+("used" + (String)"")),})</code>.</p><p>By default, any warning specified will be disallowed onall legal TokenTypes unless otherwise specified viathe tokens property.</p><p>Also, by default warnings that are empty strings or allwhitespace (regex: ^$|^\s+$) are flagged. By specifying,the format property these defaults no longer apply.</p><p>This check can be configured so that the "unchecked"and "unused" warnings cannot be suppressed onanything but variable and parameter declarations.See below of an example.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.annotation
com.puppycrawl.tools.checkstyle.checks.SuppressWarningsHolderCheck:
Description: |
<p>Maintains a set of check suppressions from<code>@SuppressWarnings</code> annotations. It allows toprevent Checkstyle from reporting violations from parts of codethat were annotated with <code>@SuppressWarnings</code> andusing name of the check to be excluded. You can also definealiases for check names that need to be suppressed.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks
com.puppycrawl.tools.checkstyle.checks.blocks.AvoidNestedBlocksCheck:
Description: |
<p>Finds nested blocks (blocks that are used freely in the code).</p><p>Rationale: Nested blocks are often leftovers from thedebugging process, they confuse the reader.</p><p>For example this Check finds the obsolete braces in</p><source><br>public void guessTheOutput()<br>{<br> int whichIsWhich = 0;<br> {<br> whichIsWhich = 2;<br> }<br> System.out.println("value = " + whichIsWhich);<br>}<br> </source><p> and debugging / refactoring leftovers such as </p><source><br>// if (conditionThatIsNotUsedAnyLonger)<br>{<br> System.out.println("unconditional");<br>}<br> </source><p>A case in a switch statement does not implicitly form a block.Thus to be able to introduce local variables that have casescope it is necessary to open a nested block. This issupported, set the allowInSwitchCase property to true andinclude all statements of the case in the block.</p><source><br>switch (a)<br>{<br> case 0:<br> // Never OK, break outside block<br> {<br> x = 1;<br> }<br> break;<br> case 1:<br> // Never OK, statement outside block<br> System.out.println("Hello");<br> {<br> x = 2;<br> break;<br> }<br> case 2:<br> // OK if allowInSwitchCase is true<br> {<br> System.out.println("Hello");<br> x = 3;<br> break;<br> }<br>}<br> </source><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.blocks
com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck:
Description: |
<p> Checks for empty blocks. This check does not validate sequential blocks. </p><p> Sequential blocks won't be checked. Also, no violations for fallthrough: </p><source><br>switch (a) {<br> case 1: // no violation<br> case 2: // no violation<br> case 3: someMethod(); { } // no violation<br> default: break;<br>}<br> </source><p>NOTE: This check processes LITERAL_CASE and LITERAL_DEFAULT separately.Verification empty block is done for single most nearest {@code case} or {@code default}.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.blocks
com.puppycrawl.tools.checkstyle.checks.blocks.EmptyCatchBlockCheck:
Description: |
<p>Checks for empty catch blocks.By default check allows empty catch block with any comment inside.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.blocks
com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck:
Description: |
<p>Checks for the placement of left curly braces(<code>'{'</code>) for code blocks.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.blocks
com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck:
Description: |
<p> Checks for braces around code blocks. </p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.blocks
com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck:
Description: |
<p>Checks the placement of right curly braces (<code>'}'</code>) for code blocks.This check supports if-else, try-catch-finally blocks, while-loops, for-loops,method definitions, class definitions, constructor definitions,instance, static initialization blocks, annotation definitions and enum definitions.For right curly brace of expression blocks of arrays, lambdas and class instancesplease follow issue<a href="https://github.com/checkstyle/checkstyle/issues/5945">#5945</a>.For right curly brace of enum constant please follow issue<a href="https://github.com/checkstyle/checkstyle/issues/7519">#7519</a>.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.blocks
com.puppycrawl.tools.checkstyle.checks.coding.ArrayTrailingCommaCheck:
Description: |
<p>Checks that array initialization contains a trailing comma.</p><source><br>int[] a = new int[]<br>{<br> 1,<br> 2,<br> 3,<br>};<br> </source><p>By default, the check demands a comma at the end if neither left nor right curly bracesare on the same line as the last element of the array.</p><source><br>return new int[] { 0 };<br>return new int[] { 0<br> };<br>return new int[] {<br> 0 };<br> </source><p>Rationale: Putting this comma in makes it easier to change the orderof the elements or add new elements on the end. Main benefit of a trailingcomma is that when you add new entry to an array, no surrounding lines are changed.</p><source><br>{<br> 100000000000000000000,<br> 200000000000000000000, // OK<br>}<br><br>{<br> 100000000000000000000,<br> 200000000000000000000,<br> 300000000000000000000, // Just this line added, no other changes<br>}<br> </source><p>If closing brace is on the same line as trailing comma, this benefit is gone(as the check does not demand a certain location of curly braces the followingtwo cases will not produce a violation):</p><source><br>{100000000000000000000,<br> 200000000000000000000,} // Trailing comma not needed, line needs to be modified anyway<br><br>{100000000000000000000,<br> 200000000000000000000, // Modified line<br> 300000000000000000000,} // Added line<br> </source><p>If opening brace is on the same line as trailing comma there's also (more arguable)problem:</p><source><br>{100000000000000000000, // Line cannot be just duplicated to slightly modify entry<br>}<br><br>{100000000000000000000,<br> 100000000000000000001, // More work needed to duplicate<br>}<br> </source><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.AvoidDoubleBraceInitializationCheck:
Description: |
<p>Detects double brace initialization.</p><p>Rationale: Double brace initialization (set of<a href="https://docs.oracle.com/javase/specs/jls/se12/html/jls-8.html#jls-8.6">Instance Initializers</a> in class body) may look cool,but it is considered as anti-pattern and should be avoided.This is also can lead to a hard-to-detect memory leak, if the anonymous class instance isreturned outside and other object(s) hold reference to it.Created anonymous class is not static, it holds an implicit reference to the outer classinstance.See this<a href="https://blog.jooq.org/2014/12/08/dont-be-clever-the-double-curly-braces-anti-pattern/">blog post</a> and<a href="https://www.baeldung.com/java-double-brace-initialization">article</a> for more details.Check ignores any comments and semicolons in class body.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.AvoidInlineConditionalsCheck:
Description: |
<p>Detects inline conditionals. Here is one example of an inline conditional:</p><source><br>String a = getParameter("a");<br>String b = (a==null || a.length()<1) ? null : a.substring(1);<br> </source><p>Rationale: Some developers find inline conditionals hard to read, sotheir employer's coding standards forbid them.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.AvoidNoArgumentSuperConstructorCallCheck:
Description: |
<p>Checks if call to superclass constructor without arguments is present.Such invocation is redundant because constructor body implicitlybegins with a superclass constructor invocation <code>super();</code>See <a href="https://docs.oracle.com/javase/specs/jls/se13/html/jls-8.html#jls-8.8.7">specification</a> for detailed information.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.CovariantEqualsCheck:
Description: |
<p>Checks that classes and records which define a covariant <code>equals()</code> methodalso override method <code>equals(Object)</code>.</p><p>Covariant <code>equals()</code> - method that is similar to <code>equals(Object)</code>,but with a covariant parameter type (any subtype of Object).</p><p><strong>Notice</strong>: the enums are also checked, eventhough they cannot override <code>equals(Object)</code>. The reason isto point out that implementing <code>equals()</code> in enums is considered anawful practice: it may cause having two different enum values that are equal usingcovariant enum method, and not equal when compared normally.</p><p>Inspired by <a href="https://www.cs.jhu.edu/~daveho/pubs/oopsla2004.pdf">Finding Bugs is Easy, chapter '4.5 Bad Covariant Definition of Equals (Eq)'</a>:</p><p>Java classes and records may override the <code>equals(Object)</code> method to definea predicate for object equality. This method is used by many of the Java runtimelibrary classes; for example, to implement generic containers.</p><p>Programmers sometimes mistakenly use the type of their class <code>Foo</code>as the type of the parameter to <code>equals()</code>:</p><source><br>public boolean equals(Foo obj) {...}<br> </source><p>This covariant version of <code>equals()</code> does not override the version in the<code>Object</code> class, and it may lead to unexpected behavior at runtime,especially if the class is used with one of the standard collection classeswhich expect that the standard <code>equals(Object)</code> method is overridden.</p><p>This kind of bug is not obvious because it looks correct, and in circumstances wherethe class is accessed through the references of the class type (rather than a supertype),it will work correctly. However, the first time it is used in a container,the behavior might be mysterious. For these reasons, this type of bug can eludetesting and code inspections.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.DeclarationOrderCheck:
Description: |
<p>Checks that the parts of a class, record, or interface declaration appear in the ordersuggested by the<a href="https://checkstyle.org/styleguides/sun-code-conventions-19990420/CodeConventions.doc2.html#a1852">Code Conventions for the Java Programming Language</a>.</p><p>According to <a href="styleguides/sun-code-conventions-19990420/CodeConventions.doc2.html#a1852">Code Conventions for the Java Programming Language</a> , the partsof a class or interface declaration should appear in the followingorder:</p><ol><li>Class (static) variables. First the public class variables, thenprotected, then package level (no access modifier), and thenprivate.</li><li>Instance variables. First the public class variables, thenprotected, then package level (no access modifier), and thenprivate.</li><li> Constructors </li><li> Methods </li></ol><p>Purpose of <b>ignore*</b> option is to ignore related violations,however it still impacts on other class members.</p><p>ATTENTION: the check skips class fields which have<a href="https://docs.oracle.com/javase/specs/jls/se11/html/jls-8.html#jls-8.3.3">forward references</a>from validation due to the fact that we have Checkstyle's limitations to clearlydetect user intention of fields location and grouping. For example:</p><source><br>public class A {<br> private double x = 1.0;<br> private double y = 2.0;<br> public double slope = x / y; // will be skipped from validation due to forward reference<br>}<br> </source><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.DefaultComesLastCheck:
Description: |
<p>Check that the <code>default</code> is after all thecases in a <code>switch</code> statement.</p><p>Rationale: Java allows <code>default</code> anywherewithin the <code>switch</code> statement. But it ismore readable if it comes after the last <code>case</code>.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck:
Description: |
<p>Detects empty statements (standalone <code>";"</code> semicolon).Empty statements often introduce bugs that are hard to spot</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck:
Description: |
<p>Checks that any combination of String literalsis on the left side of an <code>equals()</code> comparison.Also checks for String literals assigned to some field(such as <code>someString.equals(anotherString = "text")</code>).</p><p>Rationale: Calling the <code>equals()</code>method on String literals will avoid a potential<code>NullPointerException</code>. Also, it is pretty common to see nullchecks right before equals comparisons but following this rule such checksare not required.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.EqualsHashCodeCheck:
Description: |
<p>Checks that classes that either override <code>equals()</code>or <code>hashCode()</code> also overrides the other.This check only verifies that the method declarations match<code>Object.equals(Object)</code> and <code>Object.hashCode()</code> exactly to beconsidered an override. This check does not verify invalid method names, parametersother than <code>Object</code>, or anything else.</p><p>Rationale: The contract of <code>equals()</code> and<code>hashCode()</code> requires that equal objectshave the same hashCode. Therefore, whenever you override<code>equals()</code> you must override <code>hashCode()</code>to ensure that your class can be used in hash-based collections.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.ExplicitInitializationCheck:
Description: |
<p>Checks if any class or object member is explicitly initialized todefault for its type value (<code>null</code> forobject references, zero for numeric types and <code>char</code> and <code>false</code> for<code>boolean</code>.</p><p>Rationale: Each instance variable gets initialized twice, to thesame value. Java initializes each instance variable to its default value(<code>0</code> or <code>null</code>) before performing any initialization specified inthe code. So there is a minor inefficiency.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.FallThroughCheck:
Description: |
<p>Checks for fall-through in <code>switch</code>statements. Finds locations where a <code>case</code><b>contains</b> Java code but lacks a <code>break</code>, <code>return</code>,<code>throw</code> or <code>continue</code>statement.</p><p>The check honors special comments to suppress the warning.By default the texts"fallthru", "fall thru", "fall-thru","fallthrough", "fall through", "fall-through""fallsthrough", "falls through", "falls-through" (case sensitive).The comment containing these words must be all on one line,and must be on the last non-empty line before the<code>case</code> triggering the warning or onthe same line before the <code>case</code>(ugly, but possible).</p><p>Note: The check assumes that there is no unreachablecode in the <code>case</code>.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck:
Description: |
<p>Checks that local variables that never have their values changed aredeclared final. The check can be configured to also check thatunchanged parameters are declared final.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.HiddenFieldCheck:
Description: |
<p>Checks that a local variable or a parameter does not shadow a fieldthat is defined in the same class.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.IllegalCatchCheck:
Description: |
<p>Checks that certain exception types do not appear in a <code>catch</code> statement.</p><p>Rationale:catching <code>java.lang.Exception</code>, <code>java.lang.Error</code> or<code>java.lang.RuntimeException</code> is almost never acceptable.Novice developers often simply catch Exception in anattempt to handle multiple exception classes. This unfortunatelyleads to code that inadvertently catches <code>NullPointerException</code>,<code>OutOfMemoryError</code>, etc.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.IllegalInstantiationCheck:
Description: |
<p>Checks for illegal instantiations where a factory method ispreferred.</p><p>Rationale: Depending on the project, for some classes it might bepreferable to create instances through factory methods rather thancalling the constructor.</p><p>A simple example is the <code>java.lang.Boolean</code>class. For performance reasons, it is preferable touse the predefined constants <code> TRUE</code> and<code>FALSE</code>. Constructor invocations should bereplaced by calls to <code>Boolean.valueOf()</code>.</p><p>Some extremely performance sensitive projects may require the use offactory methods for other classes as well, to enforce the usage ofnumber caches or object pools.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.IllegalThrowsCheck:
Description: |
<p>Checks that specified types are not declared to be thrown.Declaring that a method throws <code>java.lang.Error</code> or<code>java.lang.RuntimeException</code> is almost never acceptable.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenCheck:
Description: |
<p>Checks for illegal tokens. By default labels are prohibited.</p><p>Rationale: Certain language features can harm readability, lead toconfusion or are not obvious to novice developers. Other featuresmay be discouraged in certain frameworks, such as not havingnative methods in Enterprise JavaBeans components.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenTextCheck:
Description: |
<p>Checks specified tokens text for matching an illegal pattern.By default no tokens are specified.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck:
Description: |
<p>Checks that particular classes or interfaces are never used.</p><p>Rationale: Helps reduce coupling on concrete classes.</p><p>For additional restriction of type usage see also:<a href="config_coding.html#IllegalInstantiation">IllegalInstantiation</a>,<a href="config_imports.html#IllegalImport">IllegalImport</a></p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.InnerAssignmentCheck:
Description: |
<p>Checks for assignments in subexpressions, such as in<code>String s = Integer.toString(i = 2);</code>.</p><p>Rationale: With the exception of loop idioms,all assignments should occur in their own top-level statementto increase readability. With inner assignments like the one given above, it is difficultto see all places where a variable is set.</p><p>Note: Check allows usage of the popular assignments in loops:</p><source><br>String line;<br>while ((line = bufferedReader.readLine()) != null) { // OK<br> // process the line<br>}<br><br>for (;(line = bufferedReader.readLine()) != null;) { // OK<br> // process the line<br>}<br><br>do {<br> // process the line<br>}<br>while ((line = bufferedReader.readLine()) != null); // OK<br> </source><p>Assignment inside a condition is not a problem here, as the assignment is surrounded byan extra pair of parentheses. The comparison is <code>!= null</code> and there is nochance that intention was to write <code>line == reader.readLine()</code>.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck:
Description: |
<p>Checks that there are no<a href="https://en.wikipedia.org/wiki/Magic_number_%28programming%29">"magic numbers"</a> where a magicnumber is a numeric literal that is not defined as a constant.By default, -1, 0, 1, and 2 are not considered to be magic numbers.</p><p>Constant definition is any variable/field that has 'final' modifier.It is fine to have one constant defining multiple numeric literals within one expression:</p><source><br>static final int SECONDS_PER_DAY = 24 * 60 * 60;<br>static final double SPECIAL_RATIO = 4.0 / 3.0;<br>static final double SPECIAL_SUM = 1 + Math.E;<br>static final double SPECIAL_DIFFERENCE = 4 - Math.PI;<br>static final Border STANDARD_BORDER = BorderFactory.createEmptyBorder(3, 3, 3, 3);<br>static final Integer ANSWER_TO_THE_ULTIMATE_QUESTION_OF_LIFE = new Integer(42);<br> </source><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.MatchXpathCheck:
Description: |
<p>Evaluates Xpath query and report violation on all matching AST nodes. This check allowsuser to implement custom checks using Xpath. If Xpath query is not specified explicitly,then the check does nothing.</p><p>It is recommended to define custom message for violation to explain what is not allowedand what to use instead, default message might be too abstract. To customize a messageyou need to add <code>message</code> element with <b>matchxpath.match</b> as<code>key</code> attribute and desired message as <code>value</code> attribute.</p><p>Please read more about Xpath syntax at<a href="https://www.saxonica.com/html/documentation/expressions/">Xpath Syntax</a>.Information regarding Xpath functions can be found at<a href="https://www.saxonica.com/html/documentation/functions/fn/">XSLT/XPathReference</a>. Note, that <b>@text</b> attribute can used only with token types thatare listed in<a href="https://github.com/checkstyle/checkstyle/search?q=%22TOKEN_TYPES_WITH_TEXT_ATTRIBUTE+%3D+Arrays.asList%22">XpathUtil</a>.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.MissingCtorCheck:
Description: |
<p>Checks that classes (except abstract ones) define a constructor and don'trely on the default one.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.MissingSwitchDefaultCheck:
Description: |
<p>Checks that switch statement has a <code>default</code> clause.</p><p>Rationale: It's usually a good idea to introduce a default case inevery switch statement. Even if the developer is sure that allcurrently possible cases are covered, this should be expressed inthe default branch, e.g. by using an assertion. This way the code isprotected against later changes, e.g. introduction of new types in anenumeration type. Note that the compiler requires switch expressionsto be exhaustive, so this check does not enforce default branches onsuch expressions.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck:
Description: |
<p>Checks that for loop control variables are not modified insidethe for block. An example is:</p><source><br>for (int i = 0; i < 1; i++) {<br> i++; //violation<br>}<br> </source><p>Rationale: If the control variable is modified inside the loopbody, the program flow becomes more difficult to follow. See<a href="https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-14.14">FOR statement</a> specification for more details.</p><p>Such loop would be suppressed:</p><source><br>for (int i = 0; i < 10;) {<br> i++;<br>}<br> </source><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.MultipleStringLiteralsCheck:
Description: |
<p>Checks for multiple occurrences of the same string literal within asingle file.</p><p>Rationale: Code duplication makes maintenance more difficult, so itcan be better to replace the multiple occurrences with a constant.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.MultipleVariableDeclarationsCheck:
Description: |
<p>Checks that each variable declaration is in its own statement and onits own line.</p><p>Rationale: <a href="styleguides/sun-code-conventions-19990420/CodeConventions.doc5.html#a2992">the Java code conventions chapter 6.1</a> recommends thatdeclarations should be one per line/statement.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.NestedForDepthCheck:
Description: |
<p>Restricts nested <code>for</code> blocks to a specified depth.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.NestedIfDepthCheck:
Description: |
<p>Restricts nested if-else blocks to a specified depth.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.NestedTryDepthCheck:
Description: |
<p>Restricts nested try-catch-finally blocks to a specified depth.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.NoArrayTrailingCommaCheck:
Description: |
<p>Checks that array initialization do not contain a trailing comma.Rationale: JLS allows trailing commas in arrays and enumerations, but does not allowthem in other locations. To unify the coding style, the use of trailing commas shouldbe prohibited.</p><source><br>int[] foo = new int[] {<br> 1,<br> 2<br>};<br> </source><p>The check demands that there should not be any comma after the last element of an array.</p><source><br>String[] foo = new String[] {<br> "FOO",<br> "BAR", //violation<br>}<br> </source><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.NoCloneCheck:
Description: |
<p>Checks that the clone method is not overridden from theObject class.</p><p>This check is almost exactly the same as the <code>NoFinalizerCheck</code>.</p><p>See <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#clone()">Object.clone()</a></p><p>Rationale: The clone method relies on strange, hard to follow rules thatare difficult to get right and do not work in all situations.In some cases, either a copy constructoror a static factory method can be used instead of the clone methodto return copies of an object.For more information on rules for the clone method and its issues, see Effective Java:Programming Language Guide First Edition by Joshua Blochpages 45-52.</p><p>Below are some of the rules/reasons why the clone method should be avoided.</p><ul><li>Classes supporting the clone method should implement the Cloneable interfacebut the Cloneable interface does not include the clone method.As a result, it doesn't enforce the method override.</li><li>The Cloneable interface forces the Object's clone method to work correctly.Without implementing it, the Object's clone method will throw aCloneNotSupportedException.</li><li>Non-final classes must return the object returned from a call to super.clone().</li><li>Final classes can use a constructor to create a clone which is differentfrom non-final classes.</li><li>If a super class implements the clone method incorrectly all subclasses callingsuper.clone() are doomed to failure.</li><li>If a class has references to mutable objects then those object references must bereplaced with copies in the clone method after calling super.clone().</li><li>The clone method does not work correctly with final mutable object references becausefinal references cannot be reassigned.</li><li>If a super class overrides the clone method then all subclasses must provide a correctclone implementation.</li></ul><p>Two alternatives to the clone method, in some cases, is a copy constructor or a staticfactory method to return copies of an object. Both of these approaches are simpler anddo not conflict with final fields. They do not force the calling client to handle aCloneNotSupportedException. They also are typed therefore no casting is necessary.Finally, they are more flexible since they can take interface types rather than concreteclasses.</p><p>Sometimes a copy constructor or static factory is not an acceptable alternative to theclone method. The example below highlights the limitation of a copy constructor(or static factory). Assume Square is a subclass for Shape.</p><source><br>Shape s1 = new Square();<br>System.out.println(s1 instanceof Square); //true<br> </source><p>...assume at this point the code knows nothing of s1 being a Square that's the beautyof polymorphism but the code wants to copy the Square which is declared as a Shape,its super type...</p><source><br>Shape s2 = new Shape(s1); //using the copy constructor<br>System.out.println(s2 instanceof Square); //false<br> </source><p>The working solution (without knowing about all subclasses and doing many casts) is to dothe following (assuming correct clone implementation).</p><source><br>Shape s2 = s1.clone();<br>System.out.println(s2 instanceof Square); //true<br> </source><p>Just keep in mind if this type of polymorphic cloning is required then a properlyimplemented clone method may be the best choice.</p><p>Much of this information was taken from Effective Java: Programming Language Guide FirstEdition by Joshua Bloch pages 45-52. Give Bloch credit for writing an excellent book.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.NoEnumTrailingCommaCheck:
Description: |
<p>Checks that enum definition does not contain a trailing comma.Rationale: JLS allows trailing commas in arrays and enumerations, but does not allowthem in other locations. To unify the coding style, the use of trailing commas shouldbe prohibited.</p><source><br>enum Foo1 {<br> FOO,<br> BAR;<br>}<br> </source><p>The check demands that there should not be any comma after last constant inenum definition.</p><source><br>enum Foo1 {<br> FOO,<br> BAR, //violation<br>}<br> </source><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.NoFinalizerCheck:
Description: |
<p>Checks that there is no method <code>finalize</code> with zero parameters.</p><p>See <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#finalize()">Object.finalize()</a></p><p>Rationale: Finalizers are unpredictable, often dangerous, and generally unnecessary.Their use can cause erratic behavior, poor performance, and portability problems.For more information for the finalize method and its issues, see Effective Java:Programming Language Guide Third Edition by Joshua Bloch, §8.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck:
Description: |
<p>Checks that there is only one statement per line.</p><p>Rationale: It's very difficult to read multiple statements on one line.</p><p>In the Java programming language, statements are the fundamental unit ofexecution. All statements except blocks are terminated by a semicolon.Blocks are denoted by open and close curly braces.</p><p>OneStatementPerLineCheck checks the following types of statements:variable declaration statements, empty statements, import statements,assignment statements, expression statements, increment statements,object creation statements, 'for loop' statements, 'break' statements,'continue' statements, 'return' statements, resources statements (optional).</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.OverloadMethodsDeclarationOrderCheck:
Description: |
<p>Checks that overloaded methods are grouped together. Overloaded methods have the samename but different signatures where the signature can differ by the number of inputparameters or type of input parameters or both.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.PackageDeclarationCheck:
Description: |
<p>Ensures that a class has a package declaration, and (optionally) whetherthe package name matches the directory name for the source file.</p><p>Rationale: Classes that live in the null package cannot beimported. Many novice developers are not aware of this.</p><p>Packages provide logical namespace to classes and should be stored inthe form of directory levels to provide physical grouping to your classes.These directories are added to the classpath so that your classesare visible to JVM when it runs the code.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.ParameterAssignmentCheck:
Description: |
<p> Disallows assignment of parameters.</p><p>Rationale: Parameter assignment is often considered poor programmingpractice. Forcing developers to declare parameters as final is oftenonerous. Having a check ensure that parameters are never assignedwould give the best of both worlds.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.RequireThisCheck:
Description: |
<p>Checks that references to instance variables and methods of the presentobject are explicitly of the form "this.varName" or"this.methodName(args)" and that those references don'trely on the default behavior when "this." is absent.</p><p>Warning: the Check is very controversial if 'validateOnlyOverlapping' option is set to'false' and not that actual nowadays.</p><p>Rationale:</p><ol><li>The same notation/habit for C++ and Java (C++ have global methods, so having"this." do make sense in it to distinguish call of method of classinstead of global).</li><li>Non-IDE development (ease of refactoring, some clearness to distinguishstatic and non-static methods).</li></ol><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.ReturnCountCheck:
Description: |
<p>Restricts the number of return statements in methods, constructors and lambda expressions.Ignores specified methods (<code>equals</code> by default).</p><p><b>max</b> property will only check returns in methods and lambdas that return a specificvalue (Ex: 'return 1;').</p><p><b>maxForVoid</b> property will only check returns in methods, constructors, and lambdasthat have no return type (IE 'return;').It will only count visible return statements. Return statements not normally written, butimplied, at the end of the method/constructor definition will not be taken into account.To disallow "return;" in void return type methods, use a value of 0.</p><p>Rationale: Too many return points can mean that code isattempting to do too much or may be difficult to understand.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanExpressionCheck:
Description: |
<p>Checks for over-complicated boolean expressions. Currently findscode like <code> if (b == true)</code>, <code>b || true</code>, <code>!false</code>,etc.</p><p>Rationale: Complex boolean logic makes code hard to understand andmaintain.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanReturnCheck:
Description: |
<p>Checks for over-complicated boolean return statements. For examplethe following code</p><source><br>if (valid())<br> return false;<br>else<br> return true;<br> </source><p>could be written as</p><source><br>return !valid();<br> </source><p>The idea for this Check has been shamelessly stolen from theequivalent <a href="https://pmd.github.io/">PMD</a> rule.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.StringLiteralEqualityCheck:
Description: |
<p>Checks that string literals are not used with <code>==</code> or<code>!=</code>.Since <code>==</code> will compare the object references,not the actual value of the strings,<code>String.equals()</code> should be used.More information can be found<a href="http://www.thejavageek.com/2013/07/27/string-comparison-with-equals-and-assignment-operator/">in this article</a>.</p><p>Rationale: Novice Java programmers often use code like:</p><source><br>if (x == "something")<br> </source><p>when they mean</p><source><br>if ("something".equals(x))<br> </source><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.SuperCloneCheck:
Description: |
<p>Checks that an overriding <code>clone()</code> method invokes<code>super.clone()</code>. Does not check native methods, asthey have no possible java defined implementation.</p><p>Reference: <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#clone%28%29">Object.clone()</a>.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.SuperFinalizeCheck:
Description: |
<p>Checks that an overriding <code>finalize()</code> method invokes<code>super.finalize()</code>. Does not check native methods, asthey have no possible java defined implementation.</p><p>References:<a href="https://www.oracle.com/technical-resources/articles/javase/finalization.html">How to Handle Java Finalization's Memory-Retention Issues</a>;<a href="https://javarevisited.blogspot.com/2012/03/finalize-method-in-java-tutorial.html">10 points on finalize method in Java</a>.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.UnnecessaryParenthesesCheck:
Description: |
<p>Checks if unnecessary parentheses are used in a statement or expression.The check will flag the following with warnings:</p><source><br>return (x); // parens around identifier<br>return (x + 1); // parens around return value<br>int x = (y / 2 + 1); // parens around assignment rhs<br>for (int i = (0); i < 10; i++) { // parens around literal<br>t -= (z + 1); // parens around assignment rhs<br> </source><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonAfterOuterTypeDeclarationCheck:
Description: |
<p>Checks if unnecessary semicolon is used after type declaration.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonAfterTypeMemberDeclarationCheck:
Description: |
<p>Checks if unnecessary semicolon is used after type member declaration.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonInEnumerationCheck:
Description: |
<p>Checks if unnecessary semicolon is in enum definitions.Semicolon is not needed if enum body contains only enum constants.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonInTryWithResourcesCheck:
Description: |
<p>Checks if unnecessary semicolon is used in last resource declaration.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.coding.VariableDeclarationUsageDistanceCheck:
Description: |
<p>Checks the distance between declaration of variable and its first usage.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.coding
com.puppycrawl.tools.checkstyle.checks.design.DesignForExtensionCheck:
Description: |
<p>Checks that classes are designed for extension (subclass creation).</p><p>Nothing wrong could be with founded classes.This check makes sense only for library projects (not application projects)which care of ideal OOP-design to make sure that class works in all cases even misusage.Even in library projects this check most likely will find classes that are designedfor extension by somebody. User needs to use suppressions extensively to got a benefitfrom this check, and keep in suppressions all confirmed/known classes that are deignedfor inheritance intentionally to let the check catch only new classes, and bring this toteam/user attention.</p><p>ATTENTION: Only user can decide whether a class is designed for extension or not.The check just shows all classes which are possibly designed for extension.If smth inappropriate is found please use suppression.</p><p>ATTENTION: If the method which can be overridden in a subclass has a javadoc comment(a good practice is to explain its self-use of overridable methods) the check will notrise a violation. The violation can also be skipped if the method which can be overriddenin a subclass has one or more annotations that are specified in ignoredAnnotationsoption. Note, that by default @Override annotation is not included in theignoredAnnotations set as in a subclass the method which has the annotation can also beoverridden in its subclass.</p><p>Problem is described at "Effective Java, 2nd Edition by Joshua Bloch" book, chapter"Item 17: Design and document for inheritance or else prohibit it".</p><p>Some quotes from book:</p><blockquote>The class must document its self-use of overridable methods.By convention, a method that invokes overridable methods contains a descriptionof these invocations at the end of its documentation comment. The descriptionbegins with the phrase “This implementation.”</blockquote><blockquote>The best solution to this problem is to prohibit subclassing in classes thatare not designed and documented to be safely subclassed.</blockquote><blockquote>If a concrete class does not implement a standard interface, then you mayinconvenience some programmers by prohibiting inheritance. If you feel that youmust allow inheritance from such a class, one reasonable approach is to ensurethat the class never invokes any of its overridable methods and to document thisfact. In other words, eliminate the class’s self-use of overridable methods entirely.In doing so, you’ll create a class that is reasonably safe to subclass. Overriding amethod will never affect the behavior of any other method.</blockquote><p>The check finds classes that have overridable methods (public or protected methodsthat are non-static, not-final, non-abstract) and have non-empty implementation.</p><p>Rationale: This library design style protects superclasses againstbeing broken by subclasses. The downside is that subclasses arelimited in their flexibility, in particular they cannot preventexecution of code in the superclass, but that also means thatsubclasses cannot corrupt the state of the superclass by forgettingto call the superclass's method.</p><p>More specifically,it enforces a programming style where superclasses provide empty"hooks" that can be implemented by subclasses.</p><p>Example of code that cause violation as it is designed for extension:</p><source><br>public abstract class Plant {<br> private String roots;<br> private String trunk;<br><br> protected void validate() {<br> if (roots == null) throw new IllegalArgumentException("No roots!");<br> if (trunk == null) throw new IllegalArgumentException("No trunk!");<br> }<br><br> public abstract void grow();<br>}<br><br>public class Tree extends Plant {<br> private List leaves;<br><br> @Overrides<br> protected void validate() {<br> super.validate();<br> if (leaves == null) throw new IllegalArgumentException("No leaves!");<br> }<br><br> public void grow() {<br> validate();<br> }<br>}<br> </source><p>Example of code without violation:</p><source><br>public abstract class Plant {<br> private String roots;<br> private String trunk;<br><br> private void validate() {<br> if (roots == null) throw new IllegalArgumentException("No roots!");<br> if (trunk == null) throw new IllegalArgumentException("No trunk!");<br> validateEx();<br> }<br><br> protected void validateEx() { }<br><br> public abstract void grow();<br>}<br> </source><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.design
com.puppycrawl.tools.checkstyle.checks.design.FinalClassCheck:
Description: |
<p>Checks that a class which has only private constructors is declaredas final. Doesn't check for classes nested in interfacesor annotations, as they are always <code>final</code> there.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.design
com.puppycrawl.tools.checkstyle.checks.design.HideUtilityClassConstructorCheck:
Description: |
<p>Makes sure that utility classes (classes that contain only staticmethods or fields in their API) do not have a public constructor.</p><p>Rationale: Instantiating utility classes does not make sense. Hencethe constructors should either be private or (if you want to allowsubclassing) protected. A common mistake is forgetting to hide thedefault constructor.</p><p>If you make the constructor protected you may want to consider thefollowing constructor implementation technique to disallowinstantiating subclasses:</p><source><br>public class StringUtils // not final to allow subclassing<br>{<br> protected StringUtils() {<br> // prevents calls from subclass<br> throw new UnsupportedOperationException();<br> }<br><br> public static int count(char c, String s) {<br> // ...<br> }<br>}<br> </source><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.design
com.puppycrawl.tools.checkstyle.checks.design.InnerTypeLastCheck:
Description: |
<p>Checks nested (internal) classes/interfaces are declared at the bottom of theprimary (top-level) class after all init and static init blocks,method, constructor and field declarations.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.design
com.puppycrawl.tools.checkstyle.checks.design.InterfaceIsTypeCheck:
Description: |
<p>Implements Joshua Bloch, Effective Java, Item 17 - Use Interfaces only todefine types.</p><p>According to Bloch, an interface should describe a <em>type</em>.It is therefore inappropriate to define an interface that does notcontain any methods but only constants. The Standard interface <a href="https://docs.oracle.com/javase/8/docs/api/javax/swing/SwingConstants.html">javax.swing.SwingConstants</a>is an example of an interface that would be flagged by this check.</p><p>The check can be configured to also disallow marker interfaces like<code>java.io.Serializable</code>, that do not contain methods orconstants at all.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.design
com.puppycrawl.tools.checkstyle.checks.design.MutableExceptionCheck:
Description: |
<p>Ensures that exception classes (classes with names conforming to some regularexpression and explicitly extending classes with names conforming to otherregular expression) are immutable, that is, that they have only final fields.</p><p>The current algorithm is very simple: it checks that all members ofexception are final. The user can still mutate an exception's instance(e.g. Throwable has a method called <code>setStackTrace</code>which changes the exception's stack trace). But, at least, all informationprovided by this exception type is unchangeable.</p><p>Rationale: Exception instances should represent an errorcondition. Having non final fields not only allows the state to bemodified by accident and therefore mask the original condition butalso allows developers to accidentally forget to set the initial state.In both cases, code catching the exception could draw incorrectconclusions based on the state.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.design
com.puppycrawl.tools.checkstyle.checks.design.OneTopLevelClassCheck:
Description: |
<p>Checks that each top-level class, interface, enumor annotation resides in a source file of its own.Official description of a 'top-level' term:<a href="https://docs.oracle.com/javase/specs/jls/se11/html/jls-7.html#jls-7.6">7.6. Top Level Type Declarations</a>.If file doesn't contains public class, interface, enum or annotation,top-level type is the first type in file.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.design
com.puppycrawl.tools.checkstyle.checks.design.ThrowsCountCheck:
Description: |
<p>Restricts throws statements to a specified count.Methods with "Override" or "java.lang.Override" annotation are skippedfrom validation as current class cannot change signature of these methods.</p><p>Rationale: Exceptions form part of a method's interface. Declaring amethod to throw too many differently rooted exceptions makesexception handling onerous and leads to poor programming practicessuch as writing code like <code>catch(Exception ex)</code>.4 is the empirical value which is based on reports that we had forthe ThrowsCountCheck over big projects such as OpenJDK.This check also forces developers to put exceptions into a hierarchysuch that in the simplest case, only one type of exception need bechecked for by a caller but any subclasses can be caught specificallyif necessary. For more information on rules for the exceptions andtheir issues, see Effective Java: Programming Language GuideSecond Edition by Joshua Bloch pages 264-273.</p><p><b>ignorePrivateMethods</b> - allows to skip private methods as they donot cause problems for other classes.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.design
com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheck:
Description: |
<p>Checks visibility of class members. Only static final, immutable or annotatedby specified annotation members may be public; other class members must be privateunless the property <code>protectedAllowed</code> or <code>packageAllowed</code> is set.</p><p>Public members are not flagged if the name matches the publicmember regular expression (contains <code>"^serialVersionUID$"</code> by default).</p><p>Note thatCheckstyle 2 used to include <code>"^f[A-Z][a-zA-Z0-9]*$"</code> in the defaultpattern to allow names used in container-managed persistence for Enterprise JavaBeans(EJB) 1.1 with the default settings. With EJB 2.0 it is no longer necessary to havepublic access for persistent fields, so the default has been changed.</p><p>Rationale: Enforce encapsulation.</p><p>Check also has options making it less strict:</p><p><b>ignoreAnnotationCanonicalNames</b> - the list of annotations which ignore variablesin consideration. If user will provide short annotation name that type will match to anynamed the same type without consideration of package.</p><p><b>allowPublicFinalFields</b> - which allows public final fields.</p><p><b>allowPublicImmutableFields</b> - which allows immutable fields to be declared aspublic if defined in final class.</p><p>Field is known to be immutable if:</p><ul><li>It's declared as final</li><li>Has either a primitive type or instance of class user defined to be immutable(such as String, ImmutableCollection from Guava and etc)</li></ul><p>Classes known to be immutable are listed in <b>immutableClassCanonicalNames</b> by theircanonical names.</p><p>Property Rationale: Forcing all fields of class to have private modifier by default isgood in most cases, but in some cases it drawbacks in too much boilerplate get/set code.One of such cases are immutable classes.</p><p>Restriction: Check doesn't check if class is immutable, there's nochecking if accessory methods are missing and all fields are immutable, we only checkif current field is immutable or final. Under the flag<b>allowPublicImmutableFields</b>, the enclosing class must also be final, to encourageimmutability. Under the flag <b>allowPublicFinalFields</b>, the final modifier onthe enclosing class is optional.</p><p>Star imports are out of scope of this Check. So if one of type imported viastar import collides with user specified one by its short name -there won't be Check's violation.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.design
com.puppycrawl.tools.checkstyle.filefilters.BeforeExecutionExclusionFileFilterCheck:
Description: |
<p>File filter <code>BeforeExecutionExclusionFileFilter</code> decides which files should beexcluded from being processed by the utility.</p><p>By default Checkstyle includes all files and sub-directories in a directory to beprocessed and checked for violations. Users could have files that are in thesesub-directories that shouldn't be processed with their checkstyle configuration forvarious reasons, one of which is a valid Java file that won't pass Checkstyle's parser.When Checkstyle tries to parse a Java file and fails, it will throw an<code>Exception</code> and halt parsing any more files for violations. An example of avalid Java file Checkstyle can't parse is JDK 9's <code>module-info.java</code>.This file filter will exclude these problem files from being parsed,allowing the rest of the files to run normal and be validated.</p><p><b>Note:</b> When a file is excluded from the utility, it is excluded from all Checks andno testing for violations will be performed on them.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.filefilters
com.puppycrawl.tools.checkstyle.filters.SeverityMatchFilterCheck:
Description: |
<p>Filter <code>SeverityMatchFilter</code> decidesaudit events according to the <a href="config.html#Severity">severitylevel</a> of the event.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.filters
com.puppycrawl.tools.checkstyle.filters.SuppressionCommentFilterCheck:
Description: |
<p>Filter <code>SuppressionCommentFilter</code> usespairs of comments to suppress audit events.</p><p>Rationale: Sometimes there are legitimate reasons for violatinga check. When this is a matter of the code in question and notpersonal preference, the best place to override the policy is inthe code itself. Semi-structured comments can be associatedwith the check. This is sometimes superior to a separatesuppressions file, which must be kept up-to-date as the sourcefile is edited.</p><p>Note that the suppression comment should be put before the violation. You can use morethan one suppression comment each on separate line.</p><p>Attention: This filter may only be specified within the TreeWalker module(<code><module name="TreeWalker"/></code>) and onlyapplies to checks which are also defined within this module.To filter non-TreeWalker checks like <code>RegexpSingleline</code>,a <a href="config_filters.html#SuppressWithPlainTextCommentFilter">SuppressWithPlainTextCommentFilter</a> or similar filter must be used.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.filters
com.puppycrawl.tools.checkstyle.filters.SuppressionFilterCheck:
Description: |
<p>Filter <code>SuppressionFilter</code> rejectsaudit events for Check violations according toa <a href="/dtds/suppressions_1_2.dtd">suppressions XMLdocument</a> in a file. If there is no configuredsuppressions file or the optional is set to true andsuppressions file was not found the Filter accepts all audit events.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.filters
com.puppycrawl.tools.checkstyle.filters.SuppressionSingleFilterCheck:
Description: |
<p>Filter <code>SuppressionSingleFilter</code> suppresses audit events forChecks violations in the specified file, class, checks, message, module id,lines, and columns.</p><p>Rationale: To allow users use suppressions configured in the same config withother modules. SuppressionFilter and SuppressionXpathFilter are require separatefile.</p><p>Advice: If checkstyle configuration is used for several projects, single suppressionson common files/folders is better to put in checkstyle configuration as common rule.All suppression that are for specific file names is better to keep in project specificconfig file.</p><p>Attention: This filter only supports single suppression, and will needmultiple instances if users wants to suppress multiple violations.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.filters
com.puppycrawl.tools.checkstyle.filters.SuppressionXpathFilterCheck:
Description: |
<p>Filter <code>SuppressionXpathFilter</code> works as<a href="config_filters.html#SuppressionFilter">SuppressionFilter</a>.Additionally, filter processes <code>suppress-xpath</code> elements,which contains xpath-expressions. Xpath-expressionsare queries for suppressed nodes inside the AST tree.</p><p>Currently, filter does not support the following checks:</p><ul id="SuppressionXpathFilter_IncompatibleChecks"><li>NoCodeInFile (reason is that AST is not generated for a file not containing code)</li><li>Regexp (reason is at <a href="https://github.com/checkstyle/checkstyle/issues/7759#issuecomment-605525287"> #7759</a>)</li><li>RegexpSinglelineJava (reason is at <a href="https://github.com/checkstyle/checkstyle/issues/7759#issuecomment-605525287"> #7759</a>)</li></ul><p>Also, the filter does not support suppressions inside javadoc reported by Javadoc checks:</p><ul id="SuppressionXpathFilter_JavadocChecks"><li>AtclauseOrder</li><li>JavadocBlockTagLocation</li><li>JavadocMethod</li><li>JavadocMissingLeadingAsterisk</li><li>JavadocMissingWhitespaceAfterAsterisk</li><li>JavadocParagraph</li><li>JavadocStyle</li><li>JavadocTagContinuationIndentation</li><li>JavadocType</li><li>MissingDeprecated</li><li>NonEmptyAtclauseDescription</li><li>RequireEmptyLineBeforeBlockTagGroup</li><li>SingleLineJavadoc</li><li>SummaryJavadoc</li><li>WriteTag</li></ul><p>Note, that support for these Checks will be available after resolving issues<a href="https://github.com/checkstyle/checkstyle/issues/5770">#5770</a> and<a href="https://github.com/checkstyle/checkstyle/issues/5777">#5777</a>.</p><p>Currently, filter supports the followingxpath axes:</p><ul><li>ancestor</li><li>ancestor-or-self</li><li>attribute</li><li>child</li><li>descendant</li><li>descendant-or-self</li><li>following</li><li>following-sibling</li><li>parent</li><li>preceding</li><li>preceding-sibling</li><li>self</li></ul><p>You can use the command line helper tool to generate xpathsuppressions based on your configuration file and input files.See<a href="cmdline.html">here</a>for more details.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.filters
com.puppycrawl.tools.checkstyle.filters.SuppressionXpathSingleFilterCheck:
Description: |
<p>Filter <code>SuppressionXpathSingleFilter</code> suppresses audit events forChecks violations in the specified file, class, checks, message, module id,and xpath.</p><p>Rationale: To allow users use suppressions configured in the same config withother modules. SuppressionFilter and SuppressionXpathFilter are require separatefile.</p><p>Advice: If checkstyle configuration is used for several projects, single suppressionson common files/folders is better to put in checkstyle configuration as common rule.All suppression that are for specific file names is better to keep in project specificconfig file.</p><p>Attention: This filter only supports single suppression, and will needmultiple instances if users wants to suppress multiple violations.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.filters
com.puppycrawl.tools.checkstyle.filters.SuppressWarningsFilterCheck:
Description: |
<p>Filter <code>SuppressWarningsFilter</code> uses annotation{@code SuppressWarnings} to suppress audit events.</p><p>Rationale: Same as for<code>SuppressionCommentFilter</code>. In the contrary to ithere, comments are not used comments but the builtin syntax of<code>@SuppressWarnings</code>. This can be perceived as amore elegant solution than using comments. Also this approachmaybe supported by various IDE.</p><p>Usage: This filter only works in conjunction with a<a href="config_annotation.html#SuppressWarningsHolder">SuppressWarningsHolder</a>,since that check findsthe annotations in the Java files and makes them available forthe filter. Because of that, a configuration that includesthis filter must also include<code>SuppressWarningsHolder</code> as a child module of the<code>TreeWalker</code>. Name of check in annotation is case-insensitiveand should be written with any dotted prefix or "Check" suffix removed.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.filters
com.puppycrawl.tools.checkstyle.filters.SuppressWithNearbyCommentFilterCheck:
Description: |
<p>Filter <code>SuppressWithNearbyCommentFilter</code> usesnearby comments to suppress audit events.</p><p>Rationale: Same as <code>SuppressionCommentFilter</code>.Whereas the SuppressionCommentFilter uses matched pairs offilters to turn on/off comment matching,<code>SuppressWithNearbyCommentFilter</code> usessingle comments. This requires fewer lines to mark a region, andmay be aesthetically preferable in some contexts.</p><p>Attention: This filter may only be specified within the TreeWalker module(<code><module name="TreeWalker"/></code>) and onlyapplies to checks which are also defined within this module.To filter non-TreeWalker checks like <code>RegexpSingleline</code>,a <a href="config_filters.html#SuppressWithPlainTextCommentFilter">SuppressWithPlainTextCommentFilter</a> or similar filter must be used.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.filters
com.puppycrawl.tools.checkstyle.filters.SuppressWithPlainTextCommentFilterCheck:
Description: |
<p>Filter <code>SuppressWithPlainTextCommentFilter</code> uses plain text to suppressaudit events. The filter can be used only to suppress audit events received fromthe checks which implement FileSetCheck interface. In other words, the checkswhich have Checker as a parent module. The filter knows nothing about AST,it treats only plain text comments and extracts the information requiredfor suppression from the plain text comments. Currently the filter supportsonly single line comments.</p><p>Please, be aware of the fact that, it is not recommended to use the filterfor Java code anymore, however you still are able to use it to suppress auditevents received from the checks which implement FileSetCheck interface.</p><p>Rationale: Sometimes there are legitimate reasons for violatinga check. When this is a matter of the code in question and notpersonal preference, the best place to override the policy is inthe code itself. Semi-structured comments can be associatedwith the check. This is sometimes superior to a separatesuppressions file, which must be kept up-to-date as the sourcefile is edited.</p><p>Note that the suppression comment should be put before the violation.You can use more than one suppression comment each on separate line.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.filters
com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck:
Description: |
<p>Checks that a source file begins with a specified header. Property<code>headerFile</code> specifies a file that containsthe required header. Alternatively, the header specification can beset directly in the <code>header</code> propertywithout the need for an external file.</p><p>Property <code>ignoreLines</code> specifies the linenumbers to ignore when matching lines in a header file. Thisproperty is very useful for supporting headers that containcopyright dates. For example, consider the following header:</p><source><br>line 1: ////////////////////////////////////////////////////////////////////<br>line 2: // checkstyle:<br>line 3: // Checks Java source code for adherence to a set of rules.<br>line 4: // Copyright (C) 2002 Oliver Burn<br>line 5: ////////////////////////////////////////////////////////////////////<br> </source><p>Since the year information will change over time, you can tellCheckstyle to ignore line 4 by setting property <code>ignoreLines</code> to<code>4</code>.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.header
com.puppycrawl.tools.checkstyle.checks.header.RegexpHeaderCheck:
Description: |
<p>Checks the header of a source file against a header that contains a<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/regex/Pattern.html">regular expression</a> for each line of the source header.</p><p>Rationale: In some projects <a href="config_header.html#Header">checking against afixed header</a> is not sufficient, e.g. the header might require acopyright line where the year information is not static.</p><p>For example, consider the following header:</p><source><br>line 1: ^/{71}$<br>line 2: ^// checkstyle:$<br>line 3: ^// Checks Java source code for adherence to a set of rules\.$<br>line 4: ^// Copyright \(C\) \d\d\d\d Oliver Burn$<br>line 5: ^// Last modification by \$Author.*\$$<br>line 6: ^/{71}$<br>line 7:<br>line 8: ^package<br>line 9:<br>line 10: ^import<br>line 11:<br>line 12: ^/\*\*<br>line 13: ^ \*([^/]|$)<br>line 14: ^ \*/<br> </source><p>Lines 1 and 6 demonstrate a more compact notation for 71 '/'characters. Line 4 enforces that the copyright notice includes afour digit year. Line 5 is an example how to enforce revisioncontrol keywords in a file header. Lines 12-14 is a template forjavadoc (line 13 is so complicated to remove conflict with and ofjavadoc comment). Lines 7, 9 and 11 will be treated as '^$' andwill forcefully expect the line to be empty.</p><p>Different programming languages have different comment syntaxrules, but all of them start a comment with a non-wordcharacter. Hence you can often use the non-word characterclass to abstract away the concrete comment syntax and allowchecking the header for different languages with a singleheader definition. For example, consider the following headerspecification (note that this is not the full Apache licenseheader):</p><source><br>line 1: ^#!<br>line 2: ^<\?xml.*>$<br>line 3: ^\W*$<br>line 4: ^\W*Copyright 2006 The Apache Software Foundation or its licensors, as applicable\.$<br>line 5: ^\W*Licensed under the Apache License, Version 2\.0 \(the "License"\);$<br>line 6: ^\W*$<br> </source><p>Lines 1 and 2 leave room for technical header lines, e.g. the"#!/bin/sh" line in Unix shell scripts, or the XML file headerof XML files. Set the multiline property to "1, 2" so theselines can be ignored for file types where they do no apply.Lines 3 through 6 define the actual header content. Note howlines 2, 4 and 5 use escapes for characters that have specialregexp semantics.</p><p>In default configuration, if header is not specified, the default valueof header is set to null and the check does not rise any violations.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.header
com.puppycrawl.tools.checkstyle.checks.imports.AvoidStarImportCheck:
Description: |
<p>Checks that there are no import statements that use the <code>*</code> notation.</p><p>Rationale: Importing all classes from a package or staticmembers from a class leads to tight coupling between packagesor classes and might lead to problems when a new version of alibrary introduces name clashes.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.imports
com.puppycrawl.tools.checkstyle.checks.imports.AvoidStaticImportCheck:
Description: |
<p>Checks that there are no static import statements.</p><p>Rationale: Importing static members can lead to namingconflicts between class' members. It may lead to poor codereadability since it may no longer be clear what class amember resides in (without looking at the import statement).</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.imports
com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck:
Description: |
<p>Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.imports
com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck:
Description: |
<p>Checks for imports from a set of illegal packages.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.imports
com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck:
Description: |
<p>Controls what can be imported in each package and file. Useful forensuring that application layering rules are not violated,especially on large projects.</p><p>You can control imports based on the a package name or based on the filename. When controlling packages, all files and sub-packages in the declaredpackage will be controlled by this check. To specify differences between a main packageand a sub-package, you must define the sub-package inside the main package. Whencontrolling file, only the file name is considered and only files processed by<a href="config.html#TreeWalker">TreeWalker</a>. The file's extension is ignored.</p><p>Short description of the behaviour:</p><ul><li>Check starts checking from the longest matching subpackage (later 'currentsubpackage') or the first file name match described inside importcontrol file to package defined in class file.<ul><li>The longest matching subpackage is found by starting with the root packageand examining if the any of the sub-packages or file definitions match thecurrent class' package or file name.</li><li>If a file name is matched first, that is considered the longestmatch and becomes the current file/subpackage.</li><li>If another subpackage is matched, then it's subpackages and filenames are examined for the next longest match and the process repeatsrecursively.</li><li>If no subpackages or file names are matched, the current subpackageis then used.</li></ul></li><li>Order of rules in the same subpackage/root are defined by the order ofdeclaration in the XML file, which is from top (first) to bottom (last).</li><li>If there is matching allow/disallow rule inside the current file/subpackagethen the Check returns the first "allowed" or "disallowed" message.</li><li>If there is no matching allow/disallow rule inside the current file/subpackagethen it continues checking in the parent subpackage.</li><li>If there is no matching allow/disallow rule in any of the files/subpackages,including the root level (import-control), then the import is disallowed by default.</li></ul><p>The DTD for a import control XML document is at <a href="/dtds/import_control_1_4.dtd">https://checkstyle.org/dtds/import_control_1_4.dtd</a>. Itcontains documentation on each of the elements and attributes.</p><p>The check validates a XML document when it loads the document.To validate against the above DTD, include the followingdocument type declaration in your XML document:</p><div class="wrapper"><pre><!DOCTYPE import-control PUBLIC"-//Checkstyle//DTD ImportControl Configuration 1.4//EN""https://checkstyle.org/dtds/import_control_1_4.dtd"></pre></div><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.imports
com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck:
Description: |
<p>Checks the ordering/grouping of imports. Features are:</p><ul><li>groups type/static imports: ensures that groups of imports come in aspecific order (e.g., java. comes first, javax. comes second,then everything else)</li><li>adds a separation between type import groups : ensures that a blankline sit between each group</li><li>type/static import groups aren't separated internally: ensures thateach group aren't separated internally by blank line or comment</li><li>sorts type/static imports inside each group: ensures that importswithin each group are in lexicographic order</li><li>sorts according to case: ensures that the comparisonbetween imports is case sensitive, in<a href="https://en.wikipedia.org/wiki/ASCII#Order">ASCII sort order</a></li><li>arrange static imports: ensures the relative order betweentype imports and static imports (see<a href="property_types.html#ImportOrderOption">ImportOrderOption</a>)</li></ul><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.imports
com.puppycrawl.tools.checkstyle.checks.imports.RedundantImportCheck:
Description: |
<p>Checks for redundant import statements. An import statement isconsidered redundant if:</p><ul><li>It is a duplicate of another import. This is, when a class isimported more than once.</li><li>The class non-statically imported is from the <code>java.lang</code>package, e.g. importing <code>java.lang.String</code>.</li><li>The class non-statically imported is from the same package as the current package.</li></ul><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.imports
com.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck:
Description: |
<p>Checks for unused import statements. Checkstyle uses a simple butvery reliable algorithm to report on unused import statements. Animport statement is considered unused if:</p><ul><li>It is not referenced in the file. The algorithm does not supportwild-card imports like <code>importjava.io.*;</code>. Most IDE's provide very sophisticated checksfor imports that handle wild-card imports.</li><li>It is a duplicate of another import. This is when a class isimported more than once.</li><li>The class imported is from the <code>java.lang</code>package. For example importing <code>java.lang.String</code>.</li><li>The class imported is from the same package.</li><li><b>Optionally:</b> it is referenced in Javadoc comments. This checkis on by default, but it is considered bad practice to introducea compile time dependency for documentation purposes only.As an example, the import <code>java.util.List</code> would beconsidered referenced with the Javadoc comment<code>{@link List}</code>. The alternative to avoid introducing acompile time dependency would be to write the Javadoc comment as<code>{@link java.util.List}</code>.</li></ul><p>The main limitation of this check is handling the case wherean imported type has the same name as a declaration, such as amember variable.</p><p>For example, in the following case the import <code>java.awt.Component</code>will not be flagged as unused:</p><source><br>import java.awt.Component;<br>class FooBar {<br> private Object Component; // a bad practice in my opinion<br> ...<br>}<br> </source><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.imports
com.puppycrawl.tools.checkstyle.checks.javadoc.AtclauseOrderCheck:
Description: |
<p>Checks the order of<a href="https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html#CHDBEFIF">javadoc block-tags or javadoc tags</a>.</p><p>Note: Google used the term "at-clauses" for block tags in their guide till 2017-02-28.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.InvalidJavadocPositionCheck:
Description: |
<p>Checks that Javadocs are located at the correct position.As specified at <a href="https://docs.oracle.com/en/java/javase/11/docs/specs/doc-comment-spec.html">Documentation Comment Specification for the Standard Doclet</a>,Javadocs are recognized only when placed immediately before module, package, class,interface, constructor, method, or field declarations. Any other position, likein the body of a method, will be ignored by the javadoc tool and is consideredinvalid by this check.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocBlockTagLocationCheck:
Description: |
<p>Checks that a<a href="https://docs.oracle.com/en/java/javase/11/docs/specs/doc-comment-spec.html#block-tags">javadoc block tag</a> appears only at the beginning of a line, ignoringleading asterisks and white space. A block tag is a token that startswith <code>@</code> symbol and is preceded by a whitespace. This checkignores block tags in comments and inside inline tags {@code } and{@literal }.</p><p>Rationale: according to<a href="https://docs.oracle.com/en/java/javase/11/docs/specs/doc-comment-spec.html#block-tags">the specification</a> all javadoc block tags should be placed at thebeginning of a line. Tags that are not placed at the beginning are treatedas plain text. To recognize intentional tag placement to text areait is better to escape the <code>@</code> symbol, and all non-escapedtags should be located at the beginning of the line. See NOTE sectionfor details on how to escape.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocContentLocationCheck:
Description: |
<p>Checks that the Javadoc content begins from the same positionfor all Javadoc comments in the project. Any leading asterisks and spacesare not counted as the beginning of the content and are therefore ignored.</p><p>It is possible to enforce two different styles:</p><ul><li>{@code first_line} - Javadoc content starts from the first line:<source>/** Summary text.* More details.*/public void method();</source></li><li>{@code second_line} - Javadoc content starts from the second line:<source>/*** Summary text.* More details.*/public void method();</source></li></ul><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck:
Description: |
<p>Checks the Javadoc of a method or constructor. The scopeto verify is specified using the <code>Scope</code> class anddefaults to <code>Scope.PRIVATE</code>. To verify anotherscope, set property scope to a different<a href="property_types.html#Scope">scope</a>.</p><p>Violates parameters and type parametersfor which no param tags arepresent can be suppressed by defining property<code>allowMissingParamTags</code>.</p><p>Violates methods which return non-void but for which no return tag ispresent can be suppressed by defining property<code>allowMissingReturnTag</code>.</p><p>Violates exceptions which are declared to be thrown (by <code>throws</code> in the methodsignature or by <code>throw new</code> in the method body), but for which no throws tag ispresent by activation of property <code>validateThrows</code>.Note that <code>throw new</code> is not checked in the following places:</p><ul><li>Inside a try block (with catch). It is not possible to determine if the thrownexception can be caught by the catch block as there is no knowledge of theinheritance hierarchy, so the try block is ignored entirely. However, catchand finally blocks, as well as try blocks without catch, are still checked.</li><li>Local classes, anonymous classes and lambda expressions. It is not known when thethrow statements inside such classes are going to be evaluated, so they are ignored.</li></ul><p>ATTENTION: Checkstyle does not have information about hierarchy of exception typesso usage of base class is considered as separate exception type.As workaround you need to specify both types in javadoc (parent and exact type).</p><p>Javadoc is not required on a method that is tagged with the<code>@Override</code> annotation. However underJava 5 it is not possible to mark a method required for aninterface (this was <i>corrected</i> under Java 6). HenceCheckstyle supports using the convention of using a single<code>{@inheritDoc}</code> tag instead of all theother tags.</p><p>Note that only inheritable items will allow the<code>{@inheritDoc}</code> tag to be used in placeof comments. Static methods at all visibilities, private non-staticmethods and constructors are not inheritable.</p><p>For example, if the following method isimplementing a method required by an interface, then theJavadoc could be done as:</p><source><br>/** {@inheritDoc} */<br>public int checkReturnTag(final int aTagIndex,<br> JavadocTag[] aTags,<br> int aLineNo)<br> </source><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck:
Description: |
<p>Checks if the javadoc has<a href="https://docs.oracle.com/en/java/javase/14/docs/specs/javadoc/doc-comment-spec.html#leading-asterisks">leading asterisks</a>on each line.</p><p>The check does not require asterisks on the first line, nor on the last lineif it is blank. All other lines in a Javadoc should start with <code>*</code>,including blank lines and code blocks.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck:
Description: |
<p>Checks that there is at least one whitespace after the leading asterisk.Although spaces after asterisks are optional in the Javadoc comments, their absencemakes the documentation difficult to read. It is the de facto standard to put at leastone whitespace after the leading asterisk.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck:
Description: |
<p>Checks that each Java package has a Javadoc file used forcommenting. By default it only allows a <code>package-info.java</code> file, but can beconfigured to allow a <code>package.html</code>file.</p><p>A violation will be reported if both files exist as this is notallowed by the Javadoc tool.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocParagraphCheck:
Description: |
<p>Checks the Javadoc paragraph.</p><p>Checks that:</p><ul><li>There is one blank line between each of two paragraphs.</li><li>Each paragraph but the first has <p> immediately before the first word, withno space after.</li></ul><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck:
Description: |
<p>Validates Javadoc comments to help ensure they are well formed.</p><p>The following checks are performed:</p><ul><li>Ensures the first sentence ends with proper punctuation(That is a period, question mark, or exclamation mark, by default).Javadoc automatically places the first sentence in themethod summary table and index. Without proper punctuationthe Javadoc may be malformed. All items eligible for the<code>{@inheritDoc}</code> tag are exempt from thisrequirement.</li><li>Check text for Javadoc statements that do not have anydescription. This includes both completely empty Javadoc,and Javadoc with only tags such as <code>@param</code> and <code>@return</code>.</li><li>Check text for incomplete HTML tags. Verifies that HTMLtags have corresponding end tags and issues an "UnclosedHTML tag found:" error if not. An "Extra HTML tag found:"error is issued if an end tag is found without a previousopen tag.</li><li>Check that a package Javadoc comment is well-formed (asdescribed above) and NOT missing from any package-info.java files.</li><li>Check for allowed HTML tags. The list of allowed HTML tagsis "a", "abbr", "acronym", "address", "area", "b", "bdo", "big","blockquote", "br", "caption", "cite", "code", "colgroup", "dd","del", "dfn", "div", "dl", "dt", "em", "fieldset", "font", "h1","h2", "h3", "h4", "h5", "h6", "hr", "i", "img", "ins", "kbd", "li","ol", "p", "pre", "q", "samp", "small", "span", "strong", "sub","sup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "tt","u", "ul", "var".</li></ul><p>These checks were patterned after the checks made by the <a href="http://maven-doccheck.sourceforge.net/">DocCheck</a>doclet available from Sun. Note: Original Sun's DocCheck tool does not exist anymore.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTagContinuationIndentationCheck:
Description: |
<p>Checks the indentation of the continuation lines in block tags.That is whether thecontinued description of at clauses should be indented or not. If the text is not properlyindented it throws a violation. A continuation line is when the description starts/spanspast the line with the tag. Default indentation required is at least 4, but this can bechanged with the help of properties below.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck:
Description: |
<p>Checks the Javadoc comments for type definitions.By default, does not check for author or version tags. Thescope to verify is specified using the <code>Scope</code>class and defaults to <code>Scope.PRIVATE</code>. To verifyanother scope, set property scope to one of the<code>Scope</code> constants. To define the format for anauthor tag or a version tag, set property authorFormat orversionFormat respectively to a<a href="https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html">regular expression</a>.</p><p>Does not perform checks for author and version tags for innerclasses, as they should be redundant because of outer class.</p><p>Error messages about type parameters and record components for which noparam tags are present can be suppressed by defining property<code>allowMissingParamTags</code>.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocVariableCheck:
Description: |
<p>Checks that a variable has a Javadoc comment. Ignores <code>serialVersionUID</code>fields.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck:
Description: |
<p>Checks for missing Javadoc comments for a method or constructor.The scope to verify is specified using the <code>Scope</code> class anddefaults to <code>Scope.PUBLIC</code>. To verify anotherscope, set property scope to a different<a href="property_types.html#Scope">scope</a>.</p><p>Javadoc is not required on a method that is tagged with the<code>@Override</code> annotation. However underJava 5 it is not possible to mark a method required for aninterface (this was <i>corrected</i> under Java 6). HenceCheckstyle supports using the convention of using a single<code>{@inheritDoc}</code> tag instead of all theother tags.</p><p>For getters and setters for the property <code>allowMissingPropertyJavadoc</code>,the methods must match exactly the structures below.</p><div class="wrapper"><pre>public void setNumber(final int number){mNumber = number;}public int getNumber(){return mNumber;}public boolean isSomething(){return false;}</pre></div><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocPackageCheck:
Description: |
<p>Checks for missing Javadoc comments in package-info.java files.</p><p>Rationale: description and other related documentation for a package can be written upin the package-info.java file and it gets used in the production of the Javadocs.See <a href="https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html#packagecomment">link</a> for more info.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck:
Description: |
<p>Checks for missing Javadoc comments for class, enum, interface, and annotationinterface definitions. The scope to verify is specified using the <code>Scope</code>class and defaults to <code>Scope.PUBLIC</code>. To verifyanother scope, set property scope to one of the<code>Scope</code> constants.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.NonEmptyAtclauseDescriptionCheck:
Description: |
<p>Checks that the block tag is followed by description.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.RequireEmptyLineBeforeBlockTagGroupCheck:
Description: |
<p>Checks that one blank line before the block tag if it is present in Javadoc.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.SingleLineJavadocCheck:
Description: |
<p>Checks that a Javadoc block can fit in a single line and doesn'tcontain block tags. Javadoc comment that contains at least one block tagshould be formatted in a few lines.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.SummaryJavadocCheck:
Description: |
<p>Checks that<a href="https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html#firstsentence">Javadoc summary sentence</a> does not contain phrases that are not recommended to use.Summaries that contain only the <code>{@inheritDoc}</code> tag are skipped. Check alsoviolate Javadoc that does not contain first sentence.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.javadoc.WriteTagCheck:
Description: |
<p>Requires user defined Javadoc tag to be present in Javadoc comment withdefined format. To define the format for a tag, set property tagFormat to a regularexpression. Property tagSeverity is used for severity of events when the tag exists.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.javadoc
com.puppycrawl.tools.checkstyle.checks.metrics.BooleanExpressionComplexityCheck:
Description: |
<p>Restricts the number of boolean operators (<code>&&</code>, <code>||</code>,<code>&</code>, <code>|</code> and <code>^</code>) in an expression.</p><p>Rationale: Too many conditions leads to code that is difficultto read and hence debug and maintain.</p><p>Note that the operators <code>&</code> and<code>|</code> are not only integer bitwise operators, they are also the<a href="https://docs.oracle.com/javase/specs/jls/se11/html/jls-15.html#jls-15.22.2">non-shortcut versions</a> of the boolean operators<code>&&</code> and <code>||</code>.</p><p>Note that <code>&</code>, <code>|</code> and <code>^</code> are not checkedif they are part of constructor or method callbecause they can be applied to non boolean variables andCheckstyle does not know types of methods from different classes.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.metrics
com.puppycrawl.tools.checkstyle.checks.metrics.ClassDataAbstractionCouplingCheck:
Description: |
<p>Measures the number of instantiations of otherclasses within the given class or record. This type of coupling is notcaused by inheritance or the object orientedparadigm. Generally speaking, any data type with other datatypes as members or local variable that is an instantiation(object) of another class has data abstraction coupling (DAC).The higher the DAC, the more complex the structure of the class.</p><p>This check processes files in the following way:</p><ol><li>Iterates over the list of tokens (defined below) and counts all mentioned classes.<ul><li><a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#IMPORT">PACKAGE_DEF</a></li><li><a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#IMPORT">IMPORT</a></li><li><a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CLASS_DEF">CLASS_DEF</a></li><li><a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INTERFACE_DEF">INTERFACE_DEF</a></li><li><a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ENUM_DEF">ENUM_DEF</a></li><li><a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_NEW">LITERAL_NEW</a></li><li><a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#RECORD_DEF">RECORD_DEF</a></li></ul></li><li>If a class was imported with direct import (i.e.<code>import java.math.BigDecimal</code>), or the class was referenced with thepackage name (i.e. <code>java.math.BigDecimal value</code>) and the package wasadded to the <code>excludedPackages</code> parameter, the class does notincrease complexity.</li><li>If a class name was added to the <code>excludedClasses</code> parameter,the class does not increase complexity.</li></ol><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.metrics
com.puppycrawl.tools.checkstyle.checks.metrics.ClassFanOutComplexityCheck:
Description: |
<p>Checks the number of other types a given class/record/interface/enum/annotationrelies on. Also the square of this has been shown to indicate the amount ofmaintenance required in functional programs (on a file basis) at least.</p><p>This check processes files in the following way:</p><ol><li>Iterates over all tokens that might contain type reference.</li><li>If a class was imported with direct import (i.e.<code>import java.math.BigDecimal</code>), or the class was referenced with thepackage name (i.e. <code>java.math.BigDecimal value</code>) and the package wasadded to the <code>excludedPackages</code> parameter, the class does not increasecomplexity.</li><li>If a class name was added to the <code>excludedClasses</code> parameter,the class does not increase complexity.</li></ol><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.metrics
com.puppycrawl.tools.checkstyle.checks.metrics.CyclomaticComplexityCheck:
Description: |
<p>Checks cyclomatic complexity against a specified limit.It is a measure of the minimum number ofpossible paths through the source and therefore the number ofrequired tests, it is not a about quality of code!It is only applied to methods, c-tors,<a href="https://docs.oracle.com/javase/tutorial/java/javaOO/initial.html">static initializers and instance initializers</a>.</p><p>The complexity is equal to the number of decision points <code> + 1</code>.Decision points: <code>if</code>, <code>while</code>, <code>do</code>, <code>for</code>, <code>?:</code>, <code>catch</code>, <code>switch</code>, <code>case</code>statements and operators <code>&&</code> and <code>||</code>in the body of target.</p><p>By pure theory level 1-4 is considered easy to test, 5-7 OK, 8-10consider re-factoring to ease testing, and 11+ re-factor now as testing will be painful.</p><p>When it comes to code quality measurement by this metriclevel 10 is very good level as a ultimate target (that is hard to archive).Do not be ashamed to have complexity level 15 or even higher,but keep it below 20 to catch really bad designed code automatically.</p><p>Please use Suppression to avoid violations on cases that could not be split in fewmethods without damaging readability of code or encapsulation.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.metrics
com.puppycrawl.tools.checkstyle.checks.metrics.JavaNCSSCheck:
Description: |
<p>Determines complexity of methods, classes and files bycounting the Non Commenting Source Statements (NCSS). Thischeck adheres to the <a href="http://www.kclee.de/clemens/java/javancss/#specification">specification</a> for the<a href="http://www.kclee.de/clemens/java/javancss/">JavaNCSS-Tool</a>written by <b>Chr. Clemens Lee</b>.</p><p>Roughly said the NCSS metric is calculated bycounting the source lines which are not comments, (nearly)equivalent to counting the semicolons and opening curly braces.</p><p>The NCSS for a class is summarized from the NCSSof all its methods, the NCSS of its nested classes and thenumber of member variable declarations.</p><p>The NCSS for a file is summarized from the ncss of all its top level classes,the number of imports and the package declaration.</p><p>Rationale: Too large methods and classes are hard to read andcostly to maintain. A large NCSS number often means that amethod or class has too many responsibilities and/orfunctionalities which should be decomposed into smaller units.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.metrics
com.puppycrawl.tools.checkstyle.checks.metrics.NPathComplexityCheck:
Description: |
<p>Checks the NPATH complexity against a specified limit.</p><p>The NPATH metric computes the number of possible executionpaths through a function(method). It takes into account the nesting ofconditional statements and multi-part boolean expressions(A && B, C || D, E ? F :G and their combinations).</p><p>The NPATH metric was designed base on Cyclomatic complexity toavoid problem of Cyclomatic complexity metric like nesting level within afunction(method).</p><p>Metric was described at <a href="http://dl.acm.org/citation.cfm?id=42379">"NPATH: a measure of execution pathcomplexity and its applications"</a>.If you need detailed description of algorithm, please read that article,it is well written and have number of examples and details.</p><p>Here is some quotes:</p><blockquote>An NPATH threshold value of 200 has been establishedfor a function. The value 200 is based on studies doneat AT&T Bell Laboratories [1988 year].</blockquote><blockquote>Some of the most effective methods of reducing the NPATH value include:<ul><li>distributing functionality;</li><li>implementing multiple if statements as a switch statement;</li><li>creating a separate function for logical expressions with a highcount of variables and (&&) and or (||) operators.</li></ul></blockquote><blockquote>Although strategies to reduce the NPATH complexityof functions are important, care must be taken not todistort the logical clarity of the software by applying astrategy to reduce the complexity of functions. That is,there is a point of diminishing return beyond which afurther attempt at reduction of complexity distorts thelogical clarity of the system structure.</blockquote><div class="wrapper"><table><caption>Examples</caption><thead><tr><th>Structure</th><th> Complexity expression </th></tr></thead><tr><td>if ([expr]) { [if-range] }</td><td>NP(if-range) + 1 + NP(expr)</td></tr><tr><td>if ([expr]) { [if-range] } else { [else-range] }</td><td>NP(if-range)+ NP(else-range) + NP(expr)</td></tr><tr><td>while ([expr]) { [while-range] } </td><td>NP(while-range) + NP(expr) + 1</td></tr><tr><td>do { [do-range] } while ([expr])</td><td>NP(do-range) + NP(expr) + 1</td></tr><tr><td>for([expr1]; [expr2]; [expr3]) { [for-range] }</td><td>NP(for-range) + NP(expr1)+ NP(expr2) + NP(expr3) + 1</td></tr><tr><td>switch ([expr]) { case : [case-range] default: [default-range] }</td><td>S(i=1:i=n)NP(case-range[i]) + NP(default-range) + NP(expr)</td></tr><tr><td>[expr1] ? [expr2] : [expr3]</td><td>NP(expr1) + NP(expr2) + NP(expr3) + 2</td></tr><tr><td>goto label</td><td>1</td></tr><tr><td>break</td><td>1</td></tr><tr><td>Expressions</td><td>Number of && and || operators in expression. Nooperators - 0</td></tr><tr><td>continue</td><td>1</td></tr><tr><td>return</td><td>1</td></tr><tr><td>Statement (even sequential statements)</td><td>1</td></tr><tr><td>Empty block {}</td><td>1</td></tr><tr><td>Function call</td><td>1</td></tr><tr><td>Function(Method) declaration or Block</td><td>P(i=1:i=N)NP(Statement[i])</td></tr></table></div><p><b>Rationale:</b> Nejmeh says that his group had an informal NPATHlimit of 200 on individual routines; functions(methods) that exceededthis value were candidates for further decomposition - or atleast a closer look.<b>Please do not be fanatic with limit 200</b>- choose number that suites your project style. Limit 200 isempirical number base on some sources of at AT&T Bell Laboratoriesof 1988 year.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.metrics
com.puppycrawl.tools.checkstyle.checks.ArrayTypeStyleCheck:
Description: |
<p>Checks the style of array type definitions. Some like Java style:<code>public static void main(String[] args)</code> and some likeC style: <code>public static void main(String args[])</code>.</p><p>By default the Check enforces Java style.</p><p>This check strictly enforces only Java style for method return typesregardless of the value for 'javaStyle'. For example, <code>byte[] getData()</code>.This is because C doesn't compile methods with array declarations on the name.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks
com.puppycrawl.tools.checkstyle.checks.AvoidEscapedUnicodeCharactersCheck:
Description: |
<p>Restricts using<a href="https://docs.oracle.com/javase/specs/jls/se11/html/jls-3.html#jls-3.3">Unicode escapes</a> (such as \u221e).It is possible to allow using escapes for<a href="https://en.wiktionary.org/wiki/Appendix:Control_characters">non-printable, control characters</a>.Also, this check can be configured to allow using escapesif trail comment is present. By the option it is possible toallow using escapes if literal contains only them.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks
com.puppycrawl.tools.checkstyle.checks.indentation.CommentsIndentationCheck:
Description: |
<p>Controls the indentation between comments and surrounding code.Comments are indented at the same level as the surrounding code.Detailed info about such convention can be found<a href="styleguides/google-java-style-20180523/javaguide.html#s4.8.6.1-block-comment-style">here</a></p><p>Please take a look at the following examples to understand how the check works:</p><p>Example #1: Block comments.</p><source><br>1 /*<br>2 * it is Ok<br>3 */<br>4 boolean bool = true;<br>5<br>6 /* violation<br>7 * (block comment should have the same indentation level as line 9)<br>8 */<br>9 double d = 3.14;<br> </source><p>Example #2: Comment is placed at the end of the block and has previous statement.</p><source><br>1 public void foo1() {<br>2 foo2();<br>3 // it is OK<br>4 }<br>5<br>6 public void foo2() {<br>7 foo3();<br>8 // violation (comment should have the same indentation level as line 7)<br>9 }<br> </source><p>Example #3: Comment is used as a single line border to separate groups of methods.</p><source><br>1 /////////////////////////////// it is OK<br>2<br>3 public void foo7() {<br>4 int a = 0;<br>5 }<br>6<br>7 ///////////////////////////// violation (should have the same indentation level as line 9)<br>8<br>9 public void foo8() {}<br> </source><p>Example #4: Comment has distributed previous statement.</p><source><br>1 public void foo11() {<br>2 CheckUtil<br>3 .getFirstNode(new DetailAST())<br>4 .getFirstChild()<br>5 .getNextSibling();<br>6 // it is OK<br>7 }<br>8<br>9 public void foo12() {<br>10 CheckUtil<br>11 .getFirstNode(new DetailAST())<br>12 .getFirstChild()<br>13 .getNextSibling();<br>14 // violation (should have the same indentation level as line 10)<br>15 }<br> </source><p>Example #5: Single line block comment is placed within an empty code block.Note, if comment is placed at the end of the empty code block, we have Checkstyle'slimitations to clearly detect user intention of explanation target - above or below. Theonly case we can assume as a violation is when a single line comment within the emptycode block has indentation level that is lower than the indentation level of the closingright curly brace.</p><source><br>1 public void foo46() {<br>2 // comment<br>3 // block<br>4 // it is OK (we cannot clearly detect user intention of explanation target)<br>5 }<br>6<br>7 public void foo46() {<br>8 // comment<br>9 // block<br>10 // violation (comment should have the same indentation level as line 11)<br>11 }<br> </source><p>Example #6: 'fallthrough' comments and similar.</p><source><br>0 switch(a) {<br>1 case "1":<br>2 int k = 7;<br>3 // it is OK<br>4 case "2":<br>5 int k = 7;<br>6 // it is OK<br>7 case "3":<br>8 if (true) {}<br>9 // violation (should have the same indentation level as line 8 or 10)<br>10 case "4":<br>11 case "5": {<br>12 int a;<br>13 }<br>14 // fall through (it is OK)<br>15 case "12": {<br>16 int a;<br>17 }<br>18 default:<br>19 // it is OK<br>20 }<br> </source><p>Example #7: Comment is placed within a distributed statement.</p><source><br>1 String breaks = "J"<br>2 // violation (comment should have the same indentation level as line 3)<br>3 + "A"<br>4 // it is OK<br>5 + "V"<br>6 + "A"<br>7 // it is OK<br>8 ;<br> </source><p>Example #8: Comment is placed within an empty case block.Note, if comment is placed at the end of the empty case block, we have Checkstyle'slimitations to clearly detect user intention of explanation target - above or below. Theonly case we can assume as a violation is when a single line comment within the empty caseblock has indentation level that is lower than the indentation level of the next casetoken.</p><source><br>1 case 4:<br>2 // it is OK<br>3 case 5:<br>4 // violation (should have the same indentation level as line 3 or 5)<br>5 case 6:<br> </source><p>Example #9: Single line block comment has previous and next statement.</p><source><br>1 String s1 = "Clean code!";<br>2 s.toString().toString().toString();<br>3 // single line<br>4 // block<br>5 // comment (it is OK)<br>6 int a = 5;<br>7<br>8 String s2 = "Code complete!";<br>9 s.toString().toString().toString();<br>10 // violation (should have the same indentation level as line 11)<br>11 // violation (should have the same indentation level as line 12)<br>12 // violation (should have the same indentation level as line 13)<br>13 int b = 18;<br> </source><p>Example #10: Comment within the block tries to describe the next code block.</p><source><br>1 public void foo42() {<br>2 int a = 5;<br>3 if (a == 5) {<br>4 int b;<br>5 // it is OK<br>6 } else if (a ==6) { ... }<br>7 }<br>8<br>9 public void foo43() {<br>10 try {<br>11 int a;<br>12 // Why do we catch exception here? - violation (not the same indentation as line 11)<br>13 } catch (Exception e) { ... }<br>14 }<br> </source><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.indentation
com.puppycrawl.tools.checkstyle.checks.DescendantTokenCheck:
Description: |
<p>Checks for restricted tokens beneath other tokens.</p><p>WARNING: This is a very powerful and flexible check, but, at thesame time, it is low-level and very implementation-dependent becauseits results depend on the grammar we use to build abstract syntaxtrees. Thus we recommend using other checks when they provide thedesired functionality. Essentially, this check just works on the levelof an abstract syntax tree and knows nothing about language structures.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks
com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck:
Description: |
<p>Checks that parameters for methods, constructors, catch and for-each blocks arefinal. Interface, abstract, and native methods are not checked: the finalkeyword does not make sense for interface, abstract, and native methodparameters as there is no code that could modify the parameter.</p><p>Rationale: Changing the value of parameters during the execution ofthe method's algorithm can be confusing and should be avoided. Agreat way to let the Java compiler prevent this coding style is todeclare parameters final.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck:
Description: |
<p>Checks correct indentation of Java code.</p><p>The idea behind this is that while pretty printers aresometimes convenient for bulk reformats of legacy code, they ofteneither aren't configurable enough or just can't anticipate howformat should be done. Sometimes this is personal preference, othertimes it is practical experience. In any case, this check shouldjust ensure that a minimal set of indentation rules is followed.</p><p>Basic offset indentation is used for indentation inside code blocks.For any lines that span more than 1, line wrapping indentation is used for thoselines after the first.Brace adjustment, case, and throws indentations are all used only if those specificidentifiers start the line. If, for example, a brace is used in the middle of the line,its indentation will not take effect.All indentations have an accumulative/recursive effect when they are triggered. Ifduring a line wrapping, another code block is found and it doesn't end on that sameline, then the subsequent lines afterwards, in that new code block, are increased ontop of the line wrap and any indentations above it.</p><p>Example:</p><source><br>if ((condition1 && condition2)<br> || (condition3 && condition4) // line wrap with bigger indentation<br> ||!(condition5 && condition6)) { // line wrap with bigger indentation<br> field.doSomething() // basic offset<br> .doSomething() // line wrap<br> .doSomething( c -> { // line wrap<br> return c.doSome(); // basic offset<br> });<br>}<br> </source><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.indentation
com.puppycrawl.tools.checkstyle.checks.NewlineAtEndOfFileCheck:
Description: |
<p>Checks whether files end with a line separator.</p><p>Rationale: Any source files and text files in general shouldend with a line separator to let other easily add new contentat the end of file and "diff" command does not show previous lines as changed.</p><p>Example (line 36 should not be in diff):</p><source><br>@@ -32,4 +32,5 @@ ForbidWildcardAsReturnTypeCheck.returnTypeClassNamesIgnoreRegex<br>PublicReferenceToPrivateTypeCheck.name = Public Reference To Private Type<br><br>StaticMethodCandidateCheck.name = Static Method Candidate<br>-StaticMethodCandidateCheck.desc = Checks whether private methods should be declared as static.<br>\ No newline at end of file<br>+StaticMethodCandidateCheck.desc = Checks whether private methods should be declared as static.<br>+StaticMethodCandidateCheck.skippedMethods = Method names to skip during the check.<br> </source><p>It can also trick the VCS to report the wrong owner for such lines.An engineer who has added nothing but a newline character becomesthe last known author for the entire line. As a result, a mate can askhim a question to which he will not give the correct answer.</p><p>Old Rationale: CVS source control managementsystems will even print a warning when itencounters a file that doesn't end with a line separator.</p><p>Attention: property fileExtensions works with files that are passed by similar propertyfor at <a href="config.html#Checker">Checker</a>.Please make sure required file extensions are mentioned at Checker's fileExtensionsproperty.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks
com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck:
Description: |
<p>Checks whether file contains code.Files which are considered to have no code:</p><ul><li>File with no text</li><li>File with single line comment(s)</li><li>File with a multi line comment(s).</li></ul><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks
com.puppycrawl.tools.checkstyle.checks.OrderedPropertiesCheck:
Description: |
<p>Detects if keys in properties files are in correct order.</p><p>Rationale: Sorted properties make it easy for people to find required properties by namein file. It makes merges more easy. While there are no problems at runtime.This check is valuable only on files with string resources where order of linesdoes not matter at all, but this can be improved.E.g.: checkstyle/src/main/resources/com/puppycrawl/tools/checkstyle/messages.propertiesYou may suppress warnings of this check for files that have an logical structure likebuild files or log4j configuration files. See SuppressionFilter.<code><suppress checks="OrderedProperties"files="log4j.properties|ResourceBundle/Bug.*.properties|logging.properties"/></code></p><p>Known limitation: The key should not contain a newline.The string compare will work, but not the line number reporting.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks
com.puppycrawl.tools.checkstyle.checks.OuterTypeFilenameCheck:
Description: |
<p>Checks that the outer type name and the file name match. For example,the class <code>Foo</code> must be in a file named<code>Foo.java</code>.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks
com.puppycrawl.tools.checkstyle.checks.TodoCommentCheck:
Description: |
<p>Checks for <code>TODO:</code> comments. Actuallyit is a generic<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/regex/Pattern.html">regularexpression</a> matcher on Java comments. To check for otherpatterns in Java comments, set the <code>format</code> property.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks
com.puppycrawl.tools.checkstyle.checks.TrailingCommentCheck:
Description: |
<p>The check to ensure that requires that comments be the only thing ona line. For the case of <code>//</code> comments that means that the only thingthat should precede it is whitespace. It doesn't check comments ifthey do not end a line; for example, it accepts the following:<code>Thread.sleep( 10 /*some comment here*/ );</code> Formatproperty is intended to deal with the <code>} // while</code> example.</p><p>Rationale: Steve McConnell in <cite>Code Complete</cite> suggests thatendline comments are a bad practice. An end line comment would beone that is on the same line as actual code. For example:</p><source><br>a = b + c; // Some insightful comment<br>d = e / f; // Another comment for this line<br> </source><p>Quoting <cite>Code Complete</cite> for the justification:</p><ul><li> "The comments have to be aligned so that they do notinterfere with the visual structure of the code. If you don't alignthem neatly, they'll make your listing look like it's been through awashing machine."</li><li> "Endline comments tend to be hard to format...It takestime to align them. Such time is not spent learning more about thecode; it's dedicated solely to the tedious task of pressing thespacebar or tab key."</li><li> "Endline comments are also hard to maintain. If the codeon any line containing an endline comment grows, it bumps thecomment farther out, and all the other endline comments will have tobumped out to match. Styles that are hard to maintain aren'tmaintained...."</li><li> "Endline comments also tend to be cryptic. The right sideof the line doesn't offer much room and the desire to keep thecomment on one line means the comment must be short. Work then goesinto making the line as short as possible instead of as clear aspossible. The comment usually ends up as cryptic aspossible...."</li><li> "A systemic problem with endline comments is that it'shard to write a meaningful comment for one line of code. Mostendline comments just repeat the line of code, which hurts more thanit helps."</li></ul><p>McConnell's comments on being hard to maintain when the size of the linechanges are even more important in the age of automatedrefactorings.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks
com.puppycrawl.tools.checkstyle.checks.TranslationCheck:
Description: |
<p>Ensures the correct translation of code by checking property files forconsistency regarding their keys. Two property filesdescribing one and the same context are consistent if theycontain the same keys. TranslationCheck also can check an existence of requiredtranslations which must exist in project, if <code>requiredTranslations</code>option is used.</p><p>Consider the following properties file in the same directory:</p><source><br>#messages.properties<br>hello=Hello<br>cancel=Cancel<br><br>#messages_de.properties<br>hell=Hallo<br>ok=OK<br> </source><p>The Translation check will find the typo in the German <code>hello</code>key, the missing <code>ok</code> key in the default resource file and themissing <code>cancel</code> key in the German resource file:</p><source><br>messages_de.properties: Key 'hello' missing.<br>messages_de.properties: Key 'cancel' missing.<br>messages.properties: Key 'hell' missing.<br>messages.properties: Key 'ok' missing.<br> </source><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks
com.puppycrawl.tools.checkstyle.checks.UncommentedMainCheck:
Description: |
<p>Detects uncommented <code>main</code> methods.</p><p>Rationale: A <code>main</code> method is often used for debuggingpurposes. When debugging is finished, developers often forgetto remove the method, which changes the API and increases thesize of the resulting class or JAR file. With the exception ofthe real program entry points, all <code>main</code> methods should beremoved or commented out of the sources.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks
com.puppycrawl.tools.checkstyle.checks.UniquePropertiesCheck:
Description: |
<p>Detects duplicated keys in properties files.</p><p>Rationale: Multiple property keys usually appear after mergeor rebase of several branches. While there are no problems inruntime, there can be a confusion due to having different valuesfor the duplicated properties.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks
com.puppycrawl.tools.checkstyle.checks.UpperEllCheck:
Description: |
<p>Checks that long constants are defined with an upper ell. Thatis <code>'L'</code> and not <code>'l'</code>. This is in accordance with the JavaLanguage Specification,<a href="https://docs.oracle.com/javase/specs/jls/se11/html/jls-3.html#jls-3.10.1">Section 3.10.1</a>.</p><p>Rationale: The lower-case ell <code>'l'</code> looks a lot like <code>1</code>.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks
com.puppycrawl.tools.checkstyle.checks.modifier.ClassMemberImpliedModifierCheck:
Description: |
<p>Checks for implicit modifiers on nested types in classes and records.</p><p>This check is effectively the opposite of<a href="config_modifier.html#RedundantModifier">RedundantModifier</a>.It checks the modifiers on nested types in classes and records, ensuring that certainmodifiers are explicitly specified even though they are actually redundant.</p><p>Nested enums, interfaces, and records within a class are always <code>static</code> and assuch the compiler does not require the <code>static</code> modifier. This check providesthe ability to enforce that the <code>static</code> modifier is explicitly coded and notimplicitly added by the compiler.</p><source><br>public final class Person {<br> enum Age { // violation<br> CHILD, ADULT<br> }<br>}<br> </source><p>Rationale for this check:Nested enums, interfaces, and records are treated differently from nested classes as theyare only allowed to be <code>static</code>. Developers should not need to remember thisrule, and this check provides the means to enforce that the modifier is coded explicitly.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.modifier
com.puppycrawl.tools.checkstyle.checks.modifier.InterfaceMemberImpliedModifierCheck:
Description: |
<p>Checks for implicit modifiers on interface members and nested types.</p><p>This check is effectively the opposite of<a href="config_modifier.html#RedundantModifier">RedundantModifier</a>.It checks the modifiers on interface members, ensuring that certainmodifiers are explicitly specified even though they are actually redundant.</p><p>Methods in interfaces are <code>public</code> by default, however from Java 9they can also be <code>private</code>. This check provides the ability to enforcethat <code>public</code> is explicitly coded and not implicitly added by the compiler.</p><p>From Java 8, there are three types of methods in interfaces - static methodsmarked with <code>static</code>, default methods marked with <code>default</code> andabstract methods which do not have to be marked with anything.From Java 9, there are also private methods marked with <code>private</code>.This check provides the ability to enforce that <code>abstract</code> is explicitlycoded and not implicitly added by the compiler.</p><p>Fields in interfaces are always <code>public static final</code> and as such thecompiler does not require these modifiers. This check provides the ability toenforce that these modifiers are explicitly coded and not implicitly added bythe compiler.</p><p>Nested types within an interface are always <code>public static</code> and as such thecompiler does not require the <code>public static</code> modifiers. This check providesthe ability to enforce that the <code>public</code> and <code>static</code> modifiersare explicitly coded and not implicitly added by the compiler.</p><source><br>public interface AddressFactory {<br> // check enforces code contains "public static final"<br> public static final String UNKNOWN = "Unknown";<br><br> String OTHER = "Other"; // violation<br><br> // check enforces code contains "public" or "private"<br> public static AddressFactory instance();<br><br> // check enforces code contains "public abstract"<br> public abstract Address createAddress(String addressLine, String city);<br><br> List<Address> findAddresses(String city); // violation<br><br> // check enforces default methods are explicitly declared "public"<br> public default Address createAddress(String city) {<br> return createAddress(UNKNOWN, city);<br> }<br><br> default Address createOtherAddress() { // violation<br> return createAddress(OTHER, OTHER);<br> }<br>}<br> </source><p>Rationale for this check:Methods, fields and nested types are treated differently depending on whetherthey are part of an interface or part of a class. For example, by default methodsare package-scoped on classes, but public in interfaces. However, from Java 8 onwards,interfaces have changed to be much more like abstract classes.Interfaces now have static and instance methods with code. Developers should not haveto remember which modifiers are required and which are implied.This check allows the simpler alternative approach to be adopted where theimplied modifiers must always be coded explicitly.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.modifier
com.puppycrawl.tools.checkstyle.checks.modifier.ModifierOrderCheck:
Description: |
<p>Checks that the order of modifiers conforms to the suggestions inthe <a href="https://docs.oracle.com/javase/specs/jls/se11/html/jls-8.html">JavaLanguage specification, § 8.1.1, 8.3.1, 8.4.3</a> and<a href="https://docs.oracle.com/javase/specs/jls/se11/html/jls-9.html">9.4</a>. The correct order is:</p><ol><li><code>public</code></li><li><code>protected</code></li><li><code>private</code></li><li><code>abstract</code></li><li><code>default</code></li><li><code>static</code></li><li><code>final</code></li><li><code>transient</code></li><li><code>volatile</code></li><li><code>synchronized</code></li><li><code>native</code></li><li><code>strictfp</code></li></ol><p>In additional, modifiers are checked to ensure all annotations aredeclared before all other modifiers.</p><p>Rationale: Code is easier to read if everybody follows a standard.</p><p>ATTENTION: We skip<a href="https://www.oracle.com/technical-resources/articles/java/ma14-architect-annotations.html">type annotations</a> from validation.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.modifier
com.puppycrawl.tools.checkstyle.checks.modifier.RedundantModifierCheck:
Description: |
<p>Checks for redundant modifiers.</p><p>Rationale: The Java Language Specification stronglydiscourages the usage of <code>public</code> and <code>abstract</code> for methoddeclarations in interface definitions as a matter of style.</p><p>The check validates:</p><ol><li>Interface and annotation definitions.</li><li>Final modifier on methods of final and anonymous classes.</li><li>Inner <code>interface</code> declarations that are declaredas <code>static</code>.</li><li>Class constructors.</li><li>Nested <code>enum</code> definitions that are declaredas <code>static</code>.</li></ol><p>Interfaces by definition are abstract so the <code>abstract</code>modifier on the interface is redundant.</p><p>Classes inside of interfaces by definition are public and static,so the <code>public</code> and <code>static</code> modifierson the inner classes are redundant. On the other hand, classesinside of interfaces can be abstract or non abstract.So, <code>abstract</code> modifier is allowed.</p><p>Fields in interfaces and annotations are automaticallypublic, static and final, so these modifiers are redundant aswell.</p><p>As annotations are a form of interface, their fields are alsoautomatically public, static and final just as theirannotation fields are automatically public and abstract.</p><p>Enums by definition are static implicit subclasses of java.lang.Enum<E>.So, the <code>static</code> modifier on the enums is redundant. In addition,if enum is inside of interface, <code>public</code> modifier is also redundant.</p><p>Enums can also contain abstract methods and methods which can be overridden by thedeclared enumeration fields.See the following example:</p><source><br>public enum EnumClass {<br> FIELD_1,<br> FIELD_2 {<br> @Override<br> public final void method1() {} // violation expected<br> };<br><br> public void method1() {}<br> public final void method2() {} // no violation expected<br>}<br> </source><p>Since these methods can be overridden in these situations, the final methods are notmarked as redundant even though they can't be extended by other classes/enums.</p><p>Nested <code>enum</code> types are always static by default.</p><p>Final classes by definition cannot be extended so the <code>final</code>modifier on the method of a final class is redundant.</p><p>Public modifier for constructors in non-public non-protected classesis always obsolete:</p><source><br>public class PublicClass {<br> public PublicClass() {} // OK<br>}<br><br>class PackagePrivateClass {<br> public PackagePrivateClass() {} // violation expected<br>}<br> </source><p>There is no violation in the following example,because removing public modifier from ProtectedInnerClassconstructor will make this code not compiling:</p><source><br>package a;<br>public class ClassExample {<br> protected class ProtectedInnerClass {<br> public ProtectedInnerClass () {}<br> }<br>}<br><br>package b;<br>import a.ClassExample;<br>public class ClassExtending extends ClassExample {<br> ProtectedInnerClass pc = new ProtectedInnerClass();<br>}<br> </source><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.modifier
".OverviewCheck": {}
com.puppycrawl.tools.checkstyle.checks.naming.AbbreviationAsWordInNameCheck:
Description: |
<p>Validates abbreviations (consecutive capital letters) length in identifier name,it also allows to enforce camel case naming. Please read more at<a href="https://checkstyle.org/styleguides/google-java-style-20180523/javaguide.html#s5.3-camel-case">Google Style Guide</a>to get to know how to avoid long abbreviations in names.</p><p><code>allowedAbbreviationLength</code> specifies how many consecutive capital letters areallowed in the identifier.A value of <i>3</i> indicates that up to 4 consecutive capital letters are allowed,one after the other, before a violation is printed. The identifier 'MyTEST' would beallowed, but 'MyTESTS' would not be.A value of <i>0</i> indicates that only 1 consecutive capital letter is allowed. Thisis what should be used to enforce strict camel casing. The identifier 'MyTest' wouldbe allowed, but 'MyTEst' would not be.</p><p><code>ignoreFinal</code>, <code>ignoreStatic</code>, and <code>ignoreStaticFinal</code>control whether variables with the respective modifiers are to be ignored.Note that a variable that is both static and final will always be considered under<code>ignoreStaticFinal</code> only, regardless of the values of <code>ignoreFinal</code>and <code>ignoreStatic</code>. So for example if <code>ignoreStatic</code> is true but<code>ignoreStaticFinal</code> is false, then static final variables will not be ignored.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.naming
com.puppycrawl.tools.checkstyle.checks.naming.AbstractClassNameCheck:
Description: |
<p>Ensures that the names of abstract classes conforming to some regular expression andcheck that <code>abstract</code> modifier exists.</p><p>Rationale: Abstract classes are convenience base class implementations ofinterfaces, not types as such. As such they should be named to indicate this.Also if names of classes starts with 'Abstract' it's very convenient thatthey will have abstract modifier.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.naming
"<p>com.puppycrawl.tools.checkstyle.checks.naming</p>.CatchParameterNameCheck":
Description: |
<p>Checks that <code>catch</code> parameter names conform to a specified pattern.</p><p>Default pattern has the following characteristic:</p><ul><li>allows names beginning with two lowercase letters followed by at least one uppercaseor lowercase letter</li><li>allows <code>e</code> abbreviation (suitable for exceptions end errors)</li><li>allows <code>ex</code> abbreviation (suitable for exceptions)</li><li>allows <code>t</code> abbreviation (suitable for throwables)</li><li>prohibits numbered abbreviations like <code>e1</code> or <code>t2</code></li><li>prohibits one letter prefixes like <code>pException</code></li><li>prohibits two letter abbreviations like <code>ie</code> or <code>ee</code></li><li>prohibits any other characters than letters</li></ul><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: "<p>com.puppycrawl.tools.checkstyle.checks.naming</p>"
com.puppycrawl.tools.checkstyle.checks.naming.ClassTypeParameterNameCheck:
Description: |
<p>Checks that class type parameter names conform to a specified pattern.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.naming
com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck:
Description: |
<p>Checks that constant names conform to a specified pattern.A <em>constant</em> is a <strong>static</strong> and <strong>final</strong> field or aninterface/annotation field, except <strong>serialVersionUID</strong> and<strong>serialPersistentFields</strong>.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.naming
"<p>com.puppycrawl.tools.checkstyle.checks.naming</p>.IllegalIdentifierNameCheck":
Description: |
<p>Checks identifiers with a regular expression for a set of illegal names, such as thosethat are restricted or contextual keywords. Examples include "yield", "record","_", and "var". Please read more at<a href="https://docs.oracle.com/javase/specs/jls/se14/html/jls-3.html#jls-3.9">Java Language Specification</a>to get to know more about restricted keywords. Since this check uses aregular expression to specify valid identifiers, users can also prohibit the usageof certain symbols, such as "$", or any non-ascii character.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: "<p>com.puppycrawl.tools.checkstyle.checks.naming</p>"
com.puppycrawl.tools.checkstyle.checks.naming.InterfaceTypeParameterNameCheck:
Description: |
<p>Checks that interface type parameter names conform to a specified pattern.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.naming
com.puppycrawl.tools.checkstyle.checks.naming.LambdaParameterNameCheck:
Description: |
<p>Checks lambda parameter names.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.naming
com.puppycrawl.tools.checkstyle.checks.naming.LocalFinalVariableNameCheck:
Description: |
<p>Checks that local final variable names conform to a specified pattern.A catch parameter and resources in try statementsare considered to be a local, final variables.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.naming
com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck:
Description: |
<p>Checks that local, non-<code>final</code> variable names conform to a specified pattern.A catch parameter is considered to be a local variable.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.naming
com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck:
Description: |
<p>Checks that instance variable names conform to a specified pattern.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.naming
com.puppycrawl.tools.checkstyle.checks.naming.MethodNameCheck:
Description: |
<p>Checks that method names conform to a specified pattern.</p><p>Also, checks if a method name has the same name as the residing class.The default is false (it is not allowed). It is legal in Java to havemethod with the same name as a class. As long as a return type is specifiedit is a method and not a constructor which it could be easily confused as.Does not check-style the name of an overridden methods because the developerdoes not have a choice in renaming such methods.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.naming
com.puppycrawl.tools.checkstyle.checks.naming.MethodTypeParameterNameCheck:
Description: |
<p>Checks that method type parameter names conform to a specified pattern.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.naming
com.puppycrawl.tools.checkstyle.checks.naming.PackageNameCheck:
Description: |
<p>Checks that package names conform to a specified pattern.</p><p>The default value of <code>format</code> for module <code>PackageName</code> has beenchosen to match the requirements in the <a href="https://docs.oracle.com/javase/specs/jls/se8/html/jls-6.html#jls-6.5.3">JavaLanguage specification</a> and the Sun coding conventions. Howeverboth underscores and uppercase letters are rather uncommon, so mostconfigurations should probably assign value <code>^[a-z]+(\.[a-z][a-z0-9]*)*$</code> to<code>format</code> for module <code>PackageName</code>.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.naming
com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck:
Description: |
<p>Checks that method parameter names conform to a specified pattern.By using <code>accessModifiers</code> property it is possibleto specify different formats for methods at different visibility levels.</p><p>To validate <code>catch</code> parameters please use<a href="https://checkstyle.org/config_naming.html#CatchParameterName">CatchParameterName</a>.</p><p>To validate lambda parameters please use<a href="https://checkstyle.org/config_naming.html#LambdaParameterName">LambdaParameterName</a>.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.naming
com.puppycrawl.tools.checkstyle.checks.naming.PatternVariableNameCheck:
Description: |
<p>Checks that pattern variable names conform to a specified pattern.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.naming
"<p>com.puppycrawl.tools.checkstyle.checks.naming</p>.RecordTypeParameterNameCheck":
Description: |
<p>Checks that record type parameter names conform to a specified pattern.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: "<p>com.puppycrawl.tools.checkstyle.checks.naming</p>"
com.puppycrawl.tools.checkstyle.checks.naming.StaticVariableNameCheck:
Description: |
<p>Checks that <code>static</code>, non-<code>final</code> variable namesconform to a specified pattern.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.naming
com.puppycrawl.tools.checkstyle.checks.naming.TypeNameCheck:
Description: |
<p>Checks that type names conform to a specified pattern.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.naming
com.puppycrawl.tools.checkstyle.checks.regexp.RegexpCheck:
Description: |
<p>Checks that a specified pattern exists, exists lessthan a set number of times, or does not exist in the file.</p><p>This check combines all the functionality provided by<a href="config_header.html#RegexpHeader">RegexpHeader</a>except supplying the regular expression from a file.</p><p>It differs from them in that it works in multiline mode.Its regular expression can span multiple lines and it checks thisagainst the whole file at once.The others work in singleline mode.Their single or multiple regular expressions can only span one line.They check each of these against each line in the file in turn.</p><p><b>Note:</b> Because of the different mode of operation there may besome changes in the regular expressions used to achieve a particular end.</p><p>In multiline mode...</p><ul><li> <code>^</code> means the beginning of a line, as opposed to beginning of theinput.</li><li> For beginning of the input use <code>\A</code>.</li><li> <code>$</code> means the end of a line, as opposed to the end of the input.</li><li> For end of input use <code>\Z</code>.</li><li> Each line in the file is terminated with a line feed character.</li></ul><p><b>Note:</b> Not all regular expression engines are created equal. Some provide extrafunctions that others do not and some elements of the syntax may vary.This check makes use of the<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/regex/package-summary.html">java.util.regex package</a>; please check its documentation fordetails of how to construct a regular expression to achieve a particulargoal.</p><p><b>Note:</b> When entering a regular expression as a parameter in theXML config file you must also take into account the XML rules. e.g. ifyou want to match a < symbol you need to enter &lt;. The regularexpression should be entered on one line.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.regexp
com.puppycrawl.tools.checkstyle.checks.regexp.RegexpMultilineCheck:
Description: |
<p>Checks that a specified pattern matches across multiple lines inany file type.</p><p>Rationale: This check can be used to when the regularexpression can be span multiple lines.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.regexp
com.puppycrawl.tools.checkstyle.checks.regexp.RegexpOnFilenameCheck:
Description: |
<p>Checks that a specified pattern matches based on file and/or folder path.It can also be used to verify files match specific namingpatterns not covered by other checks (Ex: properties, xml, etc.).</p><p>When customizing the check, the properties are applied in a specific order.The fileExtensions property first picks only files that match any of thespecific extensions supplied.Once files are matched against the fileExtensions, the match property is thenused in conjunction with the patterns to determine if the check is lookingfor a match or mis-match on those files. If the fileNamePattern issupplied, the matching is only applied to the fileNamePattern and not thefolderPattern. If no fileNamePattern is supplied, then matching is appliedto the folderPattern only and will result in all files in a folder to bereported on violations. If no folderPattern is supplied, then all foldersthat checkstyle finds are examined for violations.The ignoreFileNameExtensions property drops the file extension and appliesthe fileNamePattern only to the rest of file name. For example, if the file isnamed 'test.java' and this property is turned on, the pattern is only appliedto 'test'.</p><p>If this check is configured with no properties, then the default behaviorof this check is to report file names with spaces in them.When at least one pattern property is supplied, the entire check is underthe user's control to allow them to fully customize the behavior.</p><p>It is recommended that if you create your own pattern, to alsospecify a custom violation message. This allows the violation message printedto be clear what the violation is, especially if multiple RegexpOnFilenamechecks are used.Argument 0 for the message populates the check's folderPattern.Argument 1 for the message populates the check's fileNamePattern.The file name is not passed as an argument since it is part of CheckStyle'sdefault violation messages.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.regexp
com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineCheck:
Description: |
<p>Checks that a specified pattern matches a single line in any file type.</p><p>Rationale: This check can be used to prototype checks and tofind common bad practice such as calling <code>ex.printStacktrace()</code>, <code>System.out.println()</code>, <code>System.exit()</code>, etc.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.regexp
com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck:
Description: |
<p>Checks that a specified pattern matches a single line in Java files.</p><p>This class is variation on<a href="config_regexp.html#RegexpSingleline">RegexpSingleline</a> for detectingsingle lines that match a supplied regular expression in Java files. It supportssuppressing matches in Java comments.</p><p>
<i><a href="http://checkstyle.sourceforge.net/checks.html">This documentation is written and maintained by the Checkstyle community</a> and is <a href="http://checkstyle.sourceforge.net/license.html">covered under the same license as the Checkstyle project.</a></i>
</p>
Package: com.puppycrawl.tools.checkstyle.checks.regexp
com.puppycrawl.tools.checkstyle.checks.sizes.AnonInnerLengthCheck:
Description: |