forked from checkstyle/checkstyle
/
config_naming.xml
3259 lines (3087 loc) · 123 KB
/
config_naming.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 https://maven.apache.org/xsd/xdoc-2.0.xsd">
<head>
<title>Naming Conventions</title>
</head>
<body>
<section name="Content">
<macro name="toc">
<param name="fromDepth" value="1"/>
<param name="toDepth" value="1"/>
</macro>
</section>
<section name="Overview">
<p>
Each of these naming modules validates identifiers for particular code
elements. Valid identifiers for a naming module are specified by its
<code> format</code> property. The value of <code>format</code> is a <a
href="https://docs.oracle.com/javase/1.5.0/docs/api/java/util/regex/Pattern.html">
pattern</a> for valid identifiers.
</p>
</section>
<section name="AbbreviationAsWordInName">
<p>Since Checkstyle 5.8</p>
<subsection name="Description" id="AbbreviationAsWordInName_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>'_' is considered as word separator in identifier name.</p>
<p>
<code>allowedAbbreviationLength</code> specifies how many consecutive capital letters are
allowed 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 be
allowed, but 'MyTESTS' would not be.
A value of <i>0</i> indicates that only 1 consecutive capital letter is allowed. This
is what should be used to enforce strict camel casing. The identifier 'MyTest' would
be 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>
</subsection>
<subsection name="Properties" id="AbbreviationAsWordInName_Properties">
<div class="wrapper">
<table>
<tr>
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr>
<td>allowedAbbreviationLength</td>
<td>Indicate the number of consecutive capital letters allowed in targeted
identifiers (abbreviations in the classes, interfaces, variables and methods
names, ... ).</td>
<td><a href="property_types.html#int">int</a></td>
<td><code>3</code></td>
<td>5.8</td>
</tr>
<tr>
<td>allowedAbbreviations</td>
<td>Specify abbreviations that must be skipped for checking.</td>
<td><a href="property_types.html#String.5B.5D">String[]</a></td>
<td><code>{}</code></td>
<td>5.8</td>
</tr>
<tr>
<td>ignoreFinal</td>
<td>Allow to skip variables with <code>final</code> modifier.</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><code>true</code></td>
<td>5.8</td>
</tr>
<tr>
<td>ignoreStatic</td>
<td>Allow to skip variables with <code>static</code> modifier.</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><code>true</code></td>
<td>5.8</td>
</tr>
<tr>
<td>ignoreStaticFinal</td>
<td>Allow to skip variables with both <code>static</code>
and <code>final</code> modifiers.</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><code>true</code></td>
<td>8.32</td>
</tr>
<tr>
<td>ignoreOverriddenMethods</td>
<td>Allow to ignore methods tagged with <code>@Override</code> annotation
(that usually mean inherited name).</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><code>true</code></td>
<td>5.8</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#CLASS_DEF">
CLASS_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INTERFACE_DEF">
INTERFACE_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ENUM_DEF">
ENUM_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ANNOTATION_DEF">
ANNOTATION_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ANNOTATION_FIELD_DEF">
ANNOTATION_FIELD_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#PARAMETER_DEF">
PARAMETER_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#VARIABLE_DEF">
VARIABLE_DEF</a>
, <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#ENUM_CONSTANT_DEF">
ENUM_CONSTANT_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#PATTERN_VARIABLE_DEF">
PATTERN_VARIABLE_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#RECORD_DEF">
RECORD_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#RECORD_COMPONENT_DEF">
RECORD_COMPONENT_DEF</a>
.
</td>
<td>
<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CLASS_DEF">
CLASS_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INTERFACE_DEF">
INTERFACE_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ENUM_DEF">
ENUM_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ANNOTATION_DEF">
ANNOTATION_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ANNOTATION_FIELD_DEF">
ANNOTATION_FIELD_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#PARAMETER_DEF">
PARAMETER_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#VARIABLE_DEF">
VARIABLE_DEF</a>
, <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#PATTERN_VARIABLE_DEF">
PATTERN_VARIABLE_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#RECORD_DEF">
RECORD_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#RECORD_COMPONENT_DEF">
RECORD_COMPONENT_DEF</a>
.
</td>
<td>5.8</td>
</tr>
</table>
</div>
</subsection>
<subsection name="Examples" id="AbbreviationAsWordInName_Examples">
<p>To configure the check:</p>
<source>
<module name="AbbreviationAsWordInName"/>
</source>
<p>Example:</p>
<source>
public class MyClass extends SuperClass { // OK, camel case
int CURRENT_COUNTER; // violation, at most 4 consecutive capital letters allowed
static int GLOBAL_COUNTER; // OK, static is ignored
final Set<String> stringsFOUND = new HashSet<>(); // OK, final is ignored
@Override
void printCOUNTER() { // OK, overridden method is ignored
System.out.println(CURRENT_COUNTER); // OK, only definitions are checked
}
void incrementCOUNTER() { // violation, at most 4 consecutive capital letters allowed
CURRENT_COUNTER++; // OK, only definitions are checked
}
static void incrementGLOBAL() { // violation, static method is not ignored
GLOBAL_COUNTER++; // OK, only definitions are checked
}
}
</source>
<p>
To configure to include static variables and
methods tagged with <code>@Override</code> annotation.
</p>
<p>Configuration:</p>
<source>
<module name="AbbreviationAsWordInName">
<property name="ignoreStatic" value="false"/>
<property name="ignoreOverriddenMethods" value="false"/>
</module>
</source>
<p>Example:</p>
<source>
public class MyClass extends SuperClass { // OK, camel case
int CURRENT_COUNTER; // violation, at most 4 consecutive capital letters allowed
static int GLOBAL_COUNTER; // violation, static is not ignored
final Set<String> stringsFOUND = new HashSet<>(); // OK, final is ignored
@Override
void printCOUNTER() { // violation, overridden method is not ignored
System.out.println(CURRENT_COUNTER); // OK, only definitions are checked
}
void incrementCOUNTER() { // violation, at most 4 consecutive capital letters allowed
CURRENT_COUNTER++; // OK, only definitions are checked
}
static void incrementGLOBAL() { // violation, at most 4 consecutive capital letters allowed
GLOBAL_COUNTER++; // OK, only definitions are checked
}
}
</source>
<p>
To configure to check all variables and identifiers
(including ones with the static modifier) and enforce
no abbreviations (essentially camel case) except for
words like 'XML' and 'URL'.
</p>
<p>Configuration:</p>
<source>
<module name="AbbreviationAsWordInName">
<property name="tokens" value="VARIABLE_DEF,CLASS_DEF"/>
<property name="ignoreStatic" value="false"/>
<property name="allowedAbbreviationLength" value="0"/>
<property name="allowedAbbreviations" value="XML,URL,O"/>
</module>
</source>
<p>Example:</p>
<source>
public class MyClass { // OK
int firstNum; // OK
int secondNUM; // violation, it allowed only 1 consecutive capital letter
static int thirdNum; // OK, the static modifier would be checked
static int fourthNUm; // violation, the static modifier would be checked,
// and only 1 consecutive capital letter is allowed
String firstXML; // OK, XML abbreviation is allowed
String firstURL; // OK, URL abbreviation is allowed
final int TOTAL = 5; // OK, final is ignored
static final int LIMIT = 10; // OK, static final is ignored
void newOAuth2Client() {} // OK, O abbreviation is allowed
void OAuth2() {} // OK, O abbreviation is allowed
void OAUth2() {} // violation, OA abbreviation is not allowed
// split occurs as 'OA', 'Uth2'
}
</source>
<p>
To configure to check variables, excluding fields with
the static modifier, and allow abbreviations up to 2
consecutive capital letters ignoring the longer word 'CSV'.
</p>
<p>Configuration:</p>
<source>
<module name="AbbreviationAsWordInName">
<property name="tokens" value="VARIABLE_DEF"/>
<property name="ignoreStatic" value="true"/>
<property name="allowedAbbreviationLength" value="1"/>
<property name="allowedAbbreviations" value="CSV"/>
</module>
</source>
<p>Example:</p>
<source>
public class MyClass { // OK, ignore checking the class name
int firstNum; // OK, abbreviation "N" is of allowed length 1
int secondNUm; // OK
int secondMYNum; // violation, found "MYN" but only
// 2 consecutive capital letters are allowed
int thirdNUM; // violation, found "NUM" but it is allowed
// only 2 consecutive capital letters
static int fourthNUM; // OK, variables with static modifier
// would be ignored
String firstCSV; // OK, CSV abbreviation is allowed
String firstXML; // violation, XML abbreviation is not allowed
final int TOTAL = 5; // OK, final is ignored
static final int LIMIT = 10; // OK, static final is ignored
}
</source>
<p>
To configure to check variables, enforcing no abbreviations
except for variables that are both static and final.
</p>
<p>Configuration:</p>
<source>
<module name="AbbreviationAsWordInName">
<property name="tokens" value="VARIABLE_DEF"/>
<property name="ignoreFinal" value="false"/>
<property name="ignoreStatic" value="false"/>
<property name="ignoreStaticFinal" value="true"/>
<property name="allowedAbbreviationLength" value="0"/>
</module>
</source>
<p>Example:</p>
<source>
public class MyClass {
public int counterXYZ = 1; // violation
public final int customerID = 2; // violation
public static int nextID = 3; // violation
public static final int MAX_ALLOWED = 4; // OK, ignored
}
</source>
<p>
To configure to check variables, enforcing no abbreviations
and ignoring static (but non-final) variables only.
</p>
<p>Configuration:</p>
<source>
<module name="AbbreviationAsWordInName">
<property name="tokens" value="VARIABLE_DEF"/>
<property name="ignoreFinal" value="false"/>
<property name="ignoreStatic" value="true"/>
<property name="ignoreStaticFinal" value="false"/>
<property name="allowedAbbreviationLength" value="0"/>
</module>
</source>
<p>Example:</p>
<source>
public class MyClass {
public int counterXYZ = 1; // violation
public final int customerID = 2; // violation
public static int nextID = 3; // OK, ignored
public static final int MAX_ALLOWED = 4; // violation
}
</source>
<p>
To configure to check variables, enforce
no abbreviations (essentially camel case) except for
words like 'ORDER', 'TEST'.
</p>
<p>Configuration:</p>
<source>
<module name="AbbreviationAsWordInName">
<property name="allowedAbbreviations" value="ORDER, TEST"/>
</module>
</source>
<p>Example:</p>
<source>
public class Test {
void getORDER_TEST() {} // OK, both abbreviations are allowed
}
</source>
</subsection>
<subsection name="Example of Usage" id="AbbreviationAsWordInName_Example_of_Usage">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Agoogle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+AbbreviationAsWordInName">
Google Style</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+AbbreviationAsWordInName">
Checkstyle Style</a>
</li>
</ul>
</subsection>
<subsection name="Violation Messages" id="AbbreviationAsWordInName_Violation_Messages">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fnaming+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22abbreviation.as.word%22">
abbreviation.as.word</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="AbbreviationAsWordInName_Package">
<p> com.puppycrawl.tools.checkstyle.checks.naming </p>
</subsection>
<subsection name="Parent Module" id="AbbreviationAsWordInName_Parent_Module">
<p> <a href="config.html#TreeWalker">TreeWalker</a> </p>
</subsection>
</section>
<section name="AbstractClassName">
<p>Since Checkstyle 3.2</p>
<subsection name="Description" id="AbstractClassName_Description">
<p>
Ensures that the names of abstract classes conforming to some pattern and
check that <code>abstract</code> modifier exists.
</p>
<p>
Rationale: Abstract classes are convenience base class implementations of
interfaces, 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 that
they will have abstract modifier.
</p>
</subsection>
<subsection name="Properties" id="AbstractClassName_Properties">
<div class="wrapper">
<table>
<tr>
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr>
<td>format</td>
<td>Specify valid identifiers.</td>
<td><a href="property_types.html#Pattern">Pattern</a></td>
<td><code>"^Abstract.+$"</code></td>
<td>3.2</td>
</tr>
<tr>
<td>ignoreModifier</td>
<td>
Control whether to ignore checking for the
<code>abstract</code> modifier on classes that match the
name.
</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><code>false</code></td>
<td>5.3</td>
</tr>
<tr>
<td>ignoreName</td>
<td>
Control whether to ignore checking the name. Realistically
only useful if using the check to identify that match name
and do not have the <code>abstract</code> modifier.
</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><code>false</code></td>
<td>5.3</td>
</tr>
</table>
</div>
</subsection>
<subsection name="Examples" id="AbstractClassName_Examples">
<p>
To configure the check:
</p>
<source>
<module name="AbstractClassName"/>
</source>
<p>Example:</p>
<source>
abstract class AbstractFirstClass {} // OK
abstract class SecondClass {} // violation, it should match pattern "^Abstract.+$"
class AbstractThirdClass {} // violation, must be declared 'abstract'
class FourthClass {} // OK
</source>
<p>
To configure the check so that it check name
but ignore <code>abstract</code> modifier:
</p>
<source>
<module name="AbstractClassName">
<property name="ignoreModifier" value="true"/>
</module>
</source>
<p>Example:</p>
<source>
abstract class AbstractFirstClass {} // OK
abstract class SecondClass {} // violation, it should match pattern "^Abstract.+$"
class AbstractThirdClass {} // OK, no "abstract" modifier
class FourthClass {} // OK
</source>
<p>
To configure the check to ignore name
validation when class declared as 'abstract'
</p>
<source>
<module name="AbstractClassName">
<property name="ignoreName" value="true"/>
</module>
</source>
<p>Example:</p>
<source>
abstract class AbstractFirstClass {} // OK
abstract class SecondClass {} // OK, name validation is ignored
class AbstractThirdClass {} // violation, must be declared as 'abstract'
class FourthClass {} // OK, no "abstract" modifier
</source>
<p>
To configure the check
with <code>format</code>:
</p>
<source>
<module name="AbstractClassName">
<property name="format" value="^Generator.+$"/>
</module>
</source>
<p>Example:</p>
<source>
abstract class GeneratorFirstClass {} // OK
abstract class SecondClass {} // violation, must match pattern '^Generator.+$'
class GeneratorThirdClass {} // violation, must be declared 'abstract'
class FourthClass {} // OK, no "abstract" modifier
</source>
</subsection>
<subsection name="Example of Usage" id="AbstractClassName_Example_of_Usage">
<ul>
<li>
<a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+AbstractClassName">
Checkstyle Style</a>
</li>
</ul>
</subsection>
<subsection name="Violation Messages" id="AbstractClassName_Violation_Messages">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fnaming+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22illegal.abstract.class.name%22">
illegal.abstract.class.name</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fnaming+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22no.abstract.class.modifier%22">
no.abstract.class.modifier</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="AbstractClassName_Package">
<p> com.puppycrawl.tools.checkstyle.checks.naming </p>
</subsection>
<subsection name="Parent Module" id="AbstractClassName_Parent_Module">
<p> <a href="config.html#TreeWalker">TreeWalker</a> </p>
</subsection>
</section>
<section name="CatchParameterName">
<p>Since Checkstyle 6.14</p>
<subsection name="Description" id="CatchParameterName_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 uppercase
or 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>
</subsection>
<subsection name="Properties" id="CatchParameterName_Properties">
<div class="wrapper">
<table>
<tr>
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr>
<td>format</td>
<td>Specifies valid identifiers.</td>
<td><a href="property_types.html#Pattern">Pattern</a></td>
<td>
<code>"^(e|t|ex|[a-z][a-z][a-zA-Z]+)$"</code>
</td>
<td>6.14</td>
</tr>
</table>
</div>
</subsection>
<subsection name="Examples" id="CatchParameterName_Examples">
<p>
To configure the check:
</p>
<source>
<module name="CatchParameterName"/>
</source>
<p>Example:
</p>
<source>
public class MyTest {
public void myTest() {
try {
// ...
} catch (ArithmeticException e) { // OK
// ...
} catch (ArrayIndexOutOfBoundsException ex) { // OK
// ...
} catch (Throwable t) { // OK
// ...
} catch (IndexOutOfBoundsException e123) { // violation, digits
// not allowed
// ...
} catch (NullPointerException ab) { // violation, should have at least
// three characters if not e|t|ex
// ...
} catch (ArrayStoreException abc) { // OK
// ...
} catch (InterruptedException aBC) { // violation, first two characters
// should be in lowercase
// ...
} catch (RuntimeException abC) { // OK
// ...
} catch (Exception abCD) { // OK
// ...
}
}
}
</source>
<p>
An example of how to configure the check for names that begin with
a lower case letter, followed by any letters or digits is:
</p>
<p>Configuration:</p>
<source>
<module name="CatchParameterName">
<property name="format" value="^[a-z][a-zA-Z0-9]+$"/>
</module>
</source>
<p>Example:</p>
<source>
public class MyTest {
public void myTest() {
try {
// ...
} catch (ArithmeticException ex) { // OK
// ...
} catch (ArrayIndexOutOfBoundsException ex2) { // OK
// ...
} catch (IOException thirdException) { // OK
// ...
} catch (Exception FourthException) { // violation, the initial letter
// should be lowercase
// ...
}
}
}
</source>
</subsection>
<subsection name="Example of Usage" id="CatchParameterName_Example_of_Usage">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Agoogle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+CatchParameterName">
Google Style
</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+CatchParameterName">
Checkstyle Style
</a>
</li>
</ul>
</subsection>
<subsection name="Violation Messages" id="CatchParameterName_Violation_Messages">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fnaming+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22name.invalidPattern%22">
name.invalidPattern</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="CatchParameterName_Package">
<p>com.puppycrawl.tools.checkstyle.checks.naming</p>
</subsection>
<subsection name="Parent Module" id="CatchParameterName_Parent_Module">
<p>
<a href="config.html#TreeWalker">TreeWalker</a>
</p>
</subsection>
</section>
<section name="ClassTypeParameterName">
<p>Since Checkstyle 5.0</p>
<subsection name="Description" id="ClassTypeParameterName_Description">
<p>Checks that class type parameter names conform to a specified pattern.</p>
</subsection>
<subsection name="Properties" id="ClassTypeParameterName_Properties">
<div class="wrapper">
<table>
<tr>
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr>
<td>format</td>
<td>Specifies valid identifiers.</td>
<td><a href="property_types.html#Pattern">Pattern</a></td>
<td><code>"^[A-Z]$"</code></td>
<td>5.0</td>
</tr>
</table>
</div>
</subsection>
<subsection name="Examples" id="ClassTypeParameterName_Examples">
<p>
To configure the check:
</p>
<source>
<module name="ClassTypeParameterName"/>
</source>
<p>Example:</p>
<source>
class MyClass1<T> {} // OK
class MyClass2<t> {} // violation
class MyClass3<abc> {} // violation
class MyClass4<LISTENER> {} // violation
class MyClass5<RequestT> {} // violation
</source>
<p>
To configure the check for names that are uppercase word:
</p>
<source>
<module name="ClassTypeParameterName">
<property name="format" value="^[A-Z]{2,}$"/>
</module>
</source>
<p>Example:</p>
<source>
class MyClass1<T> {} // violation
class MyClass2<t> {} // violation
class MyClass3<abc> {} // violation
class MyClass4<LISTENER> {} // OK
class MyClass5<RequestT> {} // violation
</source>
<p>
To configure the check for names that are camel case word with T as suffix
(<a href="https://checkstyle.org/styleguides/google-java-style-20180523/javaguide.html#s5.2.8-type-variable-names">Google Style</a>):
</p>
<source>
<module name="ClassTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
</module>
</source>
<p>Example:</p>
<source>
class MyClass1<T> {} // violation
class MyClass2<t> {} // violation
class MyClass3<abc> {} // violation
class MyClass4<LISTENER> {} // violation
class MyClass5<RequestT> {} // OK
</source>
</subsection>
<subsection name="Example of Usage" id="ClassTypeParameterName_Example_of_Usage">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Agoogle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+ClassTypeParameterName">
Google Style</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+ClassTypeParameterName">
Checkstyle Style</a>
</li>
</ul>
</subsection>
<subsection name="Violation Messages" id="ClassTypeParameterName_Violation_Messages">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fnaming+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22name.invalidPattern%22">
name.invalidPattern</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="ClassTypeParameterName_Package">
<p> com.puppycrawl.tools.checkstyle.checks.naming </p>
</subsection>
<subsection name="Parent Module" id="ClassTypeParameterName_Parent_Module">
<p> <a href="config.html#TreeWalker">TreeWalker</a> </p>
</subsection>
</section>
<section name="ConstantName">
<p>Since Checkstyle 3.0</p>
<subsection name="Description" id="ConstantName_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 an
interface/annotation field, except <strong>serialVersionUID</strong> and
<strong>serialPersistentFields</strong>.
</p>
</subsection>
<subsection name="Properties" id="ConstantName_Properties">
<div class="wrapper">
<table>
<tr>
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr>
<td>format</td>
<td>Specifies valid identifiers.</td>
<td><a href="property_types.html#Pattern">Pattern</a></td>
<td><code>"^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"</code></td>
<td>3.0</td>
</tr>
<tr>
<td>applyToPublic</td>
<td>Controls whether to apply the check to public member.</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><code>true</code></td>
<td>5.0</td>
</tr>
<tr>
<td>applyToProtected</td>
<td>Controls whether to apply the check to protected member.</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><code>true</code></td>
<td>5.0</td>
</tr>
<tr>
<td>applyToPackage</td>
<td>
Controls whether to apply the check to package-private member.
</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><code>true</code></td>
<td>5.0</td>
</tr>
<tr>
<td>applyToPrivate</td>
<td>Controls whether to apply the check to private member.</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><code>true</code></td>
<td>5.0</td>
</tr>
</table>
</div>
</subsection>
<subsection name="Examples" id="ConstantName_Examples">
<p>
To configure the check:
</p>
<source>
<module name="ConstantName"/>
</source>
<p>Example:</p>
<source>
class MyClass {
public final static int FIRST_CONSTANT1 = 10; // OK
protected final static int SECOND_CONSTANT2 = 100; // OK
final static int third_Constant3 = 1000; // violation, name 'third_Constant3' must
// match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
private final static int fourth_Const4 = 50; // violation, name 'fourth_Const4' must match
// pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
}
</source>
<p>
The following configuration apart from names allowed by default allows <code>log</code>
or <code>logger</code>:
</p>
<source>
<module name="ConstantName">
<property name="format"
value="^log(ger)?$|^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
</module>
</source>
<p>Code Example:</p>
<source>
class MyClass {
final static int log = 10; // OK
final static int logger = 50; // OK
final static int logMYSELF = 10; // violation, name 'logMYSELF' must match
// pattern '^log(ger)?$|^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
final static int loggerMYSELF = 5; // violation, name 'loggerMYSELF' must match
// pattern '^log(ger)?$|^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
final static int MYSELF = 100; // OK
final static int myselfConstant = 1; // violation, name 'myselfConstant' must match pattern
// '^log(ger)?$|^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
}
</source>
<p>
The following configuration skip validation on
public constant field and protected constant field.
</p>
<source>
<module name="ConstantName">
<property name="applyToPublic" value="false"/>
<property name="applyToProtected" value="false"/>
</module>
</source>
<p>Code Example:</p>
<source>
class MyClass {
public final static int firstConstant = 10; // OK
protected final static int secondConstant = 100; // OK
final static int thirdConstant = 1000; // violation, name 'thirdConstant' must
// match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
private final static int fourthConstant = 50; // violation, name 'fourthConstant' must match
// pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
}
</source>
</subsection>
<subsection name="Example of Usage" id="ConstantName_Example_of_Usage">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Asun_checks.xml+repo%3Acheckstyle%2Fcheckstyle+ConstantName">
Sun Style</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+ConstantName">
Checkstyle Style</a>
</li>
</ul>
</subsection>
<subsection name="Violation Messages" id="ConstantName_Violation_Messages">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fnaming+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22name.invalidPattern%22">
name.invalidPattern</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="ConstantName_Package">
<p> com.puppycrawl.tools.checkstyle.checks.naming </p>
</subsection>
<subsection name="Parent Module" id="ConstantName_Parent_Module">
<p> <a href="config.html#TreeWalker">TreeWalker</a> </p>
</subsection>
</section>
<section name="IllegalIdentifierName">
<p>Since Checkstyle 8.36</p>
<subsection name="Description" id="IllegalIdentifierName_Description">
<p>
Checks identifiers with a pattern for a set of illegal names, such as those
that 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 a