Skip to content

Commit fb132c4

Browse files
committed
chore(sdk) add checkstyle
Signed-off-by: Scott Hamrick <2623452+cshamrick@users.noreply.github.com>
1 parent 9bd9ce5 commit fb132c4

File tree

3 files changed

+264
-0
lines changed

3 files changed

+264
-0
lines changed

checkstyle-suppressions.xml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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="FileLength" -->
9+
<!-- files="DefaultBeanContext.java|BeanDefinitionWriter.java|DefaultHttpClient.java"/> -->
10+
11+
<suppress checks="DesignForExtension" />
12+
<suppress checks="MagicNumber" />
13+
<!-- <suppress checks="VisibilityModifier" />-->
14+
<suppress checks="RedundantModifier" />
15+
<suppress checks="WhitespaceAround" />
16+
<suppress checks="FinalParameters" />
17+
<suppress checks="FinalClass" />
18+
<!-- <suppress checks="MissingJavadocMethod" />-->
19+
<!-- <suppress checks="JavadocStyle" />-->
20+
<!-- <suppress checks="JavadocVariable" />-->
21+
<!-- <suppress checks="JavadocMethod" />-->
22+
<suppress checks="HideUtilityClassConstructor" />
23+
<suppress checks="ModifierOrder" />
24+
<suppress checks="RegexpSingleline" />
25+
<suppress checks="LineLength" />
26+
<suppress checks="HiddenField" />
27+
<suppress checks="NewlineAtEndOfFile" />
28+
<suppress checks="ConstantName" />
29+
<suppress checks="NoWhitespaceAfter" />
30+
<suppress checks="OperatorWrap" />
31+
<suppress checks="AvoidStarImport" />
32+
<suppress checks="NeedBraces" />
33+
<suppress checks="MemberName" />
34+
<suppress checks="InnerAssignment" />
35+
<suppress checks="MultipleVariableDeclarations" />
36+
<suppress checks="NoWhitespaceBefore" />
37+
<suppress checks="WhitespaceAfter" />
38+
<suppress checks="MethodName" />
39+
<suppress checks="MissingSwitchDefault" />
40+
<suppress checks="EmptyForIteratorPad" />
41+
<suppress checks="ParenPad" />
42+
<suppress checks="UnusedImports" />
43+
<suppress checks="LocalVariableName" />
44+
<suppress checks="MethodLength" />
45+
<suppress checks="ParameterNumber" />
46+
<!-- <suppress checks="JavadocPackage" />-->
47+
</suppressions>

checkstyle.xml

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

pom.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@
213213
<artifactId>maven-deploy-plugin</artifactId>
214214
<version>3.1.2</version>
215215
</plugin>
216+
<plugin>
217+
<groupId>org.apache.maven.plugins</groupId>
218+
<artifactId>maven-checkstyle-plugin</artifactId>
219+
<version>3.6.0</version>
220+
</plugin>
216221
</plugins>
217222
</pluginManagement>
218223
<plugins>
@@ -275,6 +280,19 @@
275280
</execution>
276281
</executions>
277282
</plugin>
283+
<plugin>
284+
<groupId>org.apache.maven.plugins</groupId>
285+
<artifactId>maven-checkstyle-plugin</artifactId>
286+
<executions>
287+
<execution>
288+
<id>validate</id>
289+
<phase>validate</phase>
290+
<goals>
291+
<goal>check</goal>
292+
</goals>
293+
</execution>
294+
</executions>
295+
</plugin>
278296
</plugins>
279297
</build>
280298
<profiles>

0 commit comments

Comments
 (0)