Skip to content

Commit 049c66c

Browse files
author
Wayne
committed
no message
1 parent 834687b commit 049c66c

File tree

2 files changed

+402
-0
lines changed

2 files changed

+402
-0
lines changed

config/checkstyle/checkstyle

Lines changed: 398 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,398 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
6+
<!--
7+
This configuration file enforces rules for a modified version of the module's code standard at
8+
https://oss-generic.github.io/process/codingstandards/coding-standards-java.html
9+
-->
10+
11+
<module name="Checker">
12+
13+
<module name="FileTabCharacter">
14+
<!-- Checks that there are no tab characters in the file. -->
15+
</module>
16+
17+
<module name="RegexpSingleline">
18+
<!-- Checks that FIXME is not used in comments. TODO is preferred. -->
19+
<property name="format" value="((//.*)|(\*.*))FIXME" />
20+
<property name="message" value='TODO is preferred to FIXME."' />
21+
</module>
22+
23+
<module name="SuppressionFilter">
24+
<property name="file" value="${config_loc}/suppressions.xml"/>
25+
</module>
26+
27+
<module name="LineLength">
28+
<!-- Checks if a line is too long. -->
29+
<property name="max" value="120"/>
30+
</module>
31+
32+
<!-- All Java AST specific tests live under TreeWalker module. -->
33+
<module name="TreeWalker">
34+
35+
<!-- Required to allow exceptions in code style -->
36+
<module name="SuppressionCommentFilter">
37+
<property name="offCommentFormat" value="CHECKSTYLE.OFF\: ([\w\|]+)"/>
38+
<property name="onCommentFormat" value="CHECKSTYLE.ON\: ([\w\|]+)"/>
39+
<property name="checkFormat" value="$1"/>
40+
</module>
41+
42+
<!--
43+
IMPORT CHECKS
44+
-->
45+
46+
<!-- Checks the ordering of import statements follow the rules that the default Eclipse formatter uses.
47+
The order rule "STATIC###STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE" consists of:
48+
1. STATIC: static imports
49+
2. STANDARD_JAVA_PACKAGE: standard java/javax imports
50+
3. SPECIAL_IMPORTS: defined as org imports
51+
4. THIRD_PARTY_PACKAGE: defined as com imports
52+
-->
53+
<module name="CustomImportOrder">
54+
<property name="customImportOrderRules"
55+
value="STATIC###STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE"/>
56+
<property name="specialImportsRegExp" value="^org\."/>
57+
<property name="thirdPartyPackageRegExp" value="^com\."/>
58+
<property name="sortImportsInGroupAlphabetically" value="true"/>
59+
</module>
60+
61+
<!-- Checks for redundant import statements.
62+
An import statement is redundant if:
63+
* It is a duplicate of another import. This is, when a class is imported more than once.
64+
* The class non-statically imported is from the java.lang package, e.g. importing java.lang.String.
65+
* The class non-statically imported is from the same package as the current package.
66+
-->
67+
<module name="RedundantImport"/>
68+
69+
<!-- Checks for unused import statements.
70+
An import statement is unused if:
71+
It's not referenced in the file.
72+
-->
73+
<module name="UnusedImports"/>
74+
75+
<module name="AvoidStarImport"/>
76+
77+
<!--
78+
NAMING CHECKS
79+
-->
80+
81+
<!-- Validate abbreviations (consecutive capital letters) length in identifier name -->
82+
<module name="AbbreviationAsWordInName">
83+
<property name="ignoreFinal" value="false"/>
84+
<property name="allowedAbbreviationLength" value="1"/>
85+
</module>
86+
87+
<module name="PackageName">
88+
<!-- Validates identifiers for package names against the supplied expression. -->
89+
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,})*$"/>
90+
<property name="severity" value="warning"/>
91+
</module>
92+
93+
<module name="TypeName">
94+
<!-- Validates static, final fields against the expression "^[A-Z][a-zA-Z0-9]*$". -->
95+
<metadata name="altname" value="TypeName"/>
96+
<property name="severity" value="warning"/>
97+
</module>
98+
99+
<module name="ConstantName">
100+
<!-- Validates non-private, static, final fields against the expression "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$". -->
101+
<metadata name="altname" value="ConstantName"/>
102+
<property name="applyToPrivate" value="false"/>
103+
<message key="name.invalidPattern"
104+
value="Variable ''{0}'' should be in ALL_CAPS (if it is a constant) or be private (otherwise)."/>
105+
<property name="severity" value="warning"/>
106+
</module>
107+
108+
<module name="StaticVariableName">
109+
<!-- Validates static, non-final fields against the supplied expression. -->
110+
<metadata name="altname" value="StaticVariableName"/>
111+
<property name="format" value="^[a-z][a-zA-Z0-9]*_?$"/>
112+
<property name="severity" value="warning"/>
113+
</module>
114+
115+
<module name="MemberName">
116+
<!-- Validates non-static members against the supplied expression. -->
117+
<metadata name="altname" value="MemberName"/>
118+
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
119+
<property name="severity" value="warning"/>
120+
</module>
121+
122+
<module name="MethodName">
123+
<!-- Validates identifiers for method names against the supplied expression. -->
124+
<metadata name="altname" value="MethodName"/>
125+
<property name="format" value="^[a-z][a-zA-Z0-9]*(_[a-z][a-zA-Z0-9]+){0,2}$"/>
126+
</module>
127+
128+
<module name="ParameterName">
129+
<!-- Validates identifiers for method parameters against the expression "^[a-z][a-zA-Z0-9]*$". -->
130+
<property name="severity" value="warning"/>
131+
</module>
132+
133+
<module name="LocalFinalVariableName">
134+
<!-- Validates identifiers for local final variables against the expression "^[a-z][a-zA-Z0-9]*$". -->
135+
<property name="severity" value="warning"/>
136+
</module>
137+
138+
<module name="LocalVariableName">
139+
<!-- Validates identifiers for local variables against the expression "^[a-z][a-zA-Z0-9]*$". -->
140+
<property name="severity" value="warning"/>
141+
</module>
142+
143+
144+
<!--
145+
LENGTH and CODING CHECKS
146+
-->
147+
148+
<!-- Checks that array type declarations follow Java Style
149+
Java style: public static void main(String[] args) // Allowed
150+
C style: public static void main(String args[]) // Not allowed
151+
-->
152+
<module name="ArrayTypeStyle"/>
153+
154+
<!-- Checks if a catch block is empty and does not contain any comments. -->
155+
<module name="EmptyCatchBlock"/>
156+
157+
<module name="LeftCurly">
158+
<!-- Checks for placement of the left curly brace ('{'). -->
159+
<property name="severity" value="warning"/>
160+
</module>
161+
162+
<module name="RightCurly">
163+
<!-- Checks right curlies on CATCH, ELSE, and TRY blocks are on
164+
the same line. e.g., the following example is fine:
165+
<pre>
166+
if {
167+
...
168+
} else
169+
</pre>
170+
-->
171+
<!-- This next example is not fine:
172+
<pre>
173+
if {
174+
...
175+
}
176+
else
177+
</pre>
178+
-->
179+
<property name="severity" value="warning"/>
180+
</module>
181+
182+
<!-- Checks for braces around loop blocks -->
183+
<module name="NeedBraces">
184+
<!--
185+
if (true) return 1; // Not allowed
186+
187+
if (true) { return 1; } // Not allowed
188+
189+
else if {
190+
return 1; // else if should always be multi line
191+
}
192+
193+
if (true)
194+
return 1; // Not allowed
195+
-->
196+
<property name="allowEmptyLoopBody" value="true"/>
197+
</module>
198+
199+
<!-- Checks that each variable declaration is in its own statement and on its own line. -->
200+
<module name="MultipleVariableDeclarations"/>
201+
202+
<module name="OneStatementPerLine"/>
203+
204+
<!-- Checks that long constants are defined with an upper ell.-->
205+
<module name="UpperEll" />
206+
207+
<module name="FallThrough">
208+
<!-- Warn about falling through to the next case statement. Similar to
209+
javac -Xlint:fallthrough, but the check is suppressed if a single-line comment
210+
on the last non-blank line preceding the fallen-into case contains 'fall through' (or
211+
some other variants which we don't publicized to promote consistency).
212+
-->
213+
<property name="reliefPattern"
214+
value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on"/>
215+
</module>
216+
217+
<module name="MissingSwitchDefault"/>
218+
219+
<!-- Checks that Class variables should never be declared public. -->
220+
<module name="VisibilityModifier">
221+
<property name="protectedAllowed" value="true"/>
222+
<property name="allowPublicFinalFields" value="true"/>
223+
<property name="ignoreAnnotationCanonicalNames" value="RegisterExtension, TempDir"/>
224+
</module>
225+
226+
<!--
227+
ORDER CHECKS
228+
-->
229+
230+
<!-- Checks that the order of at-clauses follows the tagOrder default property value order.
231+
@author, @version, @param, @return, @throws, @exception, @see, @since, @serial, @serialField, @serialData, @deprecated
232+
-->
233+
<module name="AtclauseOrder"/>
234+
235+
<!-- Checks if the Class and Interface declarations is organized in this order
236+
1. Class (static) variables. Order: public, protected, package level (no access modifier), private.
237+
2. Instance variables. Order: public, protected, package level (no access modifier), private.
238+
3. Constructors
239+
4. Methods
240+
-->
241+
<module name ="DeclarationOrder"/>
242+
243+
<module name="ModifierOrder">
244+
<!-- Warn if modifier order is inconsistent with JLS3 8.1.1, 8.3.1, and
245+
8.4.3. The prescribed order is:
246+
public, protected, private, abstract, static, final, transient, volatile,
247+
synchronized, native, strictfp
248+
-->
249+
</module>
250+
251+
<module name="OverloadMethodsDeclarationOrder"/>
252+
253+
<!--
254+
WHITESPACE CHECKS
255+
-->
256+
257+
<!-- Checks that comments are indented relative to their position in the code -->
258+
<module name="CommentsIndentation"/>
259+
260+
<module name="WhitespaceAround">
261+
<!-- Checks that various tokens are surrounded by whitespace.
262+
This includes most binary operators and keywords followed
263+
by regular or curly braces.
264+
-->
265+
<property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR,
266+
BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN,
267+
EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
268+
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
269+
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS,
270+
MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION,
271+
RCURLY, SL, SLIST, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN"/>
272+
<!-- Allow empty constructors e.g. MyClass() {} -->
273+
<property name="allowEmptyConstructors" value="true" />
274+
<!-- Allow empty methods e.g. void func() {} -->
275+
<property name="allowEmptyMethods" value="true" />
276+
<!-- Allow empty types e.g. class Foo {}, enum Foo {} -->
277+
<property name="allowEmptyTypes" value="true" />
278+
<!-- Allow empty loops e.g. for (int i = 1; i > 1; i++) {} -->
279+
<property name="allowEmptyLoops" value="true" />
280+
<!-- Allow empty lambdas e.g. () -> {} -->
281+
<property name="allowEmptyLambdas" value="true" />
282+
</module>
283+
284+
<module name="WhitespaceAfter">
285+
<!-- Checks that commas, semicolons and typecasts are followed by whitespace. -->
286+
<property name="tokens" value="COMMA, SEMI, TYPECAST"/>
287+
</module>
288+
289+
<module name="NoWhitespaceAfter">
290+
<!-- Checks that there is no whitespace after various unary operators. Linebreaks are allowed. -->
291+
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS,
292+
UNARY_PLUS"/>
293+
<property name="allowLineBreaks" value="true"/>
294+
</module>
295+
296+
<!-- No trailing whitespace -->
297+
<module name="Regexp">
298+
<property name="format" value="[ \t]+$"/>
299+
<property name="illegalPattern" value="true"/>
300+
<property name="message" value="Trailing whitespace"/>
301+
</module>
302+
303+
<module name="OperatorWrap">
304+
<!-- Checks that the non-assignment type operator is at the next line in a line wrap.
305+
This includes "?", ":", "==", "!=", "/", "+", "-", "*", "%", ">>", ">>>",
306+
">=", ">", "<<", "<=", "<", "^", "|", "||", "&", "&&", "instanceof",
307+
"&" when used in a generic upper or lower bounds constraints,
308+
e.g. <T extends Foo & Bar>
309+
"::" when used as a reference to a method or constructor without arguments.
310+
e.g. String::compareToIgnoreCase
311+
-->
312+
<property name="tokens" value="QUESTION, COLON, EQUAL, NOT_EQUAL, DIV, PLUS, MINUS, STAR, MOD, SR, BSR,
313+
GE, GT, SL, LE, LT, BXOR, BOR, LOR, BAND, LAND, LITERAL_INSTANCEOF, TYPE_EXTENSION_AND, METHOD_REF"/>
314+
<property name="option" value="nl"/>
315+
</module>
316+
<module name="OperatorWrap">
317+
<!-- Checks that the assignment type operator is at the previous end of line in a line wrap.
318+
This includes "=", "/=", "+=", "-=", "*=", "%=", ">>=", ">>>=", "<<=", "^=", "&=".
319+
-->
320+
<property name="tokens" value="ASSIGN, DIV_ASSIGN, PLUS_ASSIGN, MINUS_ASSIGN, STAR_ASSIGN, MOD_ASSIGN,
321+
SR_ASSIGN, BSR_ASSIGN, SL_ASSIGN, BXOR_ASSIGN, BOR_ASSIGN, BAND_ASSIGN"/>
322+
<property name="option" value="eol"/>
323+
</module>
324+
325+
<module name="SeparatorWrap">
326+
<!-- Checks that the ".", "@" is at the next line in a line wrap. -->
327+
<property name="tokens" value="DOT, AT"/>
328+
<property name="option" value="nl"/>
329+
</module>
330+
<module name="SeparatorWrap">
331+
<!-- Checks that the ",", "]", "[", "...", ";", "(" is at the previous end of line in a line wrap. -->
332+
<property name="tokens" value="COMMA, RBRACK, ARRAY_DECLARATOR, ELLIPSIS, SEMI, LPAREN"/>
333+
<property name="option" value="eol"/>
334+
</module>
335+
336+
<module name="Indentation">
337+
<property name="caseIndent" value="0" />
338+
</module>
339+
340+
<module name="NoWhitespaceBefore">
341+
<!-- Checks that there is no whitespace before various unary operators. Linebreaks are allowed. -->
342+
<property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC"/>
343+
<property name="allowLineBreaks" value="true"/>
344+
</module>
345+
346+
<module name="ParenPad">
347+
<!-- Checks that there is no whitespace before close parenthesis or after open parenthesis. -->
348+
<property name="severity" value="warning"/>
349+
</module>
350+
351+
<!-- Checks that non-whitespace characters are separated by no more than one whitespace character.
352+
a = 1; // Allowed
353+
a = 1; // Not allowed (more than one space before =)
354+
-->
355+
<module name="SingleSpaceSeparator">
356+
<!-- Validate whitespace surrounding comments as well.
357+
358+
a = 1; // Allowed (single space before start of comment)
359+
a = 1; /* Allowed (single space before start of comment) */
360+
/* Allowed (single space after end of comment) */ a = 1;
361+
a = 1; // Not allowed (more than one space before start of comment)
362+
a = 1; /* Not allowed (more than one space before start of comment) */
363+
/* Not allowed (more than one space after end of comment) */ a = 1;
364+
365+
This doesn't validate whitespace within comments so a comment /* like this */ is allowed.
366+
-->
367+
<property name="validateComments" value="true"/>
368+
</module>
369+
370+
<!--
371+
JAVADOC CHECKS
372+
-->
373+
374+
<!-- Checks that every class, enumeration and interface have a header comment. -->
375+
<module name="JavadocType">
376+
<property name="allowMissingParamTags" value="true"/>
377+
</module>
378+
379+
<!-- Checks that every public method (excluding getters, setters and constructors) has a header comment. -->
380+
<module name="JavadocMethod">
381+
<property name="allowedAnnotations" value="Override, Test, BeforeAll, BeforeEach, AfterAll, AfterEach, Subscribe"/>
382+
<property name="scope" value="public"/>
383+
<property name="validateThrows" value="false"/>
384+
<property name="allowMissingParamTags" value="true"/>
385+
<property name="allowMissingReturnTag" value="true"/>
386+
<property name="tokens" value="METHOD_DEF, ANNOTATION_FIELD_DEF"/>
387+
</module>
388+
389+
<module name="InvalidJavadocPosition"/>
390+
391+
<module name="MissingJavadocMethodCheck">
392+
<property name="minLineCount" value="1"/>
393+
<property name="allowMissingPropertyJavadoc" value="true"/>
394+
<property name="ignoreMethodNamesRegex" value="(set.*|get.*)"/>
395+
</module>
396+
397+
</module>
398+
</module>

0 commit comments

Comments
 (0)