-
Notifications
You must be signed in to change notification settings - Fork 13
/
checkstyle-rules.xml
executable file
·472 lines (463 loc) · 22.1 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
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright © 2015-2017 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!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="JavadocMethod">
<property name="scope" value="protected"/>
<property name="severity" value="error"/>
<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="50"/>
<property name="severity" value="error"/>
</module>
<!-- <module name="CommentsIndentation">
<property name="severity" value="error"/>
</module> -->
<!-- <module name="Indentation">
<property name="severity" value="error"/>
</module> -->
<module name="CyclomaticComplexity">
<property name="max" value="15"/>
<property name="severity" value="error"/>
</module>
<module name="DefaultComesLast">
<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"/>
</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="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="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,
java.nio.file.StandardWatchEventKinds"/>
<property name="allowStaticMemberImports" value="false"/>
</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>
<module name="UnusedImports">
<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="200"/>
<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"/>
<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="RightCurly">
<property name="severity" value="error"/>
</module>
<module name="NoFinalizer">
<property name="severity" value="error"/>
</module>
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<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="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="ignore"/>
<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">
<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">
<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">
<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">
<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="warning"/>
<property name="format" value="log\.is\w+Enabled\("/>
<property name="message"
value="If the construction of the log message is cheap, consider not checking for logging levels."/>
</module>
<module name="RegexpSinglelineJava">
<metadata name="net.sf.eclipsecs.core.comment" value="Non-static inner class"/>
<property name="severity" value="error"/>
<property name="format" value="\s+(private|public|protected)*\s+(abstract\s)*class\s+\w+"/>
<property name="message"
value="Non-static nested classes are a security compromise. Consider using a static class instead"/>
</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="\s+$"/>
<property name="message" value="Line has trailing spaces."/>
</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="final clone() method"/>
<property name="severity" value="error"/>
<property name="format" value="public\s+\w+\s+clone\(\)"/>
<property name="message"
value="Consider marking the clone() method as final to reduce chances of data corruption"/>
</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="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="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="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="Before space"/>
<property name="severity" value="error"/>
<property name="format" value="\w+\{|\)\{"/>
<property name="message" value="'{' 前应有空格"/>
</module> -->
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="Before multi space"/>
<property name="severity" value="error"/>
<property name="format" value="\w+\s{2,}\{|\)\s{2,}\{"/>
<property name="message" value="'{' 前仅能有一个空格"/>
</module>
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="if after multi space"/>
<property name="severity" value="error"/>
<property name="format" value="if\s{2,}\("/>
<property name="message" value="'if' 后仅能有一个空格"/>
</module>
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="For after space"/>
<property name="severity" value="error"/>
<property name="format" value="for\("/>
<property name="message" value="'for' 后应有空格"/>
</module>
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="For after multi space"/>
<property name="severity" value="error"/>
<property name="format" value="for\s{2,}\("/>
<property name="message" value="'for' 后仅能有一个空格"/>
</module>
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="While after space"/>
<property name="severity" value="error"/>
<property name="format" value="while\("/>
<property name="message" value="'while' 后应有空格"/>
</module>
<module name="RegexpSingleline">
<metadata name="net.sf.eclipsecs.core.comment" value="While after multi space"/>
<property name="severity" value="error"/>
<property name="format" value="while\s{2,}\("/>
<property name="message" value="'while' 后仅能有一个空格"/>
</module>
<module name="SuppressionFilter">
<property name="file" value="${checkstyle.suppressions.file}"/>
</module>
</module>