Skip to content

Commit 18b0bce

Browse files
committed
Java 8 needs a special configuration
Newer version of Checkstyle have a different configuration syntax
1 parent a3adb3d commit 18b0bce

File tree

2 files changed

+240
-0
lines changed

2 files changed

+240
-0
lines changed

checkstyle-java8.xml

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
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+
Licensed to the Apache Software Foundation (ASF) under one or more
7+
contributor license agreements. See the NOTICE file distributed with
8+
this work for additional information regarding copyright ownership.
9+
The ASF licenses this file to You under the Apache License, Version 2.0
10+
(the "License"); you may not use this file except in compliance with
11+
the License. You may obtain a copy of the License at
12+
13+
http://www.apache.org/licenses/LICENSE-2.0
14+
15+
Unless required by applicable law or agreed to in writing, software
16+
distributed under the License is distributed on an "AS IS" BASIS,
17+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
See the License for the specific language governing permissions and
19+
limitations under the License.
20+
-->
21+
22+
<!-- Checkstyle configuration that checks the commons-configuration coding conventions -->
23+
24+
<module name="Checker">
25+
<property name="localeLanguage" value="en" />
26+
27+
<!-- Checks that a package-info.java file exists for each package. -->
28+
<!-- See https://checkstyle.org/config_javadoc.html#JavadocPackage -->
29+
<module name="JavadocPackage" />
30+
31+
<!-- Checks whether files end with a new line. -->
32+
<!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
33+
<module name="NewlineAtEndOfFile" />
34+
35+
<!-- Checks that property files contain the same keys. -->
36+
<!-- See https://checkstyle.org/config_misc.html#Translation -->
37+
<module name="Translation" />
38+
39+
<!-- Checks for Tab characters -->
40+
<!-- See https://checkstyle.org/config_whitespace.html#FileTabCharacter -->
41+
<module name="FileTabCharacter">
42+
<property name="fileExtensions" value="java" />
43+
</module>
44+
45+
<!-- Checks for white space at the end of the line -->
46+
<!-- See https://checkstyle.org/config_regexp.html#RegexpSingleline -->
47+
<module name="RegexpSingleline">
48+
<property name="format" value="\s+$" />
49+
<property name="message" value="Line has trailing spaces." />
50+
<property name="fileExtensions" value="java" />
51+
</module>
52+
53+
<!-- @author tags are deprecated -->
54+
<module name="RegexpSingleline">
55+
<property name="format" value="^\s+\*\s+@author\s" />
56+
<property name="message" value="Deprecated @author tag" />
57+
<property name="fileExtensions" value="java" />
58+
<property name="severity" value="warning" />
59+
</module>
60+
61+
<!-- Don't use SVN $Date$ variable - it's localized and causes source archives to differ from the SVN tag -->
62+
<module name="RegexpSingleline">
63+
<property name="format" value="\$Date.+\$" />
64+
<property name="message" value="Don't use SVN $Date$ variable" />
65+
<property name="fileExtensions" value="java" />
66+
<property name="severity" value="warning" />
67+
</module>
68+
69+
<!-- Checks for Size Violations. -->
70+
<!-- See https://checkstyle.org/config_sizes.html#LineLength -->
71+
<module name="LineLength">
72+
<property name="max" value="160" />
73+
</module>
74+
75+
<!-- Exceptions -->
76+
<!--<module name="SuppressionFilter">
77+
<property name="file" value="conf/checkstyle-suppressions.xml"/>
78+
</module> -->
79+
<module name="RegexpSingleline">
80+
<property name="format" value="\s+$"/>
81+
<property name="message" value="Line has trailing spaces."/>
82+
</module>
83+
84+
<module name="TreeWalker">
85+
86+
<module name="ExplicitInitializationCheck" />
87+
<module name="UnusedImports"/>
88+
<!-- Checks for Javadoc comments. -->
89+
<!-- See https://checkstyle.org/config_javadoc.html -->
90+
<module name="JavadocMethod">
91+
<property name="accessModifiers" value="public" />
92+
</module>
93+
<module name="MissingJavadocMethod"/>
94+
95+
<!-- https://checkstyle.org/config_javadoc.html#JavadocType -->
96+
<module name="JavadocType">
97+
<!-- It is unfortunate to have to do this but checkstyle doesn't allow custom tags -->
98+
<property name="allowUnknownTags" value="true" />
99+
</module>
100+
<module name="JavadocVariable">
101+
<property name="scope" value="protected" />
102+
</module>
103+
<module name="JavadocStyle">
104+
<property name="scope" value="public" />
105+
</module>
106+
107+
<!-- Checks for Naming Conventions. -->
108+
<!-- See https://checkstyle.org/config_naming.html -->
109+
<module name="ConstantName">
110+
<property name="format" value="^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$|^capabilities$|^log$" />
111+
</module>
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+
<!-- Following interprets the header file as regular expressions. -->
122+
<!-- <module name="RegexpHeader"/> -->
123+
124+
<!-- Checks for imports -->
125+
<!-- See https://checkstyle.org/config_imports.html -->
126+
<module name="AvoidStarImport" />
127+
<module name="IllegalImport" /> <!-- defaults to sun.* packages -->
128+
<module name="RedundantImport" />
129+
<module name="UnusedImports" />
130+
131+
<!-- Checks for Size Violations. -->
132+
<!-- See https://checkstyle.org/config_sizes.html -->
133+
<!--<module name="FileLength"/> -->
134+
<module name="MethodLength" />
135+
<module name="ParameterNumber">
136+
<property name="max" value="10" />
137+
</module>
138+
139+
<!-- Checks for whitespace -->
140+
<!-- See https://checkstyle.org/config_whitespace.html -->
141+
<module name="EmptyForIteratorPad" />
142+
<module name="NoWhitespaceAfter" />
143+
<module name="NoWhitespaceBefore" />
144+
<module name="OperatorWrap">
145+
<property name="tokens" value="ASSIGN" />
146+
<property name="option" value="eol" />
147+
</module>
148+
<module name="ParenPad" />
149+
<module name="WhitespaceAfter" />
150+
<module name="WhitespaceAround" />
151+
<module name="GenericWhitespace" />
152+
153+
<!-- Modifier Checks -->
154+
<!-- See https://checkstyle.org/config_modifier.html -->
155+
<module name="ModifierOrder" />
156+
<module name="RedundantModifier" />
157+
158+
<!-- Checks for blocks. You know, those {}'s -->
159+
<!-- See https://checkstyle.org/config_blocks.html -->
160+
<module name="AvoidNestedBlocks" />
161+
<!-- Require empty catch blocks to have at least a comment -->
162+
<module name="EmptyBlock">
163+
<property name="option" value="text" />
164+
<property name="tokens" value="LITERAL_CATCH" />
165+
</module>
166+
<module name="LeftCurly">
167+
<property name="option" value="eol" />
168+
</module>
169+
<module name="NeedBraces" />
170+
<module name="RightCurly">
171+
<property name="option" value="same" />
172+
</module>
173+
174+
<!-- Checks for common coding problems -->
175+
<!-- See https://checkstyle.org/config_coding.html -->
176+
<module name="CovariantEquals" />
177+
<module name="EqualsHashCode" />
178+
<module name="IllegalInstantiation" />
179+
<!-- <module name="InnerAssignment"/> -->
180+
<module name="MagicNumber">
181+
<property name="ignoreNumbers" value="-1,0,1,2,3" />
182+
</module>
183+
<module name="SimplifyBooleanExpression" />
184+
<module name="SimplifyBooleanReturn" />
185+
<module name="StringLiteralEquality" />
186+
<module name="SuperClone" />
187+
<module name="SuperFinalize" />
188+
<!-- Can't customize? -->
189+
<!-- <module name="DeclarationOrder" /> -->
190+
<!-- <property name="ignoreConstructors" value="true" /> -->
191+
<!-- </module> -->
192+
<!-- <module name="ExplicitInitialization"/> -->
193+
<module name="DefaultComesLast" />
194+
<module name="FallThrough" />
195+
<module name="MultipleVariableDeclarations" />
196+
<!-- <module name="UnnecessaryParentheses"/> -->
197+
198+
<!-- Checks for class design -->
199+
<!-- See https://checkstyle.org/config_design.html -->
200+
<module name="FinalClass" />
201+
<module name="HideUtilityClassConstructor" />
202+
<module name="InterfaceIsType" />
203+
<module name="VisibilityModifier">
204+
<property name="protectedAllowed" value="true" />
205+
</module>
206+
207+
<!-- Miscellaneous other checks. -->
208+
<!-- See https://checkstyle.org/config_misc.html -->
209+
<module name="ArrayTypeStyle" />
210+
<module name="TodoComment">
211+
<property name="severity" value="info" />
212+
</module>
213+
<module name="UpperEll" />
214+
<module name="ImportOrder">
215+
<property name="option" value="top"/>
216+
<property name="groups" value="java,javax,junit,org"/>
217+
<property name="ordered" value="true"/>
218+
<property name="separated" value="true"/>
219+
</module>
220+
<module name="TypecastParenPad" />
221+
</module>
222+
223+
</module>

pom.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,23 @@
657657
</plugins>
658658
</build>
659659
</profile>
660+
<profile>
661+
<id>java8</id>
662+
<activation>
663+
<jdk>1.8</jdk>
664+
</activation>
665+
<build>
666+
<plugins>
667+
<plugin>
668+
<groupId>org.apache.maven.plugins</groupId>
669+
<artifactId>maven-checkstyle-plugin</artifactId>
670+
<configuration>
671+
<configLocation>${commons.parent.dir}/checkstyle-java8.xml</configLocation>
672+
</configuration>
673+
</plugin>
674+
</plugins>
675+
</build>
676+
</profile>
660677
</profiles>
661678
<developers>
662679
<developer>

0 commit comments

Comments
 (0)