-
Notifications
You must be signed in to change notification settings - Fork 26
/
checkstyle-rules.xml
562 lines (548 loc) · 26.3 KB
/
checkstyle-rules.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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="severity" value="warning"/>
<property name="charset" value="UTF-8"/>
<!-- TreeWalker module checks -->
<module name="TreeWalker">
<property name="tabWidth" value="4"/>
<module name="NonEmptyAtclauseDescription">
<property name="severity" value="error"/>
</module>
<module name="JavadocMethod">
<property name="scope" value="protected"/>
<property name="severity" value="error"/>
<property name="tokens" value="METHOD_DEF, ANNOTATION_FIELD_DEF"/>
<property name="allowUndeclaredRTE" value="true"/>
<property name="allowMissingPropertyJavadoc" value="true"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
</module>
<module name="JavadocType">
<property name="severity" value="error"/>
<property name="scope" value="public"/>
<property name="authorFormat" value="\w+"/>
<property name="allowMissingParamTags" value="true"/>
</module>
<module name="JavadocVariable">
<property name="severity" value="error"/>
<property name="scope" value="protected"/>
<property name="ignoreNamePattern" value="log|logger|LOG|LOGGER"/>
</module>
<module name="JavadocStyle">
<property name="severity" value="error"/>
</module>
<module name="ClassFanOutComplexity">
<property name="max" value="120"/>
<property name="severity" value="error"/>
</module>
<module name="CommentsIndentation">
<property name="severity" value="error"/>
</module>
<module name="CyclomaticComplexity">
<property name="max" value="20"/>
<property name="severity" value="error"/>
</module>
<module name="DefaultComesLast">
<property name="severity" value="error"/>
</module>
<!--
<module name="MissingCtorCheck">
<property name="severity" value="error"/>
</module>
-->
<module name="AnnotationLocation">
<property name="severity" value="error"/>
<property name="allowSamelineSingleParameterlessAnnotation" value="false"/>
</module>
<module name="ConstantName">
<property name="severity" value="error"/>
</module>
<module name="GenericWhitespaceCheck">
<property name="severity" value="error"/>
</module>
<module name="ModifiedControlVariable">
<property name="severity" value="error"/>
</module>
<module name="MagicNumber">
<property name="ignoreAnnotation" value="true"/>
<property name="ignoreHashCodeMethod" value="true"/>
<property name="ignoreFieldDeclaration" value="true"/>
<property name="severity" value="error"/>
<property name="ignoreNumbers" value="-1, 0, 1, 2, 1000"/>
</module>
<module name="LocalFinalVariableName">
<property name="severity" value="error"/>
</module>
<module name="LocalVariableName">
<property name="severity" value="error"/>
</module>
<module name="AbstractClassName">
<property name="ignoreModifier" value="true"/>
<property name="severity" value="error"/>
<property name="format" value="^Abstract.*$|^.*Factory$|^Base.*$|^Root.*$"/>
</module>
<module name="MemberName">
<property name="severity" value="error"/>
</module>
<module name="MethodName">
<property name="severity" value="error"/>
</module>
<module name="GenericWhitespace">
<property name="severity" value="error"/>
</module>
<module name="PackageName">
<property name="severity" value="error"/>
</module>
<module name="UnnecessaryParentheses">
<property name="severity" value="error"/>
</module>
<module name="ParameterName">
<property name="severity" value="error"/>
<property name="ignoreOverridden" value="true"/>
</module>
<module name="StaticVariableName">
<property name="severity" value="error"/>
<property name="format" value="(^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$)"/>
</module>
<module name="SingleSpaceSeparator">
<property name="validateComments" value="true"/>
<property name="severity" value="error"/>
</module>
<module name="AbbreviationAsWordInName"/>
<module name="TypeName">
<property name="severity" value="error"/>
</module>
<module name="AvoidStarImport">
<property name="severity" value="error"/>
<property name="excludes"
value="java.io,
java.net,
java.lang.Math,
org.junit.Assert,
org.mockito.Mockito,
org.mockito.Matchers,
org.springframework.test.web.servlet.request.MockMvcRequestBuilders,
org.springframework.test.web.servlet.result.MockMvcResultMatchers,
org.springframework.test.web.client.ExpectedCount,
org.springframework.test.web.client.match.MockRestRequestMatchers,
org.springframework.test.web.client.response.MockRestResponseCreators,
java.nio.file.StandardWatchEventKinds"/>
<property name="allowStaticMemberImports" value="true"/>
</module>
<module name="SingleLineJavadoc">
<property name="severity" value="warning"/>
</module>
<module name="IllegalImport">
<property name="severity" value="error"/>
</module>
<module name="RedundantImport">
<property name="severity" value="error"/>
</module>
<!--
This check insofar is unable to ignore constants and logger fields.
<module name="RequireThis">
<property name="severity" value="error"/>
<property name="checkMethods" value="false" />
<property name="validateOnlyOverlapping" value="false" />
</module>
-->
<module name="UnusedImports">
<property name="severity" value="error"/>
</module>
<module name="UnnecessaryParentheses">
<property name="severity" value="error"/>
</module>
<module name="SuperClone">
<property name="severity" value="info"/>
</module>
<module name="SuperFinalize">
<property name="severity" value="error"/>
</module>
<module name="MethodLength"/>
<module name="ParameterNumber">
<property name="max" value="10"/>
<property name="severity" value="error"/>
<property name="tokens" value="METHOD_DEF"/>
</module>
<module name="LineLength">
<property name="max" value="160"/>
<property name="tabWidth" value="4"/>
<property name="severity" value="error"/>
</module>
<module name="EmptyForIteratorPad"/>
<module name="MethodParamPad">
<property name="severity" value="error"/>
</module>
<module name="NoWhitespaceAfter">
<property name="severity" value="error"/>
</module>
<module name="NoWhitespaceBefore">
<property name="severity" value="error"/>
</module>
<module name="OperatorWrap">
<property name="severity" value="error"/>
</module>
<module name="ParenPad">
<property name="severity" value="error"/>
</module>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter">
<property name="severity" value="error"/>
</module>
<module name="ModifierOrder">
<property name="severity" value="error"/>
</module>
<module name="RedundantModifier">
<property name="severity" value="error"/>
</module>
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock">
<property name="severity" value="error"/>
</module>
<module name="FallThrough">
<property name="severity" value="error"/>
</module>
<module name="DeclarationOrder">
<property name="severity" value="error"/>
</module>
<module name="CovariantEquals">
<property name="severity" value="error"/>
</module>
<module name="ExplicitInitialization">
<property name="severity" value="error"/>
</module>
<module name="LeftCurly">
<property name="severity" value="error"/>
</module>
<module name="NeedBraces">
<property name="severity" value="error"/>
</module>
<module name="EqualsAvoidNull">
<property name="severity" value="error"/>
</module>
<module name="MultipleVariableDeclarations">
<property name="severity" value="error"/>
</module>
<module name="OneTopLevelClass">
<property name="severity" value="error"/>
</module>
<module name="StringLiteralEquality">
<property name="severity" value="error"/>
</module>
<!--
<module name="MissingCtor">
<property name="severity" value="error" />
</module>
-->
<module name="OuterTypeFilename">
<property name="severity" value="error"/>
</module>
<module name="OuterTypeNumber">
<property name="severity" value="error"/>
</module>
<module name="AnnotationUseStyle">
<property name="severity" value="error"/>
</module>
<module name="CatchParameterName">
<property name="severity" value="error"/>
</module>
<module name="AnonInnerLength">
<property name="max" value="40"/>
<property name="severity" value="error"/>
</module>
<module name="RightCurly">
<property name="severity" value="error"/>
</module>
<module name="NoFinalizer">
<property name="severity" value="error"/>
</module>
<module name="EmptyStatement"/>
<module name="EqualsHashCode">
<property name="severity" value="info"/>
</module>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MissingSwitchDefault">
<property name="severity" value="info"/>
</module>
<module name="SimplifyBooleanExpression">
<property name="severity" value="error"/>
</module>
<module name="SimplifyBooleanReturn">
<property name="severity" value="error"/>
</module>
<module name="FinalClass">
<property name="severity" value="error"/>
</module>
<module name="HideUtilityClassConstructor">
<property name="severity" value="error"/>
</module>
<!--
<module name="InterfaceIsType">
<property name="severity" value="info"/>
</module>
<module name="MultipleStringLiterals">
<property name="severity" value="info"/>
<property name="ignoreStringsRegexp"
value="(^""$)|(^"(no|false|\/|true|//|yes|default|\.|,|=|&|\?|UTF-8|\*|\\|//)"$)" />
</module>
-->
<module name="VisibilityModifier">
<property name="severity" value="error"/>
<property name="protectedAllowed" value="true"/>
</module>
<module name="AtclauseOrder">
<property name="severity" value="error"/>
</module>
<module name="BooleanExpressionComplexity">
<property name="severity" value="error"/>
<property name="max" value="4"/>
</module>
<module name="ArrayTypeStyle">
<property name="severity" value="error"/>
</module>
<module name="FinalParameters">
<property name="severity" value="error"/>
<property name="tokens" value="METHOD_DEF, CTOR_DEF, LITERAL_CATCH"/>
</module>
<module name="FinalLocalVariable">
<property name="severity" value="error"/>
<property name="tokens" value="PARAMETER_DEF, VARIABLE_DEF"/>
<property name="validateEnhancedForLoopVariable" value="true"/>
</module>
<module name="TodoComment">
<property name="severity" value="error"/>
</module>
<module name="MutableException">
<property name="severity" value="error"/>
</module>
<module name="UpperEll"/>
<module name="MissingOverride">
<property name="severity" value="error"/>
</module>
<module name="MissingDeprecated">
<property name="severity" value="error"/>
</module>
<!-- Custom checks based on regular expressions -->
<module name="RegexpSinglelineJava">
<property name="id" value="namedAnnotations"/>
<metadata name="net.sf.eclipsecs.core.comment" value="Component/Controller/Configuration annotations must be named"/>
<property name="severity" value="error"/>
<property name="format" value="@(Configuration|Component|Controller)(\(\))*$"/>
<property name="message"
value="It's better to name controller/component/configuration annotations to avoid implicit configuration"/>
</module>
<module name="RegexpSinglelineJava">
<metadata name="net.sf.eclipsecs.core.comment" value="Parameteric log messages"/>
<property name="severity" value="error"/>
<property name="format" value="log\.\w+\(((\".+\"\s*\+)|(.*\s*\+\s*\"))"/>
<property name="message"
value="Avoid string concatenation for constructing log messages. Use parametric messages instead"/>
</module>
<module name="RegexpSinglelineJava">
<metadata name="net.sf.eclipsecs.core.comment" value="JavaDoc @version tag"/>
<property name="severity" value="error"/>
<property name="format" value="@version\s+(.+)*(\$Revision|\$Date)"/>
<property name="message" value="Invalid JavaDoc @version tag."/>
</module>
<module name="RegexpSinglelineJava">
<metadata name="net.sf.eclipsecs.core.comment" value="Logging framework selection"/>
<property name="severity" value="error"/>
<property name="format" value="LogFactory\.getLog"/>
<property name="message" value="CAS uses the slf4j logging framework."/>
</module>
<module name="RegexpSinglelineJava">
<metadata name="net.sf.eclipsecs.core.comment" value="Logger as non-transient"/>
<property name="severity" value="error"/>
<property name="format" value="(protected|public)\s+(final\s)*Logger"/>
<property name="message" value="Non-static logger must be declared as transient to avoid serialization issues."/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="sysOutConsoleLogs"/>
<metadata name="net.sf.eclipsecs.core.comment" value="Console output messages"/>
<property name="severity" value="error"/>
<property name="format" value="System\.(out|err)"/>
<property name="message"
value="Avoid sending messages to the console directly. Use a logger object instead"/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="stackTraceConsoleLogs"/>
<metadata name="net.sf.eclipsecs.core.comment" value="Printing stack traces to the console"/>
<property name="severity" value="error"/>
<property name="format" value="\.printStackTrace\(\)"/>
<property name="message"
value="Avoid sending stack traces to the console directly. Use a logger object instead"/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="junitTestMethodName"/>
<metadata name="net.sf.eclipsecs.core.comment" value="Using 'test' prefix for JUnit Tests"/>
<property name="severity" value="error"/>
<property name="format" value="(public|protected)\s+void\s+test\w+\(.+\{$"/>
<property name="message"
value="JUnit test methods should not begin with the 'test' prefix. Use annotations instead and/or rename the method"/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="commonslang3"/>
<metadata name="net.sf.eclipsecs.core.comment" value="Force using commons-lang v3"/>
<property name="severity" value="error"/>
<property name="format" value="org\.apache\.commons\.lang\."/>
<property name="message" value="Use 'org.apache.commons.lang3' instead."/>
</module>
<module name="RegexpSinglelineJava">
<metadata name="net.sf.eclipsecs.core.comment" value="The logger object must be named "logger""/>
<property name="severity" value="error"/>
<property name="format" value="\s+(static\s)*(final\s)*(static\s)*Logger\s+(log|LOG)\b"/>
<property name="message"
value="The Logger object must only be called "logger" or "LOGGER""/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="finalNonUtilClass"/>
<metadata name="net.sf.eclipsecs.core.comment" value="final non-utility classes"/>
<property name="severity" value="error"/>
<property name="format" value="(public\s)*(static\s)*final\s+class\s+\w+"/>
<property name="message" value="Non-utility class should not be marked as final"/>
</module>
<module name="RegexpSinglelineJava">
<metadata name="net.sf.eclipsecs.core.comment" value="Qualifying logger with the "this" keyword"/>
<property name="severity" value="error"/>
<property name="format" value="((this\.logger)|(super\.logger))\.\w+\("/>
<property name="message" value="The Logger object need not be qualified with the "this" keyword"/>
</module>
<module name="RegexpSinglelineJava">
<metadata name="net.sf.eclipsecs.core.comment" value="Using @Test instead of extending TestCase"/>
<property name="severity" value="error"/>
<property name="format" value="class\s+\w+\s+extends\s+(junit\.framework\.)*TestCase"/>
<property name="message"
value="All testcase must use annotations (@Test) instead of extending junit.framework.TestCase"/>
</module>
<module name="RegexpSinglelineJava">
<metadata name="net.sf.eclipsecs.core.comment" value="Using the junit.framework package"/>
<property name="severity" value="error"/>
<property name="format" value="junit.framework"/>
<property name="message" value="The package junit.framework belongs to JUnit v3. Use org.junit instead."/>
</module>
<module name="RegexpSinglelineJava">
<metadata name="net.sf.eclipsecs.core.comment" value="Checking for logging level"/>
<property name="severity" value="error"/>
<property name="format" value="log\.is\w+Enabled\("/>
<property name="message"
value="Consider not checking for logging levels. Let the logging framework handle that."/>
</module>
<module name="RegexpSinglelineJava">
<metadata name="net.sf.eclipsecs.core.comment" value="Using PostConstruct annotation"/>
<property name="severity" value="error"/>
<property name="format" value=".+InitializingBean.+"/>
<property name="message"
value="Use the @PostConstruct annotation instead of implementing InitializingBean"/>
</module>
</module>
<!-- Checker module checks -->
<module name="UniqueProperties">
<property name="severity" value="error"/>
</module>
<module name="NewlineAtEndOfFile">
<property name="fileExtensions" value="java, xml, properties, txt"/>
<property name="lineSeparator" value="lf"/>
<property name="severity" value="error"/>
</module>
<module name="Translation">
<property name="severity" value="ignore"/>
</module>
<module name="FileLength"/>
<module name="FileTabCharacter">
<property name="severity" value="error"/>
</module>
<!-- Custom checks based on regular expressions -->
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="Trailing spaces"/>
<property name="severity" value="error"/>
<property name="format" value="\w+\s+$"/>
<property name="message" value="Line has trailing spaces."/>
</module>
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="Forbidden annotations"/>
<property name="severity" value="error"/>
<property name="format" value="@Component|@Value"/>
<property name="message" value="Avoid using the indicated annotations."/>
</module>
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="Use Java streams"/>
<property name="severity" value="error"/>
<property name="format" value="new .+(Set|List).+\(Arrays\.asList"/>
<property name="message" value="Avoid chaining collections. Shoot for immutability. Try Stream.of() and collect."/>
</module>
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="Space instead of tabs"/>
<property name="severity" value="error"/>
<property name="format" value="^\t+"/>
<property name="message" value="Tabs should never be used for indentation. Use spaces instead"/>
</module>
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="Space after cast"/>
<property name="severity" value="error"/>
<property name="format" value="\(\w+\)\w+"/>
<property name="message" value="There are no spaces after cast."/>
</module>
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="Usage of java.util.Random"/>
<property name="severity" value="error"/>
<property name="format" value="(java.util.Random)|(new Random\()"/>
<property name="message" value="For security purposes, use 'java.security.SecureRandom' instead"/>
</module>
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="JUnit Assert static import"/>
<property name="severity" value="error"/>
<property name="format" value="import\s+static\s+org\.junit\.Assert\.\w+"/>
<property name="message" value="JUnit Assert methods MUST be imported statically with a *"/>
</module>
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="Arrays.asList() method call"/>
<property name="severity" value="error"/>
<property name="format" value="Lists\.newArrayList\(.+"/>
<property name="message" value="Use Arrays.asList() or Collections.singletonList() instead."/>
</module>
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="Mockito static import"/>
<property name="severity" value="error"/>
<property name="format" value="import\s+static\s+org\.mockito\.Mockito\.\w+"/>
<property name="message" value="Mockito methods MUST be imported statically with a *"/>
</module>
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="Test class is named incorrectly"/>
<property name="severity" value="error"/>
<property name="format" value="public\s+(abstract\s+)*class\s+.+Test\s*\{"/>
<property name="message" value="Name of the test class MUST end in 'Tests'"/>
</module>
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="Use @Rule instead of expect an exception"/>
<property name="severity" value="error"/>
<property name="format" value="@Test\(expect"/>
<property name="message" value="Use @Rule ExpectedException instead of expecting an exception"/>
</module>
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="Use Collections.singleton instead"/>
<property name="severity" value="info"/>
<property name="format" value="new.*Set<>\((Arrays\.asList\([^,]+\)|Collections\.singletonList\(.*\))\)"/>
<property name="message" value="Consider using Collections.singleton instead"/>
</module>
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="Use specific request annotation"/>
<property name="severity" value="error"/>
<property name="format" value="method = RequestMethod\."/>
<property name="fileExtensions" value="java"/>
<property name="message" value="Use specific request annotation from org.springframework.web.bind.annotation package"/>
</module>
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="Missing @since tag"/>
<property name="severity" value="error"/>
<property name="format" value="\s+\*+\s+@since\s+\d+\.\d+.*"/>
<property name="maximum" value="200"/>
<property name="minimum" value="1"/>
<property name="fileExtensions" value="java,groovy"/>
<property name="message" value="There are no @since tags defined for this component's Javadocs."/>
</module>
<module name="SuppressionFilter">
<property name="file" value="${checkstyle.suppressions.file}"/>
</module>
</module>