Skip to content

Commit 7a42f68

Browse files
authored
chore: configure checkstyle (#5110)
1 parent 089b1f7 commit 7a42f68

File tree

3 files changed

+218
-0
lines changed

3 files changed

+218
-0
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,5 @@ jobs:
2929
with:
3030
token: ${{ secrets.CODECOV_TOKEN }}
3131
fail_ci_if_error: true
32+
- name: Checkstyle
33+
run: mvn checkstyle:check

checkstyle.xml

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
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+
<!-- Excludes all 'module-info.java' files -->
47+
<!-- See https://checkstyle.org/filefilters/index.html -->
48+
<module name="BeforeExecutionExclusionFileFilter">
49+
<property name="fileNamePattern" value="module\-info\.java$"/>
50+
</module>
51+
52+
<!-- https://checkstyle.org/filters/suppressionfilter.html -->
53+
<module name="SuppressionFilter">
54+
<property name="file" value="${org.checkstyle.sun.suppressionfilter.config}"
55+
default="checkstyle-suppressions.xml" />
56+
<property name="optional" value="true"/>
57+
</module>
58+
59+
<!-- Checks that a package-info.java file exists for each package. -->
60+
<!-- See https://checkstyle.org/checks/javadoc/javadocpackage.html#JavadocPackage -->
61+
<!-- TODO <module name="JavadocPackage"/> -->
62+
63+
<!-- Checks whether files end with a new line. -->
64+
<!-- See https://checkstyle.org/checks/misc/newlineatendoffile.html -->
65+
<module name="NewlineAtEndOfFile"/>
66+
67+
<!-- Checks that property files contain the same keys. -->
68+
<!-- See https://checkstyle.org/checks/misc/translation.html -->
69+
<module name="Translation"/>
70+
71+
<!-- Checks for Size Violations. -->
72+
<!-- See https://checkstyle.org/checks/sizes/index.html -->
73+
<!-- TODO <module name="FileLength"/> -->
74+
<!-- TODO <module name="LineLength">
75+
<property name="fileExtensions" value="java"/>
76+
</module> -->
77+
78+
<!-- Checks for whitespace -->
79+
<!-- See https://checkstyle.org/checks/whitespace/index.html -->
80+
<!-- TODO <module name="FileTabCharacter"/> -->
81+
82+
<!-- Miscellaneous other checks. -->
83+
<!-- See https://checkstyle.org/checks/misc/index.html -->
84+
<module name="RegexpSingleline">
85+
<property name="format" value="\s+$"/>
86+
<property name="minimum" value="0"/>
87+
<property name="maximum" value="0"/>
88+
<property name="message" value="Line has trailing spaces."/>
89+
</module>
90+
91+
<!-- Checks for Headers -->
92+
<!-- See https://checkstyle.org/checks/header/index.html -->
93+
<!-- <module name="Header"> -->
94+
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
95+
<!-- <property name="fileExtensions" value="java"/> -->
96+
<!-- </module> -->
97+
98+
<module name="TreeWalker">
99+
100+
<!-- Checks for Javadoc comments. -->
101+
<!-- See https://checkstyle.org/checks/javadoc/index.html -->
102+
<!-- TODO <module name="InvalidJavadocPosition"/> -->
103+
<!-- TODO <module name="JavadocMethod"/> -->
104+
<!-- TODO <module name="JavadocType"/> -->
105+
<!-- TODO <module name="JavadocVariable"/> -->
106+
<!-- TODO <module name="JavadocStyle"/> -->
107+
<!-- TODO <module name="MissingJavadocMethod"/> -->
108+
109+
<!-- Checks for Naming Conventions. -->
110+
<!-- See https://checkstyle.org/checks/naming/index.html -->
111+
<!-- TODO <module name="ConstantName"/> -->
112+
<!-- TODO <module name="LocalFinalVariableName"/> -->
113+
<!-- TODO <module name="LocalVariableName"/> -->
114+
<!-- TODO <module name="MemberName"/> -->
115+
<!-- TODO <module name="MethodName"/> -->
116+
<module name="PackageName"/>
117+
<!-- TODO <module name="ParameterName"/> -->
118+
<!-- TODO <module name="StaticVariableName"/> -->
119+
<!-- TODO <module name="TypeName"/> -->
120+
121+
<!-- Checks for imports -->
122+
<!-- See https://checkstyle.org/checks/imports/index.html -->
123+
<!-- TODO <module name="AvoidStarImport"/> -->
124+
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
125+
<module name="RedundantImport"/>
126+
<module name="UnusedImports">
127+
<property name="processJavadoc" value="false"/>
128+
</module>
129+
130+
<!-- Checks for Size Violations. -->
131+
<!-- See https://checkstyle.org/checks/sizes/index.html -->
132+
<module name="MethodLength"/>
133+
<module name="ParameterNumber"/>
134+
135+
<!-- Checks for whitespace -->
136+
<!-- See https://checkstyle.org/checks/whitespace/index.html -->
137+
<module name="EmptyForIteratorPad"/>
138+
<!-- TODO <module name="GenericWhitespace"/> -->
139+
<module name="MethodParamPad"/>
140+
<!-- TODO <module name="NoWhitespaceAfter"/> -->
141+
<module name="NoWhitespaceBefore"/>
142+
<!-- TODO <module name="OperatorWrap"/> -->
143+
<!-- TODO <module name="ParenPad"/> -->
144+
<module name="TypecastParenPad"/>
145+
<module name="WhitespaceAfter"/>
146+
<!-- TODO <module name="WhitespaceAround"/> -->
147+
148+
<!-- Modifier Checks -->
149+
<!-- See https://checkstyle.org/checks/modifier/index.html -->
150+
<!-- TODO <module name="ModifierOrder"/> -->
151+
<!-- TODO <module name="RedundantModifier"/> -->
152+
153+
<!-- Checks for blocks. You know, those {}'s -->
154+
<!-- See https://checkstyle.org/checks/blocks/index.html -->
155+
<!-- TODO <module name="AvoidNestedBlocks"/> -->
156+
<!-- TODO <module name="EmptyBlock"/> -->
157+
<!-- TODO <module name="LeftCurly"/> -->
158+
<!-- TODO <module name="NeedBraces"/> -->
159+
<!-- TODO <module name="RightCurly"/> -->
160+
161+
<!-- Checks for common coding problems -->
162+
<!-- See https://checkstyle.org/checks/coding/index.html -->
163+
<!-- <module name="EmptyStatement"/> -->
164+
<!-- TODO <module name="EqualsHashCode"/> -->
165+
<!-- TODO <module name="HiddenField"/> -->
166+
<module name="IllegalInstantiation"/>
167+
<!-- TODO <module name="InnerAssignment"/> -->
168+
<!-- TODO <module name="MagicNumber"/> -->
169+
<!-- TODO <module name="MissingSwitchDefault"/> -->
170+
<!-- TODO <module name="MultipleVariableDeclarations"/> -->
171+
<module name="SimplifyBooleanExpression"/>
172+
<module name="SimplifyBooleanReturn"/>
173+
174+
<!-- Checks for class design -->
175+
<!-- See https://checkstyle.org/checks/design/index.html -->
176+
<!-- TODO <module name="DesignForExtension"/> -->
177+
<!-- TODO <module name="FinalClass"/> -->
178+
<!-- TODO <module name="HideUtilityClassConstructor"/> -->
179+
<module name="InterfaceIsType"/>
180+
<!-- TODO <module name="VisibilityModifier"/> -->
181+
182+
<!-- Miscellaneous other checks. -->
183+
<!-- See https://checkstyle.org/checks/misc/index.html -->
184+
<!-- TODO <module name="ArrayTypeStyle"/> -->
185+
<!-- TODO <module name="FinalParameters"/> -->
186+
<!-- TODO <module name="TodoComment"/> -->
187+
<module name="UpperEll"/>
188+
189+
<!-- https://checkstyle.org/filters/suppressionxpathfilter.html -->
190+
<module name="SuppressionXpathFilter">
191+
<property name="file" value="${org.checkstyle.sun.suppressionxpathfilter.config}"
192+
default="checkstyle-xpath-suppressions.xml" />
193+
<property name="optional" value="true"/>
194+
</module>
195+
196+
</module>
197+
198+
</module>

pom.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,24 @@
9696
</execution>
9797
</executions>
9898
</plugin>
99+
<plugin>
100+
<groupId>org.apache.maven.plugins</groupId>
101+
<artifactId>maven-checkstyle-plugin</artifactId>
102+
<version>3.3.1</version>
103+
<configuration>
104+
<configLocation>checkstyle.xml</configLocation>
105+
<consoleOutput>true</consoleOutput>
106+
<includeTestSourceDirectory>true</includeTestSourceDirectory>
107+
<violationSeverity>warning</violationSeverity>
108+
</configuration>
109+
<dependencies>
110+
<dependency>
111+
<groupId>com.puppycrawl.tools</groupId>
112+
<artifactId>checkstyle</artifactId>
113+
<version>9.3</version>
114+
</dependency>
115+
</dependencies>
116+
</plugin>
99117
</plugins>
100118
</build>
101119
</project>

0 commit comments

Comments
 (0)