-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
config_system_properties.xml
161 lines (148 loc) · 5.68 KB
/
config_system_properties.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
<?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>Reporting Configuration</title>
</head>
<body>
<section name="Content">
<macro name="toc">
<param name="fromDepth" value="1"/>
<param name="toDepth" value="1"/>
</macro>
</section>
<section name="Localization Support">
<p>
Checkstyle supports localization of the output messages.
If your language is not supported, please consider
translating the messages in the <code>messages.properties</code> file. Please let us
know if you translate the file.
</p>
</section>
<section name="Enable External DTD load">
<p>
The property <code>checkstyle.enableExternalDtdLoad</code>
defines ability use custom DTD files in config and load them from some location.
The property type
is <a href="property_types.html#boolean">boolean</a> and defaults
to <code>false</code>. Disabled by default due to security concerns.
</p>
<subsection name="Examples" id="Enable_External_DTD_load_Examples">
<p>
The following is an example of include xml files content in xml by ENTITY feature
to let keep common part of configs in single file and composite main config
by few smaller parts.
<br/>
Imagine we want to define for test sources a bit different requirements
than for main code.
</p>
<p>
Common part <code>checkstyle-common.xml</code>:
<source>
<module name="FileLength">
<property name="max" value="1"/>
</module>
</source>
</p>
<p>
Main config <code>checkstyle.xml</code>:
<source>
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd" [
<!ENTITY common SYSTEM "checkstyle-common.xml">
]>
<module name="Checker">
&common;
<module name="TreeWalker">
<module name="MemberName">
<property name="format" value="^[a-z][a-zA-Z]+$"/>
</module>
</module>
</module>
</source>
</p>
<p>
Test config <code>checkstyle-test.xml</code>:
<source>
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd" [
<!ENTITY common SYSTEM "checkstyle-common.xml">
]>
<module name="Checker">
&common;
<module name="TreeWalker">
<module name="MemberName">
<property name="format" value="_[a-z]"/>
</module>
</module>
</module>
</source>
</p>
<p>
Target file for validation <code>Test.java</code>:
<source>
class Test {
int i = 0;
}
</source>
</p>
<p>
Example of execution for <code>checkstyle.xml</code>. Violation from Check of
<code>common.xml</code> is expected, validation of field name is done by main code rules:
<source>
$ java -Dcheckstyle.enableExternalDtdLoad=true -classpath checkstyle-XX.X-all.jar \
com.puppycrawl.tools.checkstyle.Main -c checkstyle.xml Test.java
Starting audit...
[ERROR] Test.java:1: File length is 3 lines (max allowed is 1). [FileLength]
[ERROR] Test.java:2:7: 'i' must match pattern '^[a-z][a-zA-Z]+$'. [MemberName]
Audit done.
Checkstyle ends with 2 errors.
</source>
</p>
<p>
Example of execution for <code>checkstyle-test.xml</code>. Violation from Check of
<code>common.xml</code> is expected, validation of field name is done by test code rules:
<source>
$ java -Dcheckstyle.enableExternalDtdLoad=true -classpath checkstyle-XX.X-all.jar \
com.puppycrawl.tools.checkstyle.Main -c checkstyle-test.xml Test.java
Starting audit...
[ERROR] Test.java:1: File length is 3 lines (max allowed is 1). [FileLength]
[ERROR] Test.java:2:7: 'i' must match pattern '_[a-z]'. [MemberName]
Audit done.
Checkstyle ends with 2 errors.
</source>
</p>
</subsection>
</section>
<section name="Property chaining support">
<p>
Checkstyle supports property expansion within property definitions, also
known as property chaining. This feature allows you to define properties
using other properties. For example:
<source>
checkstyle.dir=/home/user/checkstyle
config.dir=configs
checkstyle.suppressions.file=${checkstyle.dir}/${config.dir}/suppressions.xml
</source>
You can then use
<code>${checkstyle.suppressions.file}</code> in your checkstyle configuration,
which will resolve to
<code>/home/user/checkstyle/configs/suppressions.xml</code>.
</p>
<subsection name="Notes" id="Property_chaining_support_Notes">
<p>
Note that property variable expression must be of the form
<code>${expression}</code>.
</p>
<p>
It is not necessary to define chained properties sequentially.
</p>
</subsection>
</section>
</body>
</document>