forked from checkstyle/checkstyle
/
config_misc.xml
2065 lines (1919 loc) · 74.3 KB
/
config_misc.xml
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
<?xml version="1.0" encoding="UTF-8"?>
<document xmlns="http://maven.apache.org/XDOC/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
<head>
<title>Miscellaneous</title>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"/>
<script type="text/javascript" src="js/anchors.js"/>
<script type="text/javascript" src="js/google-analytics.js"/>
<link rel="icon" href="images/favicon.png" type="image/x-icon" />
<link rel="shortcut icon" href="images/favicon.ico" type="image/ico" />
</head>
<body>
<section name="Content">
<macro name="toc">
<param name="fromDepth" value="1"/>
<param name="toDepth" value="1"/>
</macro>
</section>
<section name="ArrayTypeStyle">
<subsection name="Description" id="ArrayTypeStyle_Description">
<p>Since Checkstyle 3.1</p>
<p>
Checks the style of array type definitions. Some like Java style:
<code>public static void main(String[] args)</code> and some like
C style: <code>public static void main(String args[])</code>.
</p>
<p>
This check also enforces only Java style for method return types.
</p>
</subsection>
<subsection name="Properties" id="ArrayTypeStyle_Properties">
<table>
<tr>
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr>
<td>javaStyle</td>
<td>
Controls whether to enforce Java style (true) or C style (false).
</td>
<td><a href="property_types.html#boolean">Boolean</a></td>
<td><code>true</code></td>
<td>3.1</td>
</tr>
</table>
</subsection>
<subsection name="Examples" id="ArrayTypeStyle_Examples">
<p>
To configure the check to enforce Java style:
</p>
<source>
<module name="ArrayTypeStyle"/>
</source>
<p>
Example:
</p>
<source>
public class MyClass {
int[] nums; // OK
String strings[]; // violation
char[] toCharArray() { // OK
return null;
}
byte getData()[] { // violation
return null;
}
}
</source>
<p>
To configure the check to enforce C style:
</p>
<source>
<module name="ArrayTypeStyle">
<property name="javaStyle" value="false"/>
</module>
</source>
<p>
Example:
</p>
<source>
public class MyClass {
int[] nums; // violation
String strings[]; // OK
char[] toCharArray() { // OK
return null;
}
byte getData()[] { // violation
return null;
}
}
</source>
<p>
Note that method return types must be Java style even when the check is configured
to enforce C style. This is because function/method return types in C/C++ cannot be
arrays, so there is no "C style" for such array types.
</p>
</subsection>
<subsection name="Example of Usage" id="ArrayTypeStyle_Example_of_Usage">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Agoogle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+ArrayTypeStyle">
Google Style</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Asun_checks.xml+repo%3Acheckstyle%2Fcheckstyle+ArrayTypeStyle">
Sun Style</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+ArrayTypeStyle">
Checkstyle Style</a>
</li>
</ul>
</subsection>
<subsection name="Error Messages" id="ArrayTypeStyle_Error_Messages">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22array.type.style%22">
array.type.style</a>
</li>
</ul>
<p>
All messages can be customized if the default message doesn't suit you.
Please <a href="config.html#Custom_messages">see the documentation</a> to learn how to.
</p>
</subsection>
<subsection name="Package" id="ArrayTypeStyle_Package">
<p>
com.puppycrawl.tools.checkstyle.checks
</p>
</subsection>
<subsection name="Parent Module" id="ArrayTypeStyle_Parent_Module">
<p>
<a href="config.html#TreeWalker">TreeWalker</a>
</p>
</subsection>
</section>
<section name="AvoidEscapedUnicodeCharacters">
<subsection name="Description" id="AvoidEscapedUnicodeCharacters_Description">
<p>Since Checkstyle 5.8</p>
<p>
Restrict using
<a href = "https://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.3">
Unicode escapes</a> (e.g. \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 escapes
if trail comment is present. By the option it is possible to
allow using escapes if literal contains only them.
</p>
</subsection>
<subsection name="Properties" id="AvoidEscapedUnicodeCharacters_Properties">
<table>
<tr>
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr>
<td>allowEscapesForControlCharacters</td>
<td>Allow use escapes for non-printable(control) characters.</td>
<td><a href="property_types.html#boolean">Boolean</a></td>
<td>false</td>
<td>5.8</td>
</tr>
<tr>
<td>allowByTailComment</td>
<td>Allow use escapes if trail comment is present.</td>
<td><a href="property_types.html#boolean">Boolean</a></td>
<td>false</td>
<td>5.8</td>
</tr>
<tr>
<td>allowIfAllCharactersEscaped</td>
<td>Allow if all characters in literal are escaped.</td>
<td><a href="property_types.html#boolean">Boolean</a></td>
<td>false</td>
<td>5.8</td>
</tr>
<tr>
<td>allowNonPrintableEscapes</td>
<td>Allow non-printable escapes.</td>
<td><a href="property_types.html#boolean">Boolean</a></td>
<td>false</td>
<td>5.8</td>
</tr>
</table>
</subsection>
<subsection name="Examples" id="AvoidEscapedUnicodeCharacters_Examples">
<p>
Examples of using Unicode:
</p>
<source>
String unitAbbrev = "μs"; //Best: perfectly clear even without a comment.
String unitAbbrev = "\u03bcs"; //Poor: the reader has no idea what this is.
</source>
<p>
An example of how to configure the check is:
</p>
<source>
<module name="AvoidEscapedUnicodeCharacters"/>
</source>
<p>
An example of non-printable(control) characters.
</p>
<source>
return '\ufeff' + content; // byte order mark
</source>
<p>
An example of how to configure the check to allow using escapes
for non-printable(control) characters:
</p>
<source>
<module name="AvoidEscapedUnicodeCharacters">
<property name="allowEscapesForControlCharacters" value="true"/>
</module>
</source>
<p>
Example of using escapes with trail comment:
</p>
<source>
String unitAbbrev = "\u03bcs"; // Greek letter mu, "s"
</source>
<p>
An example of how to configure the check to allow using escapes
if trail comment is present:
</p>
<source>
<module name="AvoidEscapedUnicodeCharacters">
<property name="allowByTailComment" value="true"/>
</module>
</source>
<p>
Example of using escapes if literal contains only them:
</p>
<source>
String unitAbbrev = "\u03bc\u03bc\u03bc";
</source>
<p>
An example of how to configure the check to allow escapes
if literal contains only them:
</p>
<source>
<module name="AvoidEscapedUnicodeCharacters">
<property name="allowIfAllCharactersEscaped" value="true"/>
</module>
</source>
<p>
An example of how to configure the check to allow non-printable escapes:
</p>
<source>
<module name="AvoidEscapedUnicodeCharacters">
<property name="allowNonPrintableEscapes" value="true"/>
</module>
</source>
</subsection>
<subsection name="Example of Usage" id="AvoidEscapedUnicodeCharacters_Example_of_Usage">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Agoogle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+AvoidEscapedUnicodeCharacters">
Google Style</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+AvoidEscapedUnicodeCharacters">
Checkstyle Style</a>
</li>
</ul>
</subsection>
<subsection name="Error Messages" id="AvoidEscapedUnicodeCharacters_Error_Messages">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22forbid.escaped.unicode.char%22">
forbid.escaped.unicode.char</a>
</li>
</ul>
<p>
All messages can be customized if the default message doesn't suit you.
Please <a href="config.html#Custom_messages">see the documentation</a> to learn how to.
</p>
</subsection>
<subsection name="Package" id="AvoidEscapedUnicodeCharacters_Package">
<p>
com.puppycrawl.tools.checkstyle.checks
</p>
</subsection>
<subsection name="Parent Module" id="AvoidEscapedUnicodeCharacters_Parent_Module">
<p>
<a href="config.html#TreeWalker">TreeWalker</a>
</p>
</subsection>
</section>
<section name="CommentsIndentation">
<subsection name="Description" id="CommentsIndentation_Description">
<p>Since Checkstyle 6.10</p>
<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-20170228.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>
1 /*
2 * it is Ok
3 */
4 boolean bool = true;
5
6 /* violation
7 * (block comment should have the same indentation level as line 9)
8 */
9 double d = 3.14;
</source>
<p>Example #2: Comment is placed at the end of the block and has previous statement.</p>
<source>
1 public void foo1() {
2 foo2();
3 // it is OK
4 }
5
6 public void foo2() {
7 foo3();
8 // violation (comment should have the same indentation level as line 7)
9 }
</source>
<p>Example #3: Comment is used as a single line border to separate groups of methods.</p>
<source>
1 /////////////////////////////// it is OK
2
3 public void foo7() {
4 int a = 0;
5 }
6
7 /////////////////////////////// violation (should have the same indentation level as line 9)
8
9 public void foo8() {}
</source>
<p>Example #4: Comment has distributed previous statement.</p>
<source>
1 public void foo11() {
2 CheckUtil
3 .getFirstNode(new DetailAST())
4 .getFirstChild()
5 .getNextSibling();
6 // it is OK
7 }
8
9 public void foo12() {
10 CheckUtil
11 .getFirstNode(new DetailAST())
12 .getFirstChild()
13 .getNextSibling();
14 // violation (should have the same indentation level as line 10)
15 }
</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's
limitations to clearly detect user intention of explanation target - above or below. The
only case we can assume as a violation is when a single line comment within the empty
code block has indentation level that is lower than the indentation level of the closing
right curly brace.
</p>
<source>
1 public void foo46() {
2 // comment
3 // block
4 // it is OK (we cannot clearly detect user intention of explanation target)
5 }
6
7 public void foo46() {
8 // comment
9 // block
10 // violation (comment should have the same indentation level as line 11)
11 }
</source>
<p>Example #6: 'fallthrough' comments and similar.</p>
<source>
0 switch(a) {
1 case "1":
2 int k = 7;
3 // it is OK
4 case "2":
5 int k = 7;
6 // it is OK
7 case "3":
8 if (true) {}
9 // violation (should have the same indentation level as line 8 or 10)
10 case "4":
11 case "5": {
12 int a;
13 }
14 // fall through (it is OK)
15 case "12": {
16 int a;
17 }
18 default:
19 // it is OK
20 }
</source>
<p>Example #7: Comment is placed within a distributed statement.</p>
<source>
1 String breaks = "J"
2 // violation (comment should have the same indentation level as line 3)
3 + "A"
4 // it is OK
5 + "V"
6 + "A"
7 // it is OK
8 ;
</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's
limitations to clearly detect user intention of explanation target - above or below. The
only case we can assume as a violation is when a single line comment within the empty case
block has indentation level that is lower than the indentation level of the next case
token.
</p>
<source>
1 case 4:
2 // it is OK
3 case 5:
4 // violation (should have the same indentation level as line 3 or 5)
5 case 6:
</source>
<p>Example #9: Single line block comment has previous and next statement.</p>
<source>
1 String s1 = "Clean code!";
2 s.toString().toString().toString();
3 // single line
4 // block
5 // comment (it is OK)
6 int a = 5;
7
8 String s2 = "Code complete!";
9 s.toString().toString().toString();
10 // violation (should have the same indentation level as line 11)
11 // violation (should have the same indentation level as line 12)
12 // violation (should have the same indentation level as line 13)
13 int b = 18;
</source>
<p>Example #10: Comment within the block tries to describe the next code block.</p>
<source>
1 public void foo42() {
2 int a = 5;
3 if (a == 5) {
4 int b;
5 // it is OK
6 } else if (a ==6) { ... }
7 }
8
9 public void foo43() {
10 try {
11 int a;
12 // Why do we catch exception here? - violation (should have the same indentation as line 11)
13 } catch (Exception e) { ... }
14 }
</source>
</subsection>
<subsection name="Properties" id="CommentsIndentation_Properties">
<table>
<tr>
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr>
<td>tokens</td>
<td>tokens to check</td>
<td>
subset of tokens
<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SINGLE_LINE_COMMENT">
SINGLE_LINE_COMMENT</a>,
<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BLOCK_COMMENT_BEGIN">
BLOCK_COMMENT_BEGIN</a>.
</td>
<td>
<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#SINGLE_LINE_COMMENT">
SINGLE_LINE_COMMENT</a>,
<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#BLOCK_COMMENT_BEGIN">
BLOCK_COMMENT_BEGIN</a>.
</td>
<td>6.10</td>
</tr>
</table>
</subsection>
<subsection name="Examples" id="CommentsIndentation_Examples">
<p>
To configure the Check:
</p>
<source>
<module name="CommentsIndentation"/>
</source>
</subsection>
<subsection name="Example of Usage" id="CommentsIndentation_Example_of_Usage">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Agoogle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+CommentsIndentation">
Google Style</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+CommentsIndentation">
Checkstyle Style</a>
</li>
</ul>
</subsection>
<subsection name="Error Messages" id="CommentsIndentation_Error_Messages">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Findentation+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22comments.indentation.block%22">
comments.indentation.block</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Findentation+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22comments.indentation.single%22">
comments.indentation.single</a>
</li>
</ul>
<p>
All messages can be customized if the default message doesn't suit you.
Please <a href="config.html#Custom_messages">see the documentation</a> to learn how to.
</p>
</subsection>
<subsection name="Package" id="CommentsIndentation_Package">
<p>
com.puppycrawl.tools.checkstyle.checks.indentation
</p>
</subsection>
<subsection name="Parent Module" id="CommentsIndentation_Parent_Module">
<p>
<a href="config.html#TreeWalker">TreeWalker</a>
</p>
</subsection>
</section>
<section name="DescendantToken">
<subsection name="Description" id="DescendantToken_Description">
<p>Since Checkstyle 3.2</p>
<p>
Checks for restricted tokens beneath other tokens.
</p>
<p>
WARNING: This is a very powerful and flexible check, but, at the
same time, it is low-level and very implementation-dependent because
its results depend on the grammar we use to build abstract syntax
trees. Thus we recommend using other checks when they provide the
desired functionality. Essentially, this check just works on the level
of an abstract syntax tree and knows nothing about language structures.
</p>
</subsection>
<subsection name="Properties" id="DescendantToken_Properties">
<table>
<tr>
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr>
<td>limitedTokens</td>
<td>set of tokens with limited occurrences as descendants</td>
<td>
subset of tokens
<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html">TokenTypes</a>
</td>
<td/>
<td>3.2</td>
</tr>
<tr>
<td>minimumDepth</td>
<td>the minimum depth for descendant counts</td>
<td><a href="property_types.html#integer">Integer</a></td>
<td>0</td>
<td>3.2</td>
</tr>
<tr>
<td>maximumDepth</td>
<td>the maximum depth for descendant counts</td>
<td><a href="property_types.html#integer">Integer</a></td>
<td>java.lang.Integer.MAX_VALUE</td>
<td>3.2</td>
</tr>
<tr>
<td>minimumNumber</td>
<td>a minimum count for descendants</td>
<td><a href="property_types.html#integer">Integer</a></td>
<td>0</td>
<td>3.2</td>
</tr>
<tr>
<td>maximumNumber</td>
<td>a maximum count for descendants</td>
<td><a href="property_types.html#integer">Integer</a></td>
<td>java.lang.Integer.MAX_VALUE</td>
<td>3.2</td>
</tr>
<tr>
<td>sumTokenCounts</td>
<td>
whether the number of tokens found should be calculated
from the sum of the individual token counts
</td>
<td><a href="property_types.html#boolean">Boolean</a></td>
<td><code>false</code></td>
<td>5.0</td>
</tr>
<tr>
<td>minimumMessage</td>
<td>error message when the minimum count is not reached</td>
<td><a href="property_types.html#string">String</a></td>
<td>null</td>
<td>3.2</td>
</tr>
<tr>
<td>maximumMessage</td>
<td>error message when the maximum count is exceeded</td>
<td><a href="property_types.html#string">String</a></td>
<td>null</td>
<td>3.2</td>
</tr>
</table>
</subsection>
<subsection name="Examples" id="DescendantToken_Examples">
<p>Switch with no default:</p>
<source>
<module name="DescendantToken">
<property name="tokens" value="LITERAL_SWITCH"/>
<property name="maximumDepth" value="2"/>
<property name="limitedTokens" value="LITERAL_DEFAULT"/>
<property name="minimumNumber" value="1"/>
</module>
</source>
<p>
The condition in <code>for</code> performs no check:
</p>
<source>
<module name="DescendantToken">
<property name="tokens" value="FOR_CONDITION"/>
<property name="limitedTokens" value="EXPR"/>
<property name="minimumNumber" value="1"/>
</module>
</source>
<p>
Comparing <code>this</code> with <code>null</code> (i.e. <code>this ==
null</code> and <code>this != null</code>):
</p>
<source>
<module name="DescendantToken">
<property name="tokens" value="EQUAL,NOT_EQUAL"/>
<property name="limitedTokens" value="LITERAL_THIS,LITERAL_NULL"/>
<property name="maximumNumber" value="1"/>
<property name="maximumDepth" value="1"/>
<property name="sumTokenCounts" value="true"/>
</module>
</source>
<p>String literal equality check:</p>
<source>
<module name="DescendantToken">
<property name="tokens" value="EQUAL,NOT_EQUAL"/>
<property name="limitedTokens" value="STRING_LITERAL"/>
<property name="maximumNumber" value="0"/>
<property name="maximumDepth" value="1"/>
</module>
</source>
<p>
Assert statement may have side effects (formatted for browser
display):
</p>
<source>
<module name="DescendantToken">
<property name="tokens" value="LITERAL_ASSERT"/>
<property name="limitedTokens" value="ASSIGN,DEC,INC,POST_DEC,
POST_INC,PLUS_ASSIGN,MINUS_ASSIGN,STAR_ASSIGN,DIV_ASSIGN,MOD_ASSIGN,
BSR_ASSIGN,SR_ASSIGN,SL_ASSIGN,BAND_ASSIGN,BXOR_ASSIGN,BOR_ASSIGN,
METHOD_CALL"/>
<property name="maximumNumber" value="0"/>
</module>
</source>
<p>
The initialiser in <code>for</code> performs no setup (where a <code>while</code>
statement could be used instead):
</p>
<source>
<module name="DescendantToken">
<property name="tokens" value="FOR_INIT"/>
<property name="limitedTokens" value="EXPR"/>
<property name="minimumNumber" value="1"/>
</module>
</source>
<p>
A switch within a switch:
</p>
<source>
<module name="DescendantToken">
<property name="tokens" value="LITERAL_SWITCH"/>
<property name="limitedTokens" value="LITERAL_SWITCH"/>
<property name="maximumNumber" value="0"/>
<property name="minimumDepth" value="1"/>
</module>
</source>
<p>A return statement from within a catch or finally block:</p>
<source>
<module name="DescendantToken">
<property name="tokens" value="LITERAL_FINALLY,LITERAL_CATCH"/>
<property name="limitedTokens" value="LITERAL_RETURN"/>
<property name="maximumNumber" value="0"/>
</module>
</source>
<p>A try statement within a catch or finally block:</p>
<source>
<module name="DescendantToken">
<property name="tokens" value="LITERAL_CATCH,LITERAL_FINALLY"/>
<property name="limitedTokens" value="LITERAL_TRY"/>
<property name="maximumNumber" value="0"/>
</module>
</source>
<p>Too many cases within a switch:</p>
<source>
<module name="DescendantToken">
<property name="tokens" value="LITERAL_SWITCH"/>
<property name="limitedTokens" value="LITERAL_CASE"/>
<property name="maximumDepth" value="2"/>
<property name="maximumNumber" value="10"/>
</module>
</source>
<p>Too many local variables within a method:</p>
<source>
<module name="DescendantToken">
<property name="tokens" value="METHOD_DEF"/>
<property name="limitedTokens" value="VARIABLE_DEF"/>
<property name="maximumDepth" value="2"/>
<property name="maximumNumber" value="10"/>
</module>
</source>
<p>Too many returns from within a method:</p>
<source>
<module name="DescendantToken">
<property name="tokens" value="METHOD_DEF"/>
<property name="limitedTokens" value="LITERAL_RETURN"/>
<property name="maximumNumber" value="3"/>
</module>
</source>
<p>Too many fields within an interface:</p>
<source>
<module name="DescendantToken">
<property name="tokens" value="INTERFACE_DEF"/>
<property name="limitedTokens" value="VARIABLE_DEF"/>
<property name="maximumDepth" value="2"/>
<property name="maximumNumber" value="0"/>
</module>
</source>
<p>Limits the number of exceptions a method can throw:</p>
<source>
<module name="DescendantToken">
<property name="tokens" value="LITERAL_THROWS"/>
<property name="limitedTokens" value="IDENT"/>
<property name="maximumNumber" value="1"/>
</module>
</source>
<p>Limits the number of expressions in a method:</p>
<source>
<module name="DescendantToken">
<property name="tokens" value="METHOD_DEF"/>
<property name="limitedTokens" value="EXPR"/>
<property name="maximumNumber" value="200"/>
</module>
</source>
<p>Disallows empty statements:</p>
<source>
<module name="DescendantToken">
<property name="tokens" value="EMPTY_STAT"/>
<property name="limitedTokens" value="EMPTY_STAT"/>
<property name="maximumNumber" value="0"/>
<property name="maximumDepth" value="0"/>
<property name="maximumMessage"
value="Empty statement is not allowed."/>
</module>
</source>
<p>Too many fields within a class:</p>
<source>
<module name="DescendantToken">
<property name="tokens" value="CLASS_DEF"/>
<property name="limitedTokens" value="VARIABLE_DEF"/>
<property name="maximumDepth" value="2"/>
<property name="maximumNumber" value="10"/>
</module>
</source>
</subsection>
<subsection name="Example of Usage" id="DescendantToken_Example_of_Usage">
<ul>
<li>
<a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+DescendantToken">
Checkstyle Style</a>
</li>
</ul>
</subsection>
<subsection name="Error Messages" id="DescendantToken_Error_Messages">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22descendant.token.max%22">
descendant.token.max</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22descendant.token.min%22">
descendant.token.min</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22descendant.token.sum.max%22">
descendant.token.sum.max</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22descendant.token.sum.min%22">
descendant.token.sum.min</a>
</li>
</ul>
<p>
All messages can be customized if the default message doesn't suit you.
Please <a href="config.html#Custom_messages">see the documentation</a> to learn how to.
</p>
</subsection>
<subsection name="Package" id="DescendantToken_Package">
<p>
com.puppycrawl.tools.checkstyle.checks
</p>
</subsection>
<subsection name="Parent Module" id="DescendantToken_Parent_Module">
<p>
<a href="config.html#TreeWalker">TreeWalker</a>
</p>
</subsection>
</section>
<section name="FinalParameters">
<subsection name="Description" id="FinalParameters_Description">
<p>Since Checkstyle 3.0</p>
<p>
Check that parameters for methods, constructors, and catch blocks are
final. Interface, abstract, and native methods are not checked: the final
keyword does not make sense for interface, abstract, and native method
parameters as there is no code that could modify the parameter.
</p>
<p>
Rationale: Changing the value of parameters during the execution of
the method's algorithm can be confusing and should be avoided. A
great way to let the Java compiler prevent this coding style is to
declare parameters final.
</p>
</subsection>
<subsection name="Properties" id="FinalParameters_Properties">
<table>
<tr>
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr>
<td>ignorePrimitiveTypes</td>
<td>ignore primitive types as parameters</td>
<td><a href="property_types.html#boolean">Boolean</a></td>
<td><code>false</code></td>
<td>6.2</td>
</tr>
<tr>
<td>tokens</td>
<td>tokens to check</td>
<td>
subset of tokens
<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">
METHOD_DEF</a>,
<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">
CTOR_DEF</a>,
<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_CATCH">
LITERAL_CATCH</a>,
<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#FOR_EACH_CLAUSE">
FOR_EACH_CLAUSE</a>.
</td>
<td>
<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">
METHOD_DEF</a>,
<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">
CTOR_DEF</a>.
</td>
<td>3.0</td>
</tr>
</table>
</subsection>
<subsection name="Examples" id="FinalParameters_Examples">
<p>
To configure the check to enforce final parameters for methods and
constructors:
</p>
<source>
<module name="FinalParameters"/>
</source>
<p>
To configure the check to enforce final parameters only for
constructors:
</p>
<source>
<module name="FinalParameters">
<property name="tokens" value="CTOR_DEF"/>
</module>
</source>
<p>
To configure the check to allow ignoring
<a href="https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html">
primitive datatypes</a> as parameters:
</p>
<source>
<module name="FinalParameters">
<property name="ignorePrimitiveTypes" value="true"/>
</module>
</source>
</subsection>
<subsection name="Example of Usage" id="FinalParameters_Example_of_Usage">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Asun_checks.xml+repo%3Acheckstyle%2Fcheckstyle+FinalParameters">
Sun Style</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+FinalParameters">
Checkstyle Style</a>
</li>
</ul>
</subsection>
<subsection name="Error Messages" id="FinalParameters_Error_Messages">
<ul>