Skip to content

Commit b8e4798

Browse files
committed
Add check style
1 parent 56e4f7d commit b8e4798

File tree

2 files changed

+199
-0
lines changed

2 files changed

+199
-0
lines changed

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id("java")
33
`java-library`
4+
checkstyle
45
// FIXME
56
// Bukkit
67
// id("net.minecrell.plugin-yml.bukkit") version "0.5.1"

config/checkstyle/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/config_filefilters.html -->
48+
<module name="BeforeExecutionExclusionFileFilter">
49+
<property name="fileNamePattern" value="module\-info\.java$"/>
50+
</module>
51+
52+
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
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/config_javadoc.html#JavadocPackage -->
61+
<module name="JavadocPackage"/>
62+
63+
<!-- Checks whether files end with a new line. -->
64+
<!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
65+
<module name="NewlineAtEndOfFile"/>
66+
67+
<!-- Checks that property files contain the same keys. -->
68+
<!-- See https://checkstyle.org/config_misc.html#Translation -->
69+
<module name="Translation"/>
70+
71+
<!-- Checks for Size Violations. -->
72+
<!-- See https://checkstyle.org/config_sizes.html -->
73+
<module name="FileLength"/>
74+
<module name="LineLength">
75+
<property name="fileExtensions" value="java"/>
76+
</module>
77+
78+
<!-- Checks for whitespace -->
79+
<!-- See https://checkstyle.org/config_whitespace.html -->
80+
<module name="FileTabCharacter"/>
81+
82+
<!-- Miscellaneous other checks. -->
83+
<!-- See https://checkstyle.org/config_misc.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/config_header.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/config_javadoc.html -->
102+
<module name="InvalidJavadocPosition"/>
103+
<module name="JavadocMethod"/>
104+
<module name="JavadocType"/>
105+
<module name="JavadocVariable"/>
106+
<module name="JavadocStyle"/>
107+
<module name="MissingJavadocMethod"/>
108+
109+
<!-- Checks for Naming Conventions. -->
110+
<!-- See https://checkstyle.org/config_naming.html -->
111+
<module name="ConstantName"/>
112+
<module name="LocalFinalVariableName"/>
113+
<module name="LocalVariableName"/>
114+
<module name="MemberName"/>
115+
<module name="MethodName"/>
116+
<module name="PackageName"/>
117+
<module name="ParameterName"/>
118+
<module name="StaticVariableName"/>
119+
<module name="TypeName"/>
120+
121+
<!-- Checks for imports -->
122+
<!-- See https://checkstyle.org/config_imports.html -->
123+
<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/config_sizes.html -->
132+
<module name="MethodLength"/>
133+
<module name="ParameterNumber"/>
134+
135+
<!-- Checks for whitespace -->
136+
<!-- See https://checkstyle.org/config_whitespace.html -->
137+
<module name="EmptyForIteratorPad"/>
138+
<module name="GenericWhitespace"/>
139+
<module name="MethodParamPad"/>
140+
<module name="NoWhitespaceAfter"/>
141+
<module name="NoWhitespaceBefore"/>
142+
<module name="OperatorWrap"/>
143+
<module name="ParenPad"/>
144+
<module name="TypecastParenPad"/>
145+
<module name="WhitespaceAfter"/>
146+
<module name="WhitespaceAround"/>
147+
148+
<!-- Modifier Checks -->
149+
<!-- See https://checkstyle.org/config_modifier.html -->
150+
<module name="ModifierOrder"/>
151+
<module name="RedundantModifier"/>
152+
153+
<!-- Checks for blocks. You know, those {}'s -->
154+
<!-- See https://checkstyle.org/config_blocks.html -->
155+
<module name="AvoidNestedBlocks"/>
156+
<module name="EmptyBlock"/>
157+
<module name="LeftCurly"/>
158+
<module name="NeedBraces"/>
159+
<module name="RightCurly"/>
160+
161+
<!-- Checks for common coding problems -->
162+
<!-- See https://checkstyle.org/config_coding.html -->
163+
<module name="EmptyStatement"/>
164+
<module name="EqualsHashCode"/>
165+
<module name="HiddenField"/>
166+
<module name="IllegalInstantiation"/>
167+
<module name="InnerAssignment"/>
168+
<module name="MagicNumber"/>
169+
<module name="MissingSwitchDefault"/>
170+
<module name="MultipleVariableDeclarations"/>
171+
<module name="SimplifyBooleanExpression"/>
172+
<module name="SimplifyBooleanReturn"/>
173+
174+
<!-- Checks for class design -->
175+
<!-- See https://checkstyle.org/config_design.html -->
176+
<module name="DesignForExtension"/>
177+
<module name="FinalClass"/>
178+
<module name="HideUtilityClassConstructor"/>
179+
<module name="InterfaceIsType"/>
180+
<module name="VisibilityModifier"/>
181+
182+
<!-- Miscellaneous other checks. -->
183+
<!-- See https://checkstyle.org/config_misc.html -->
184+
<module name="ArrayTypeStyle"/>
185+
<module name="FinalParameters"/>
186+
<module name="TodoComment"/>
187+
<module name="UpperEll"/>
188+
189+
<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
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>

0 commit comments

Comments
 (0)