-
Notifications
You must be signed in to change notification settings - Fork 9
/
config.html
1490 lines (1136 loc) · 50.5 KB
/
config.html
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
<!DOCTYPE html>
<!--
| Generated by Apache Maven Doxia Site Renderer 1.11.1 from src/xdocs/config.xml at 2024-12-28
| Rendered using Apache Maven Default Skin
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="generator" content="Apache Maven Doxia Site Renderer 1.11.1" />
<title>checkstyle – Configuration</title>
<link rel="stylesheet" href="./css/maven-base.css" />
<link rel="stylesheet" href="./css/maven-theme.css" />
<link rel="stylesheet" href="./css/site.css" />
<link rel="stylesheet" href="./css/print.css" media="print" />
<script type="text/javascript" src="./js/checkstyle.js"></script>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="./js/anchors.js"></script>
<script type="text/javascript" src="./js/google-analytics.js"></script>
<link rel="icon" href="./images/favicon.png" type="image/x-icon" />
<link rel="shortcut icon" href="./images/favicon.ico" type="image/ico" />
</head>
<body class="composite">
<div id="banner">
<a href="./" id="bannerLeft" title="Checkstyle"><img src="images/header-checkstyle-logo.png" alt="Checkstyle"/></a><a href="./" id="bannerRight" title="Checkstyle"><img src="images/header-right-ruller.png" alt="Checkstyle"/></a> <div class="clear">
<hr/>
</div>
</div>
<div id="breadcrumbs">
<div class="xright"><a href="" title="toTop">toTop</a> | <span id="publishDate">Last Published: 2024-12-28</span>
| <span id="projectVersion">Version: 10.21.1</span>
</div>
<div class="clear">
<hr/>
</div>
</div>
<div id="leftColumn">
<div id="navcolumn">
<h5>About</h5>
<ul>
<li class="none"><a href="index.html" title="Checkstyle">Checkstyle</a></li>
<li class="none"><a href="releasenotes.html" title="Release Notes">Release Notes</a></li>
<li class="none"><a href="consulting.html" title="Consulting">Consulting</a></li>
<li class="none"><a href="sponsoring.html" title="Sponsoring">Sponsoring</a></li>
</ul>
<h5>Documentation</h5>
<ul>
<li class="expanded"><strong>Configuration</strong>
<ul>
<li class="none"><a href="property_types.html" title="Property Types">Property Types</a></li>
<li class="none"><a href="config_system_properties.html" title="System Properties">System Properties</a></li>
</ul></li>
<li class="expanded"><a href="running.html" title="Running">Running</a>
<ul>
<li class="none"><a href="anttask.html" title="Ant Task">Ant Task</a></li>
<li class="none"><a href="cmdline.html" title="Command Line">Command Line</a></li>
</ul></li>
<li class="expanded"><a href="checks.html" title="Checks">Checks</a>
<ul>
<li class="collapsed"><a href="checks/annotation/index.html" title="Annotations">Annotations</a></li>
<li class="collapsed"><a href="checks/blocks/index.html" title="Block Checks">Block Checks</a></li>
<li class="collapsed"><a href="checks/design/index.html" title="Class Design">Class Design</a></li>
<li class="collapsed"><a href="checks/coding/index.html" title="Coding">Coding</a></li>
<li class="collapsed"><a href="checks/header/index.html" title="Headers">Headers</a></li>
<li class="collapsed"><a href="checks/imports/index.html" title="Imports">Imports</a></li>
<li class="collapsed"><a href="checks/javadoc/index.html" title="Javadoc Comments">Javadoc Comments</a></li>
<li class="collapsed"><a href="checks/metrics/index.html" title="Metrics">Metrics</a></li>
<li class="collapsed"><a href="checks/misc/index.html" title="Miscellaneous">Miscellaneous</a></li>
<li class="collapsed"><a href="checks/modifier/index.html" title="Modifiers">Modifiers</a></li>
<li class="collapsed"><a href="checks/naming/index.html" title="Naming Conventions">Naming Conventions</a></li>
<li class="collapsed"><a href="checks/regexp/index.html" title="Regexp">Regexp</a></li>
<li class="collapsed"><a href="checks/sizes/index.html" title="Size Violations">Size Violations</a></li>
<li class="collapsed"><a href="checks/whitespace/index.html" title="Whitespace">Whitespace</a></li>
</ul></li>
<li class="collapsed"><a href="filters/index.html" title="Filters">Filters</a></li>
<li class="collapsed"><a href="filefilters/index.html" title="File Filters">File Filters</a></li>
<li class="expanded"><a href="style_configs.html" title="Style Configurations">Style Configurations</a>
<ul>
<li class="none"><a href="google_style.html" title="Google's Style">Google's Style</a></li>
<li class="none"><a href="sun_style.html" title="Sun's Style">Sun's Style</a></li>
</ul></li>
</ul>
<h5>Developers</h5>
<ul>
<li class="expanded"><a href="extending.html" title="Extending Checkstyle">Extending Checkstyle</a>
<ul>
<li class="none"><a href="writingchecks.html" title="Writing Checks">Writing Checks</a></li>
<li class="none"><a href="writingjavadocchecks.html" title="Writing Javadoc Checks">Writing Javadoc Checks</a></li>
<li class="none"><a href="writingfilters.html" title="Writing Filters">Writing Filters</a></li>
<li class="none"><a href="writingfilefilters.html" title="Writing File Filters">Writing File Filters</a></li>
<li class="none"><a href="writinglisteners.html" title="Writing Listeners">Writing Listeners</a></li>
</ul></li>
<li class="none"><a href="contributing.html" title="Contributing">Contributing</a></li>
<li class="expanded"><a href="beginning_development.html" title="Beginning Development">Beginning Development</a>
<ul>
<li class="none"><a href="eclipse.html" title="Eclipse IDE">Eclipse IDE</a></li>
<li class="none"><a href="netbeans.html" title="NetBeans IDE">NetBeans IDE</a></li>
<li class="none"><a href="idea.html" title="IntelliJ IDE">IntelliJ IDE</a></li>
</ul></li>
<li class="none"><a href="apidocs/index.html" title="Javadoc">Javadoc</a></li>
</ul>
<h5>Project Documentation</h5>
<ul>
<li class="collapsed"><a href="project-info.html" title="Project Information">Project Information</a></li>
<li class="collapsed"><a href="project-reports.html" title="Project Reports">Project Reports</a></li>
</ul>
<a href="https://github.com/checkstyle/checkstyle" title="GitHub" class="poweredBy">
<img class="poweredBy" alt="GitHub" src="images/github_logo_social_coding_outlined.png" />
</a>
<a href="https://twitter.com/checkstyle_java/" title="Twitter" class="poweredBy">
<img class="poweredBy" alt="Twitter" src="images/twitter_button.png" />
</a>
<a href="https://stackoverflow.com/questions/tagged/checkstyle" title="Stackoverflow" class="poweredBy">
<img class="poweredBy" alt="Stackoverflow" src="images/stackoverflow.jpeg" />
</a>
<a href="https://groups.google.com/forum/#!forum/checkstyle" title="GoogleGroups" class="poweredBy">
<img class="poweredBy" alt="GoogleGroups" src="images/groups.png" />
</a>
<a href="https://www.ej-technologies.com/products/jprofiler/overview.html" title="JProfiler" class="poweredBy">
<img class="poweredBy" alt="JProfiler" src="https://www.ej-technologies.com/images/product_banners/jprofiler_medium.png" />
</a>
</div>
</div>
<div id="bodyColumn">
<div id="contentBox">
<section>
<h2><a name="Content"></a>Content</h2>
<ul>
<li><a href="#Content">Content</a></li>
<li><a href="#Overview">Overview</a></li>
<li><a href="#Modules">Modules</a></li>
<li><a href="#Properties">Properties</a></li>
<li><a href="#Checker">Checker</a></li>
<li><a href="#TreeWalker">TreeWalker</a></li>
<li><a href="#TreeWalker_Checks">TreeWalker Checks</a></li>
<li><a href="#Severity">Severity</a></li>
<li><a href="#tabWidth">tabWidth</a></li>
<li><a href="#Id">Id</a></li>
<li><a href="#Custom_messages">Custom messages</a></li>
<li><a href="#Filters">Filters</a></li>
<li><a href="#Before_Execution_File_Filters">Before Execution File Filters</a></li>
<li><a href="#Audit_Listeners">Audit Listeners</a></li>
<li><a href="#Packages">Packages</a></li>
<li><a href="#Configuration_XML_Structure">Configuration XML Structure</a></li></ul>
</section>
<section>
<h2><a name="Overview"></a>Overview</h2>
<p>
A Checkstyle configuration specifies which <i>modules</i> to
plug in and apply to Java source files. Modules are structured
in a tree whose root is the <i>Checker</i> module. The next
level of modules contains:
</p>
<ul>
<li><i>File Set Checks</i> - modules that take a set of input
files and fire violation messages.</li>
<li><i>Filters</i>
- modules that filter audit events,
including messages, for acceptance.</li>
<li><i>Audit Listeners</i> - modules that report accepted events.</li>
</ul>
<p>
Many checks are submodules of the <i>TreeWalker</i>
File Set Check module. The TreeWalker operates by separately
transforming each of the Java source files into an abstract
syntax tree and then handing the result over to each of its
submodules which in turn have a look at certain aspects of the
tree.
</p>
<p>
Checkstyle obtains a configuration from an XML document whose
elements specify the configuration's hierarchy of modules and
their properties. You provide a file that contains the
configuration document when you invoke Checkstyle at the <a href="cmdline.html">command line</a>, and when you run a <a href="anttask.html">Checkstyle task</a> in ant. The
documentation directory of the Checkstyle distribution contains
a sample configuration file <i>sun_checks.xml</i> which
configures Checkstyle to check for the Sun coding conventions.
</p>
</section>
<section>
<h2><a name="Modules"></a>Modules</h2>
<p>
A <code>module</code> element in the configuration
XML document specifies a module identified by the element's
<code>name</code> attribute.
</p>
<p>
Here is a fragment of a typical configuration document:
</p>
<div class="source">
<pre>
<module name="Checker">
<module name="JavadocPackage"/>
<module name="TreeWalker">
<module name="AvoidStarImport"/>
<module name="ConstantName"/>
<module name="EmptyBlock"/>
</module>
</module>
</pre></div>
<p>
In this configuration:
</p>
<ul>
<li>
Root module <code>Checker</code> has child
FileSetChecks <code>JavadocPackage</code> and <code>TreeWalker</code>. (Module <a href="checks/javadoc/index.html"> <code>JavadocPackage</code></a> checks that all packages
have package documentation.)
</li>
<li>
Module <code>TreeWalker</code> has submodules
<code>AvoidStarImport</code>, <code>ConstantName</code>,
and <code>EmptyBlock</code>. (Modules <a href="checks/imports/index.html"><code>AvoidStarImport</code></a>, <a href="checks/naming/index.html"><code>ConstantName</code></a>, and <a href="checks/blocks/index.html"><code>EmptyBlock</code></a> check that a Java source
file has no star imports, has valid constant names, and has no
empty blocks, respectively.)
</li>
</ul>
<p>
For each configuration module, Checkstyle loads a class
identified by the <code>name</code> attribute of
the <code>module</code>. There are several rules
for loading a module's class:
</p>
<ol style="list-style-type: decimal">
<li>
Load a class directly according to a package-qualified <code>name</code>, such as loading
class <code>com.puppycrawl.tools.checkstyle.TreeWalker</code> for element:
<div class="source">
<pre>
<module name="com.puppycrawl.tools.checkstyle.TreeWalker"/>
</pre></div>
This is useful for plugging third-party modules into a configuration.
</li>
<li>
Load a class of a pre-specified package, such as loading class
<code>com.puppycrawl.tools.checkstyle.checks.AvoidStarImport</code>
for element
<div class="source">
<pre>
<module name="AvoidStarImport"/>
</pre></div>
Checkstyle applies packages <code>
com.puppycrawl.tools.checkstyle</code>, <code>
com.puppycrawl.tools.checkstyle.filters</code>, and
<code>com.puppycrawl.tools.checkstyle.checks</code>
and its sub-packages (only those included in the Checkstyle
distribution). You can specify other packages in a <a href="#Packages"><i>package names XML document</i></a>
when you invoke Checkstyle at the <a href="cmdline.html">command line</a>, and when you run a <a href="anttask.html">Checkstyle task</a> in ant.
</li>
<li>
Apply the above rules to <code>name</code>
concatenated with <code>"Check"</code>,
such as loading class
<code>com.puppycrawl.tools.checkstyle.checks.ConstantNameCheck</code>
for element
<div class="source">
<pre>
<module name="ConstantName"/>
</pre></div>
</li>
</ol>
</section>
<section>
<h2><a name="Properties"></a>Properties</h2>
<p>
Properties of a module control how the module performs its task.
Each module property has a default value, and you are not
required to define a property in the configuration document if
the default value is satisfactory. To assign a non-default
value to a module's property, define a child <code>property</code> element
of the <code>module</code> element in the configuration XML
document. Also provide appropriate <code>name</code> and <code>value</code>
attributes for the <code>property</code> element.
For example, property <code>max</code> of module
<code>MethodLength</code> specifies the maximum
allowable number of lines in a method or constructor, and has
default value <code>150</code>. Here is a
configuration of module <code>MethodLength</code>
so that the check reports methods and constructors with more
than <code>60</code> lines:
</p>
<div class="source">
<pre>
<module name="MethodLength">
<property name="max" value="60"/>
</module>
</pre></div>
<p>
<a href="cmdline.html">Command line</a> properties and ant <a href="anttask.html">Checkstyle task</a> properties apply to the
root <code>Checker</code> module. Also, properties
are inherited in the module hierarchy. These features make it
easy to define one property value that applies to many
modules. For example, the following configuration fragment
specifies that a <code>tabWidth</code> of <code>4</code>
applies to <code>TreeWalker</code> and its submodules:
</p>
<div class="source">
<pre>
<module name="Checker">
<module name="JavadocPackage"/>
<module name="TreeWalker">
<property name="tabWidth" value="4"/>
<module name="AvoidStarImport"/>
<module name="ConstantName"/>
...
</module>
</module>
</pre></div>
<p>
The value of a module property can be specified through
<i>property expansion</i> with the <code>${<i>property_name</i>}</code> notation, where
<code><i>property_name</i></code> is a <a href="cmdline.html">command line</a> property or an ant <a href="anttask.html">Checkstyle task</a> property. For example,
the following configuration document element gives property
<code>headerFile</code> the value of command line
property <code>checkstyle.header.file</code>:
</p>
<div class="source">
<pre>
<module name="Header">
<property name="headerFile" value="${checkstyle.header.file}"/>
</module>
</pre></div>
<p>
You can use property expansion to re-specify a module property
value without changing the configuration document.
</p>
<p>
The property element provides an optional <code>default</code> attribute which is
used when a property in the value cannot be resolved. For example this
configuration snippet from a central configuration file checks
that methods have javadoc, but allows individual projects to
override the severity by specifying their desired value in the
command line property <code>checkstyle.javadoc.severity</code>:
</p>
<div class="source">
<pre>
<module name="JavadocMethod">
<property name="severity"
value="${checkstyle.javadoc.severity}"
default="error"/>
</module>
</pre></div>
<p>
ATTENTION: default value is applied to module property value if at least one expansion
property is not defined.
</p>
<p>
This feature is a great help when setting up a centralized
configuration file (e.g. one file for the whole company) to
lower configuration maintenance costs. Projects that are happy
with the default can simply use that configuration file as is,
but individual projects with special needs have the flexibility
to adjust a few settings to fit their needs without having to
copy and maintain the whole configuration.
</p>
<p>
Apart from the above mentioned properties, there are a few system
properties that changes the way how Checkstyle behaves.
All the system properties can be found at the
<a href="config_system_properties.html">system properties</a> page.
</p>
<p>
You can find information about property types on
<a href="property_types.html">Property Types</a> page.
</p>
</section>
<section>
<h2><a name="Checker"></a>Checker</h2>
<a name="Checker_Description"></a><section id="Checker_Description">
<h3><a name="Description"></a>Description</h3>
<p>Since Checkstyle 3.0</p>
<p>
All configurations have root module <code>Checker</code>. <code>Checker</code>
contains:
</p>
<ul>
<li><i>File Set Check</i> children: modules that check sets of
files.</li>
<li><i>Filter</i> children: modules that filter audit
events.</li>
<li><i>File Filter</i> children: modules that filter files
for Checkstyle to process.</li>
<li><i>Audit Listener</i> children: modules that report
filtered events.</li>
</ul>
<p>
<code>Checker</code> also defines properties that are
inherited by all other modules of a configuration.
</p>
</section>
<a name="Checker_Properties"></a><section id="Checker_Properties">
<h3><a name="Properties"></a>Properties</h3>
<div class="wrapper">
<table border="0" class="bodyTable">
<tr class="a">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr class="b">
<td align="left">basedir</td>
<td>Base directory name; stripped off in messages about files</td>
<td><a href="property_types.html#String">String</a></td>
<td><code>null</code></td>
<td>3.0</td>
</tr>
<tr class="a">
<td align="left">cacheFile</td>
<td>Caches information about files that have checked OK; used
to avoid repeated checks of the same files</td>
<td><a href="property_types.html#File">File</a></td>
<td><code>null</code> (no cache file)</td>
<td>6.16</td>
</tr>
<tr class="b">
<td align="left">charset</td>
<td>Name of the file charset</td>
<td><a href="property_types.html#String">String</a></td>
<td><code>UTF-8</code></td>
<td>5.0</td>
</tr>
<tr class="a">
<td align="left">fileExtensions</td>
<td>File extensions that are accepted</td>
<td><a href="property_types.html#String.5B.5D">String[]</a></td>
<td><code>all files</code></td>
<td>6.3</td>
</tr>
<tr class="b">
<td align="left">haltOnException</td>
<td>Whether to stop execution of Checkstyle if a single file produces any kind of
exception during verification</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><code>true</code></td>
<td>7.4</td>
</tr>
<tr class="a">
<td align="left">localeCountry</td>
<td>Locale country for messages</td>
<td><a href="property_types.html#String">String</a> (either
the empty string or an uppercase ISO 3166 2-letter code)</td>
<td>default locale country for the Java Virtual Machine</td>
<td>3.0</td>
</tr>
<tr class="b">
<td align="left">localeLanguage</td>
<td>Locale language for messages</td>
<td><a href="property_types.html#String">String</a> (either
the empty string or a lowercase ISO 639 code)</td>
<td>default locale language for the Java Virtual Machine</td>
<td>3.0</td>
</tr>
<tr class="a">
<td align="left">severity</td>
<td>The default severity level of all violations</td>
<td><a href="property_types.html#SeverityLevel">SeverityLevel</a></td>
<td><code>error</code></td>
<td>3.1</td>
</tr>
<tr class="b">
<td align="left">tabWidth</td>
<td>Number of expanded spaces for a tab character (<code>'\t'</code>); used in
messages and Checks that print violations on files with tabs</td>
<td><a href="property_types.html#int">int</a></td>
<td><code>8</code></td>
<td>8.19</td>
</tr>
</table>
</div>
</section>
<a name="Checker_Metadata"></a><section id="Checker_Metadata">
<h3><a name="Metadata"></a>Metadata</h3>
<p>
This tag is used to keep metadata in the Checkstyle configuration file.
This information is ignored by Checkstyle. This may be useful if you want
to store plug-in specific information or any other information in the config
file.
</p>
<p>
To avoid name clashes between different tools/plug-ins you are <b>strongly</b>
encouraged to prefix all names with your domain name. For example, use the
name "com.mycompany.parameter" instead of "parameter".
<br />
Prefixes
<code>com.puppycrawl.</code>,
<code>net.sourceforge.checkstyle.</code>,
<code>org.checkstyle.</code>
are reserved for Checkstyle.
<br />
Example:
</p>
<div class="source">
<pre>
<module name="Checker">
<metadata name="com.myproject.cs-version" value="4.4"/>
<metadata name="com.myproject.cs-version.desc" value="legacy config"/>
...
</module>
</pre></div>
</section>
<a name="Checker_Examples"></a><section id="Checker_Examples">
<h3><a name="Examples"></a>Examples</h3>
<p>
For example, the following configuration fragment specifies base
directory <code>src/checkstyle</code>, cache file <code>target/cachefile</code> and German
locale for all modules:
</p>
<div class="source">
<pre>
<module name="Checker">
<property name="basedir" value="src/checkstyle"/>
<property name="cacheFile" value="target/cachefile"/>
<property name="localeCountry" value="DE"/>
<property name="localeLanguage" value="de"/>
<module name="JavadocPackage"/>
<module name="TreeWalker">
...
</module>
</module>
</pre></div>
<p>
To configure a <code>Checker</code> so that it
handles files with the <code>ISO-8859-5</code> charset:
</p>
<div class="source">
<pre>
<module name="Checker">
<property name="charset" value="ISO-8859-5"/>
...
</module>
</pre></div>
<p>
To configure a <code>Checker</code> so that it
handles files with the <code>java, xml, properties</code> extensions:
</p>
<div class="source">
<pre>
<module name="Checker">
<property name="fileExtensions" value="java, xml, properties"/>
...
</module>
</pre></div>
<p>
To configure a <code>Checker</code> so that it doesn't stop execution on an
<code>Exception</code> and instead prints it as a violation:
</p>
<div class="source">
<pre>
<module name="Checker">
<property name="haltOnException" value="false"/>
...
</module>
</pre></div>
<p>
To configure a <code>Checker</code> so that it
handles files with any extension:
</p>
<div class="source">
<pre>
<module name="Checker">
<property name="fileExtensions" value="null"/>
...
</module>
</pre></div>
<p>OR</p>
<div class="source">
<pre>
<module name="Checker">
<property name="fileExtensions" value=""/>
...
</module>
</pre></div>
</section>
<a name="Checker_Example_of_Usage"></a><section id="Checker_Example_of_Usage">
<h3><a name="Example_of_Usage"></a>Example of Usage</h3>
<ul>
<li>
<a class="externalLink" href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%20path%3A**%2Fgoogle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+Checker">
Google Style</a>
</li>
<li>
<a class="externalLink" href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%20path%3A**%2Fsun_checks.xml+repo%3Acheckstyle%2Fcheckstyle+Checker">
Sun Style</a>
</li>
<li>
<a class="externalLink" href="https://github.com/search?q=path%3Aconfig%20path%3A**%2Fcheckstyle-checks.xml+repo%3Acheckstyle%2Fcheckstyle+Checker">
Checkstyle Style</a>
</li>
</ul>
</section>
<a name="Checker_Package"></a><section id="Checker_Package">
<h3><a name="Package"></a>Package</h3>
<p> com.puppycrawl.tools.checkstyle </p>
</section>
</section>
<section>
<h2><a name="TreeWalker"></a>TreeWalker</h2>
<a name="TreeWalker_Description"></a><section id="TreeWalker_Description">
<h3><a name="Description"></a>Description</h3>
<p>Since Checkstyle 3.0</p>
<p>
File Set Check <code>TreeWalker</code> checks
individual Java source files and defines properties that are
applicable to checking such files.
</p>
</section>
<a name="TreeWalker_Properties"></a><section id="TreeWalker_Properties">
<h3><a name="Properties"></a>Properties</h3>
<div class="wrapper">
<table border="0" class="bodyTable">
<tr class="a">
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr class="b">
<td align="left">fileExtensions</td>
<td>File type extension to identify Java files. Setting this
property is typically only required if your Java source code
is preprocessed before compilation and the original files do
not have the extension <code>.java</code></td>
<td><a href="property_types.html#String.5B.5D">String[]</a></td>
<td><code>.java</code></td>
<td>3.0</td>
</tr>
<tr class="a">
<td align="left">javaParseExceptionSeverity</td>
<td>Specify severity level to log Java parsing exceptions when they are skipped.</td>
<td><a href="property_types.html#SeverityLevel">SeverityLevel</a></td>
<td><code>error</code></td>
<td>10.18.0</td>
</tr>
<tr class="b">
<td align="left">skipFileOnJavaParseException</td>
<td>Control whether to skip files with Java parsing exceptions.</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><code>false</code></td>
<td>10.18.0</td>
</tr>
</table>
</div>
</section>
<a name="TreeWalker_Examples"></a><section id="TreeWalker_Examples">
<h3><a name="Examples"></a>Examples</h3>
<p>
For example, the following configuration fragment specifies
<code>TreeWalker</code> a <code>tabWidth</code> of <code>4</code>:
</p>
<div class="source">
<pre>
<module name="Checker">
<module name="TreeWalker">
<property name="tabWidth" value="4"/>
...
</module>
</module>
</pre></div>
<p>
To integrate Checkstyle with BEA Weblogic Workshop 8.1:
</p>
<div class="source">
<pre>
<module name="Checker">
<module name="TreeWalker">
<property name="fileExtensions" value="java,ejb,jpf"/>
...
</module>
</module>
</pre></div>
<p>
To configure <code>TreeWalker</code> so that it
handles files with the <code>java</code> extension:
</p>
<div class="source">
<pre>
<module name="TreeWalker">
<property name="fileExtensions" value="java"/>
...
</module>
</pre></div>
<p>
To configure <code>TreeWalker</code> so that it
handles files with any extension:
</p>
<div class="source">
<pre>
<module name="TreeWalker">
<property name="fileExtensions" value="null"/>
...
</module>
</pre></div>
<p>OR</p>
<div class="source">
<pre>
<module name="TreeWalker">
<property name="fileExtensions" value=""/>
...
</module>
</pre></div>
<p>
By default, <code>skipFileOnJavaParseException</code> is set to false.
In this case, when using new Java features that are not yet supported by Checkstyle,
Checkstyle will fail to parse them, log parsing exceptions, and may halt processing,
failing to analyze other files.
</p>
<p>
To configure <code>TreeWalker</code> so that it skips files with java parsing exceptions,
preventing execution from stopping on an exception and instead
printing it as a violation:
</p>
<div class="source">
<pre>
<module name="TreeWalker">
<property name="skipFileOnJavaParseException" value="true"/>
...
</module>
</pre></div>
<p>
To configure <code>TreeWalker</code> so that it
skips files with java parsing exceptions,
preventing execution from stopping on an exception and does not
print it as a violation:
</p>
<div class="source">
<pre>
<module name="TreeWalker">
<property name="skipFileOnJavaParseException" value="true"/>
<property name="javaParseExceptionSeverity" value="ignore"/>
...
</module>
</pre></div>
</section>
<a name="TreeWalker_Example_of_Usage"></a><section id="TreeWalker_Example_of_Usage">
<h3><a name="Example_of_Usage"></a>Example of Usage</h3>
<ul>
<li>
<a class="externalLink" href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%20path%3A**%2Fgoogle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+TreeWalker">
Google Style</a>
</li>
<li>
<a class="externalLink" href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%20path%3A**%2Fsun_checks.xml+repo%3Acheckstyle%2Fcheckstyle+TreeWalker">
Sun Style</a>
</li>
<li>
<a class="externalLink" href="https://github.com/search?q=path%3Aconfig%20path%3A**%2Fcheckstyle-checks.xml+repo%3Acheckstyle%2Fcheckstyle+TreeWalker">
Checkstyle Style</a>
</li>
</ul>
</section>