4 * Copyright 2001-2004 The Apache Software Foundation.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 <!DOCTYPE module PUBLIC
21 "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
22 "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
26 Checkstyle configuration that checks the sun coding conventions from:
28 - the Java Language Specification at
29 http://java.sun.com/docs/books/jls/second_edition/html/index.html
31 - the Sun Code Conventions at http://java.sun.com/docs/codeconv/
33 - the Javadoc guidelines at
34 http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
36 - the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html
40 Checkstyle is very configurable. Be sure to read the documentation at
41 http://checkstyle.sf.net (or in your downloaded distribution).
43 Most Checks are configurable, be sure to consult the documentation.
45 To completely disable a check, just comment it out or delete it from the file.
47 Finally, it is worth reading the documentation.
51 <module name="Checker">
53 <!-- Checks that a package.html file exists for each package. -->
54 <!-- See http://checkstyle.sf.net/config_javadoc.html#PackageHtml -->
55 <module name="PackageHtml">
56 <property name="severity" value="warning"/>
59 <!-- Checks whether files end with a new line. -->
60 <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
61 <module name="NewlineAtEndOfFile" >
62 <property name="severity" value="warning"/>
65 <!-- Checks that property files contain the same keys. -->
66 <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
67 <module name="Translation"/>
69 <module name="StrictDuplicateCode">
70 <property name="charset" value="UTF-8"/>
71 <property name="min" value="30"/>
75 <module name="TreeWalker">
77 <property name="cacheFile" value="${checkstyle.cache.file}"/>
79 <!-- Checks for Javadoc comments. -->
80 <!-- See http://checkstyle.sf.net/config_javadoc.html -->
81 <module name="JavadocMethod" >
82 <property name="severity" value="info"/>
84 <module name="JavadocType">
85 <property name="severity" value="info"/>
87 <module name="JavadocVariable">
88 <property name="severity" value="info"/>
90 <module name="JavadocStyle">
91 <property name="severity" value="info"/>
95 <!-- Checks for Naming Conventions. -->
96 <!-- See http://checkstyle.sf.net/config_naming.html -->
97 <module name="ConstantName">
98 <property name="severity" value="warning"/>
100 <module name="LocalFinalVariableName" />
101 <module name="LocalVariableName"/>
102 <module name="MemberName"/>
103 <module name="MethodName"/>
104 <module name="PackageName"/>
105 <module name="ParameterName"/>
106 <module name="StaticVariableName"/>
107 <module name="TypeName"/>
110 <!-- Checks for Headers -->
111 <!-- See http://checkstyle.sf.net/config_header.html -->
112 <module name="Header">
113 <property name="headerFile" value="site/java.header"/>
116 <!-- Following interprets the header file as regular expressions. -->
117 <!-- <module name="RegexpHeader"/> -->
120 <!-- Checks for imports -->
121 <!-- See http://checkstyle.sf.net/config_import.html -->
122 <module name="AvoidStarImport"/>
123 <module name="IllegalImport"/> <!-- defaults to sun.* packages -->
124 <module name="RedundantImport" >
125 <property name="severity" value="warning"/>
127 <module name="UnusedImports">
128 <property name="severity" value="warning"/>
132 <!-- Checks for Size Violations. -->
133 <!-- See http://checkstyle.sf.net/config_sizes.html -->
134 <module name="FileLength">
135 <property name="severity" value="warning"/>
137 <module name="LineLength" >
138 <property name="max" value="100"/>
140 <module name="MethodLength"/>
141 <module name="ParameterNumber"/>
144 <!-- Checks for whitespace -->
145 <!-- See http://checkstyle.sf.net/config_whitespace.html -->
146 <module name="EmptyForIteratorPad">
147 <property name="severity" value="warning"/>
149 <module name="MethodParamPad">
150 <property name="severity" value="warning"/>
152 <module name="NoWhitespaceAfter">
153 <property name="severity" value="warning"/>
155 <module name="NoWhitespaceBefore">
156 <property name="severity" value="warning"/>
158 <module name="OperatorWrap">
159 <property name="severity" value="warning"/>
161 <module name="ParenPad">
162 <property name="severity" value="warning"/>
164 <module name="TypecastParenPad">
165 <property name="severity" value="warning"/>
167 <module name="TabCharacter"/>
168 <module name="WhitespaceAfter"/>
169 <module name="WhitespaceAround">
170 <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN, TYPE_EXTENSION_AND"/>
174 <!-- Modifier Checks -->
175 <!-- See http://checkstyle.sf.net/config_modifiers.html -->
176 <module name="ModifierOrder">
177 <property name="severity" value="warning"/>
179 <module name="RedundantModifier"/>
182 <!-- Checks for blocks. You know, those {}'s -->
183 <!-- See http://checkstyle.sf.net/config_blocks.html -->
184 <module name="AvoidNestedBlocks">
185 <property name="severity" value="warning"/>
187 <module name="EmptyBlock">
188 <property name="severity" value="warning"/>
190 <module name="LeftCurly"/>
191 <module name="NeedBraces"/>
192 <module name="RightCurly"/>
195 <!-- Checks for common coding problems -->
196 <!-- See http://checkstyle.sf.net/config_coding.html -->
197 <module name="AvoidInlineConditionals">
198 <property name="severity" value="warning"/>
200 <module name="DoubleCheckedLocking"/> <!-- MY FAVOURITE -->
201 <module name="EmptyStatement"/>
202 <module name="EqualsHashCode"/>
203 <!-- <module name="HiddenField"/> -->
204 <module name="IllegalInstantiation"/>
205 <module name="InnerAssignment"/>
206 <module name="MagicNumber"/>
207 <module name="MissingSwitchDefault"/>
208 <module name="RedundantThrows"/>
209 <module name="SimplifyBooleanExpression"/>
210 <module name="SimplifyBooleanReturn"/>
212 <!-- Checks for class design -->
213 <!-- See http://checkstyle.sf.net/config_design.html -->
214 <!-- <module name="DesignForExtension"/> -->
215 <module name="FinalClass"/>
216 <module name="HideUtilityClassConstructor"/>
217 <module name="InterfaceIsType">
218 <property name="severity" value="warning"/>
220 <module name="VisibilityModifier"/>
224 <module name="ClassFanOutComplexity">
225 <property name="max" value="10"/>
226 <property name="severity" value="warning"/>
228 <module name="CyclomaticComplexity" >
229 <property name="severity" value="warning"/>
231 <module name="ClassDataAbstractionCoupling">
232 <property name="severity" value="warning"/>
234 <module name="BooleanExpressionComplexity">
235 <property name="max" value="7"/>
236 <property name="severity" value="warning"/>
238 <module name="NPathComplexity" >
239 <property name="severity" value="warning"/>
242 <module name="JavaNCSS">
243 <property name="severity" value="warning"/>
246 <!-- Miscellaneous other checks. -->
247 <!-- See http://checkstyle.sf.net/config_misc.html -->
248 <module name="ArrayTypeStyle"/>
250 <module name="FinalParameters"/>
252 <module name="GenericIllegalRegexp">
253 <property name="format" value="\s+$"/>
254 <property name="message" value="Line has trailing spaces."/>
257 <module name="TodoComment">
258 <property name="severity" value="info"/>
262 <module name="UpperEll"/>