107107< module name=" Checker">
108108 < module name=" TreeWalker">
109109 < module name=" SuppressWithNearbyCommentFilter" />
110+ < module name=" NoWhitespaceAfter" />
110111 < /module>
111112< /module>
112113 </source >
113114 <p id =" Example1-code" >Example:</p >
114115 <source >
115- private int [] array; // SUPPRESS CHECKSTYLE
116+ public class Example1 {
117+ private int [] array; // SUPPRESS CHECKSTYLE NoWhitespaceAfter
118+ }
116119 </source >
117120 <p id =" Example2-config" >
118121 To configure a filter to suppress all audit events on any line
@@ -126,12 +129,15 @@ private int [] array; // SUPPRESS CHECKSTYLE
126129 < property name=" checkFormat" value=" .*" />
127130 < property name=" influenceFormat" value=" 0" />
128131 < /module>
132+ < module name=" ConstantName" />
129133 < /module>
130134< /module>
131135 </source >
132136 <p id =" Example2-code" >Example:</p >
133137 <source >
134- public static final int lowerCaseConstant; // CHECKSTYLE IGNORE THIS LINE
138+ public class Example2 {
139+ public static final int lowerCaseConstant = 1; // CHECKSTYLE IGNORE THIS LINE
140+ }
135141 </source >
136142 <p id =" Example3-config" >
137143 To configure a filter so that
@@ -148,17 +154,22 @@ public static final int lowerCaseConstant; // CHECKSTYLE IGNORE THIS LINE
148154 < property name=" messageFormat" value=" $1" />
149155 < property name=" influenceFormat" value=" -1" />
150156 < /module>
157+ < module name=" IllegalCatch" />
151158 < /module>
152159< /module>
153160 </source >
154161 <p id =" Example3-code" >Example:</p >
155162 <source >
156- . . .
157- catch (RuntimeException re) {
158- // OK to catch RuntimeException here
163+ public class Example3 {
164+ public void doStuff() {
165+ try {
166+ // blah blah blah
167+ }
168+ catch(RuntimeException re) {
169+ // OK to catch RuntimeException here
170+ }
171+ }
159172}
160- catch (Throwable th) { ... }
161- . . .
162173 </source >
163174 <p id =" Example4-config" >
164175 To configure a filter so that
@@ -175,16 +186,20 @@ catch (Throwable th) { ... }
175186 < property name=" checkFormat" value=" $1" />
176187 < property name=" influenceFormat" value=" $2" />
177188 < /module>
189+ < module name=" ConstantName" />
178190 < /module>
179191< /module>
180192 </source >
181193 <p id =" Example4-code" >Example:</p >
182194 <source >
183- static final int lowerCaseConstant; // CHECKSTYLE IGNORE ConstantNameCheck FOR NEXT 3 LINES
184- static final int lowerCaseConstant1;
185- static final int lowerCaseConstant2;
186- static final int lowerCaseConstant3;
187- static final int lowerCaseConstant4; // will warn here
195+ public class Example4 {
196+ // CHECKSTYLE IGNORE ConstantNameCheck FOR NEXT 4 LINES
197+ static final int lowerCaseConstant1 = 1;
198+ static final int lowerCaseConstant2 = 2;
199+ static final int lowerCaseConstant3 = 3;
200+ static final int lowerCaseConstant4 = 4;
201+ static final int lowerCaseConstant5 = 5; // violation 'must match pattern'
202+ }
188203 </source >
189204 <p id =" Example5-config" >
190205 To configure a filter to avoid any audits on code like:
@@ -194,18 +209,19 @@ static final int lowerCaseConstant4; // will warn here
194209 < module name=" TreeWalker">
195210 < module name=" SuppressWithNearbyCommentFilter">
196211 < property name=" commentFormat"
197- value=" ALLOW (\\w+) ON PREVIOUS LINE" />
198- < property name=" checkFormat" value=" $1" />
212+ value=" ALLOW (\w+) ON PREVIOUS LINE" />
199213 < property name=" influenceFormat" value=" -1" />
200214 < /module>
215+ < module name=" MemberName" />
201216 < /module>
202217< /module>
203218 </source >
204219 <p id =" Example5-code" >Example:</p >
205220 <source >
206- private int D2;
207- // ALLOW MemberName ON PREVIOUS LINE
208- . . .
221+ public class Example5 {
222+ private int D2;
223+ // ALLOW MemberName ON PREVIOUS LINE
224+ }
209225 </source >
210226
211227 <p id =" Example6-config" >
@@ -217,16 +233,21 @@ private int D2;
217233 < module name=" TreeWalker">
218234 < module name=" SuppressWithNearbyCommentFilter">
219235 < property name=" commentFormat"
220- value=" @cs\.suppress \[(\w+(\|\w+)*)\] \w[-\.'`,:;\w ]{14 ,}" />
236+ value=" @cs\.suppress \[(\w+(\|\w+)*)\] \w[-\.'`,:;\w ]{13 ,}" />
221237 < property name=" checkFormat" value=" $1" />
222238 < property name=" influenceFormat" value=" 1" />
223239 < /module>
240+ < module name=" ConstantName" />
241+ < module name=" NoWhitespaceAfter" />
224242 < /module>
225243< /module>
226244 </source >
227245 <p id =" Example6-code" >Example:</p >
228246 <source >
229- public static final int [] array; // @cs.suppress [ConstantName|NoWhitespaceAfter] A comment here
247+ public class Example6 {
248+ // @cs.suppress [ConstantName|NoWhitespaceAfter] A comment here
249+ public static final int [] array = {};
250+ }
230251 </source >
231252 <p >
232253 It is possible to specify an ID of checks, so that it can be leveraged by the
@@ -255,23 +276,25 @@ public static final int [] array; // @cs.suppress [ConstantName|NoWhitespaceAfte
255276 < property name=" format" value=" ^.*@Ignore\s*$" />
256277 < property name=" message" value=" @Ignore should have a reason." />
257278 < /module>
258-
259279 < module name=" RegexpSinglelineJava">
260280 < property name=" id" value=" systemout" />
261- < property name=" format" value=" ^.*System\.(out|err).*$" />
281+ < property name=" format" value=" ^.*System\.\ (out|err\ ).*$" />
262282 < property name=" message" value=" Don't use System.out/err, use SLF4J instead." />
263283 < /module>
264284 < /module>
265285< /module>
266286 </source >
267287 <p id =" Example7-code" >Example:</p >
268288 <source >
269- @Ignore // @cs-: ignore (test has not been implemented yet)
270- @Test
271- public void testMethod() { }
289+ public class Example7 {
290+ @Ignore // @cs-: ignore (test has not been implemented yet)
291+ @Test
292+ public void testMethod() {}
272293
273- public static void foo() {
274- System.out.println(" Debug info." ); // @cs-: systemout (should not fail RegexpSinglelineJava)
294+ public static void foo() {
295+
296+ System.out.println(" Debug info." ); // @cs-: systemout (should not fail)
297+ }
275298}
276299 </source >
277300 <p id =" Example8-config" >
@@ -286,16 +309,20 @@ public static void foo() {
286309 < property name=" checkFormat" value=" $1" />
287310 < property name=" influenceFormat" value=" $2" />
288311 < /module>
312+ < module name=" ClassDataAbstractionCoupling">
313+ < property name=" max" value=" 1" />
314+ < /module>
315+ < module name=" MagicNumber" />
289316 < /module>
290317< /module>
291318 </source >
292319 <p id =" Example8-code" >Example:</p >
293320 <source >
294321// @cs-: ClassDataAbstractionCoupling influence 2
295322// @cs-: MagicNumber influence 4
296- @Service // no violations from ClassDataAbstractionCoupling here
297- @Transactional
298- public class UserService {
323+ public class Example8 { // no violations from ClassDataAbstractionCoupling here
324+ private Example1 foo = new Example1();
325+ private Example2 bar = new Example2();
299326 private int value = 10022; // no violations from MagicNumber here
300327}
301328 </source >
0 commit comments