Skip to content

Commit 9892253

Browse files
committed
add checkstyle config
1 parent d7e79f6 commit 9892253

2 files changed

Lines changed: 219 additions & 0 deletions

File tree

checkstyle-suppressions.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
3+
<!DOCTYPE suppressions PUBLIC
4+
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
5+
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
6+
7+
<suppressions>
8+
<suppress checks="Javadoc" files="."/>
9+
<suppress checks="MethodName" files=".*[\\/]src[\\/](test|it)[\\/]"/>
10+
<suppress checks="VisibilityModifier" files=".*[\\/]src[\\/](test|it)[\\/]"/>
11+
<suppress checks="FileTabCharacter" files=".*[\\/]src[\\/](test|it)[\\/]"/>
12+
</suppressions>

checkstyle.xml

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
6+
<!--
7+
8+
Checkstyle configuration that checks the sun coding conventions from:
9+
10+
- the Java Language Specification at
11+
https://docs.oracle.com/javase/specs/jls/se11/html/index.html
12+
13+
- the Sun Code Conventions at https://www.oracle.com/java/technologies/javase/codeconventions-contents.html
14+
15+
- the Javadoc guidelines at
16+
https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html
17+
18+
- the JDK Api documentation https://docs.oracle.com/en/java/javase/11/
19+
20+
- some best practices
21+
22+
Checkstyle is very configurable. Be sure to read the documentation at
23+
https://checkstyle.org (or in your downloaded distribution).
24+
25+
Most Checks are configurable, be sure to consult the documentation.
26+
27+
To completely disable a check, just comment it out or delete it from the file.
28+
To suppress certain violations please review suppression filters.
29+
30+
Finally, it is worth reading the documentation.
31+
32+
-->
33+
34+
<module name="Checker">
35+
<!--
36+
If you set the basedir property below, then all reported file
37+
names will be relative to the specified directory. See
38+
https://checkstyle.org/config.html#Checker
39+
40+
<property name="basedir" value="${basedir}"/>
41+
-->
42+
<property name="severity" value="error"/>
43+
44+
<property name="fileExtensions" value="java, properties, xml"/>
45+
46+
<module name="SuppressWarningsFilter"/>
47+
48+
<!-- Excludes all 'module-info.java' files -->
49+
<!-- See https://checkstyle.org/config_filefilters.html -->
50+
<module name="BeforeExecutionExclusionFileFilter">
51+
<property name="fileNamePattern" value="module\-info\.java$"/>
52+
</module>
53+
54+
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
55+
<module name="SuppressionFilter">
56+
<property name="file" value="${org.checkstyle.sun.suppressionfilter.config}"
57+
default="checkstyle-suppressions.xml"/>
58+
<property name="optional" value="true"/>
59+
</module>
60+
61+
<!-- Checks that a package-info.java file exists for each package. -->
62+
<!-- See https://checkstyle.org/config_javadoc.html#JavadocPackage -->
63+
<!--<module name="JavadocPackage"/>-->
64+
65+
<!-- Checks whether files end with a new line. -->
66+
<!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
67+
<module name="NewlineAtEndOfFile"/>
68+
69+
<!-- Checks that property files contain the same keys. -->
70+
<!-- See https://checkstyle.org/config_misc.html#Translation -->
71+
<module name="Translation"/>
72+
73+
<!-- Checks for Size Violations. -->
74+
<!-- See https://checkstyle.org/config_sizes.html -->
75+
<module name="FileLength"/>
76+
<!--<module name="LineLength">
77+
<property name="fileExtensions" value="java"/>
78+
</module>-->
79+
80+
<!-- Checks for whitespace -->
81+
<!-- See https://checkstyle.org/config_whitespace.html -->
82+
<module name="FileTabCharacter"/>
83+
84+
<!-- Miscellaneous other checks. -->
85+
<!-- See https://checkstyle.org/config_misc.html -->
86+
<module name="RegexpSingleline">
87+
<property name="format" value="\s+$"/>
88+
<property name="minimum" value="0"/>
89+
<property name="maximum" value="0"/>
90+
<property name="message" value="Line has trailing spaces."/>
91+
</module>
92+
93+
<!-- Checks for Headers -->
94+
<!-- See https://checkstyle.org/config_header.html -->
95+
<!-- <module name="Header"> -->
96+
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
97+
<!-- <property name="fileExtensions" value="java"/> -->
98+
<!-- </module> -->
99+
100+
<module name="TreeWalker">
101+
102+
<!-- Support for the @SuppressWarnings java annotation -->
103+
<module name="SuppressWarningsHolder"/>
104+
105+
<!-- Checks for Javadoc comments. -->
106+
<!-- See https://checkstyle.org/config_javadoc.html -->
107+
<module name="InvalidJavadocPosition"/>
108+
<module name="JavadocMethod"/>
109+
<module name="JavadocType"/>
110+
<module name="JavadocVariable"/>
111+
<module name="JavadocStyle"/>
112+
<module name="MissingJavadocMethod"/>
113+
114+
<!-- Checks for Naming Conventions. -->
115+
<!-- See https://checkstyle.org/config_naming.html -->
116+
<module name="ConstantName"/>
117+
<module name="LocalFinalVariableName"/>
118+
<module name="LocalVariableName"/>
119+
<module name="MemberName">
120+
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
121+
<message key="name.invalidPattern"
122+
value="Member name ''{0}'' must match pattern ''{1}''."/>
123+
</module>
124+
<module name="MethodName"/>
125+
<module name="PackageName"/>
126+
<module name="ParameterName"/>
127+
<module name="StaticVariableName"/>
128+
<module name="TypeName"/>
129+
130+
<!-- Checks for imports -->
131+
<!-- See https://checkstyle.org/config_imports.html -->
132+
<module name="AvoidStarImport"/>
133+
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
134+
<module name="RedundantImport"/>
135+
<module name="UnusedImports">
136+
<property name="processJavadoc" value="false"/>
137+
</module>
138+
139+
<!-- Checks for Size Violations. -->
140+
<!-- See https://checkstyle.org/config_sizes.html -->
141+
<module name="MethodLength"/>
142+
<module name="ParameterNumber"/>
143+
144+
<!-- Checks for whitespace -->
145+
<!-- See https://checkstyle.org/config_whitespace.html -->
146+
<module name="EmptyForIteratorPad"/>
147+
<module name="GenericWhitespace"/>
148+
<module name="MethodParamPad"/>
149+
<module name="NoWhitespaceAfter"/>
150+
<module name="NoWhitespaceBefore"/>
151+
<module name="OperatorWrap"/>
152+
<module name="ParenPad"/>
153+
<module name="TypecastParenPad"/>
154+
<module name="WhitespaceAfter"/>
155+
<module name="WhitespaceAround"/>
156+
157+
<!-- Modifier Checks -->
158+
<!-- See https://checkstyle.org/config_modifiers.html -->
159+
<module name="ModifierOrder"/>
160+
<module name="RedundantModifier"/>
161+
162+
<!-- Checks for blocks. You know, those {}'s -->
163+
<!-- See https://checkstyle.org/config_blocks.html -->
164+
<module name="AvoidNestedBlocks"/>
165+
<module name="EmptyBlock"/>
166+
<module name="LeftCurly"/>
167+
<module name="NeedBraces"/>
168+
<module name="RightCurly"/>
169+
170+
<!-- Checks for common coding problems -->
171+
<!-- See https://checkstyle.org/config_coding.html -->
172+
<module name="EmptyStatement"/>
173+
<module name="EqualsHashCode"/>
174+
<!--<module name="HiddenField"/>-->
175+
<module name="IllegalInstantiation"/>
176+
<module name="InnerAssignment"/>
177+
<!--<module name="MagicNumber"/>-->
178+
<module name="MissingSwitchDefault"/>
179+
<module name="MultipleVariableDeclarations"/>
180+
<module name="SimplifyBooleanExpression"/>
181+
<module name="SimplifyBooleanReturn"/>
182+
183+
<!-- Checks for class design -->
184+
<!-- See https://checkstyle.org/config_design.html -->
185+
<!--<module name="DesignForExtension"/>-->
186+
<module name="FinalClass"/>
187+
<module name="HideUtilityClassConstructor"/>
188+
<module name="InterfaceIsType"/>
189+
<module name="VisibilityModifier">
190+
<property name="protectedAllowed" value="true"/>
191+
</module>
192+
193+
<!-- Miscellaneous other checks. -->
194+
<!-- See https://checkstyle.org/config_misc.html -->
195+
<module name="ArrayTypeStyle"/>
196+
<!--<module name="FinalParameters"/>-->
197+
<module name="TodoComment"/>
198+
<module name="UpperEll"/>
199+
200+
<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
201+
<module name="SuppressionXpathFilter">
202+
<property name="file" value="${org.checkstyle.sun.suppressionxpathfilter.config}"
203+
default="checkstyle-xpath-suppressions.xml"/>
204+
<property name="optional" value="true"/>
205+
</module>
206+
</module>
207+
</module>

0 commit comments

Comments
 (0)