1 <?xml version="1.0" encoding="UTF-8"?>
4 ~ ===============================LICENSE_START======================================
6 ~ ================================================================================
7 ~ Copyright © 2017 AT&T Intellectual Property. All rights reserved.
8 ~ ================================================================================
9 ~ Licensed under the Apache License, Version 2.0 (the "License");
10 ~ you may not use this file except in compliance with the License.
11 ~ You may obtain a copy of the License at
13 ~ http://www.apache.org/licenses/LICENSE-2.0
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 ~ ============================LICENSE_END===========================================
23 <!DOCTYPE module PUBLIC
24 "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
25 "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
27 <!-- This is a checkstyle configuration file. For descriptions of
28 what the following rules do, please see the checkstyle configuration
29 page at http://checkstyle.sourceforge.net/config.html -->
31 <module name="Checker">
36 COPYRIGHT HEADER CHECKS
41 <module name="FileTabCharacter">
42 <property name="severity" value="error"/>
43 <!-- Checks that there are no tab characters in the file. -->
48 LENGTH CHECKS FOR FILES
52 <module name="FileLength">
53 <property name="max" value="3000"/>
54 <property name="severity" value="warning"/>
58 <module name="NewlineAtEndOfFile">
59 <property name="lineSeparator" value="lf"/>
62 <module name="RegexpSingleline">
63 <!-- Checks that FIXME is not used in comments. TODO is preferred. -->
64 <property name="format" value="((//.*)|(\*.*))FIXME"/>
65 <property name="message"
66 value='TODO is preferred to FIXME. e.g. "TODO: (ENG-123) - Refactor when v2 is released."'/>
69 <module name="RegexpSingleline">
70 <!-- Checks that TODOs are named with some basic formatting. Checks for the following pattern TODO: (
72 <property name="format" value="((//.*)|(\*.*))TODO[^: (]"/>
73 <property name="message"
74 value='All TODOs should be named. e.g. "TODO: (ENG-123) - Refactor when v2 is released."'/>
77 <module name="JavadocPackage">
78 <!-- Checks that each Java package has a Javadoc file used for commenting.
79 Only allows a package-info.java, not package.html. -->
80 <property name="severity" value="error"/>
83 <!-- All Java AST specific tests live under TreeWalker module. -->
84 <module name="TreeWalker">
86 <!-- required for SupressionCommentFilter and SuppressWithNearbyCommentFilter -->
87 <module name="FileContentsHolder"/>
95 <module name="AvoidStarImport">
96 <property name="allowClassImports" value="false"/>
97 <property name="severity" value="error"/>
100 <module name="RedundantImport">
101 <!-- Checks for redundant import statements. -->
102 <property name="severity" value="error"/>
105 <module name="ImportOrder">
106 <!-- Checks for out of order import statements. -->
107 <property name="severity" value="error"/>
108 <property name="ordered" value="true"/>
109 <property name="groups" value="/([^j]|.[^a]|..[^v]|...[^a])/,/^javax?\./"/>
110 <!-- This ensures that static imports go to the end. -->
111 <property name="option" value="bottom"/>
112 <property name="tokens" value="STATIC_IMPORT, IMPORT"/>
115 <module name="IllegalImport">
116 <property name="illegalPkgs" value="junit.framework"/>
125 <module name="MethodLength">
126 <property name="tokens" value="METHOD_DEF"/>
127 <property name="max" value="300"/>
128 <property name="countEmpty" value="false"/>
129 <property name="severity" value="warning"/>
138 <!-- Checks for Javadoc comments. -->
139 <!-- See http://checkstyle.sf.net/config_javadoc.html -->
140 <module name="JavadocMethod">
141 <property name="scope" value="protected"/>
142 <property name="severity" value="error"/>
143 <property name="allowMissingJavadoc" value="true"/>
144 <property name="allowMissingParamTags" value="true"/>
145 <property name="allowMissingReturnTag" value="true"/>
146 <property name="allowMissingThrowsTags" value="true"/>
147 <property name="allowThrowsTagsForSubclasses" value="true"/>
148 <property name="allowUndeclaredRTE" value="true"/>
151 <module name="JavadocType">
152 <property name="scope" value="protected"/>
153 <property name="severity" value="error"/>
156 <module name="JavadocStyle">
157 <property name="severity" value="error"/>
166 <!-- Item 38 - Adhere to generally accepted naming conventions -->
168 <module name="PackageName">
169 <!-- Validates identifiers for package names against the
170 supplied expression. -->
171 <!-- Here the default checkstyle rule restricts package name parts to
172 seven characters, this is not in line with common practice at Google.
174 <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,})*$"/>
175 <property name="severity" value="error"/>
178 <module name="TypeNameCheck">
179 <!-- Validates static, final fields against the
180 expression "^[A-Z][a-zA-Z0-9]*$". -->
181 <metadata name="altname" value="TypeName"/>
182 <property name="severity" value="error"/>
185 <module name="ConstantNameCheck">
186 <!-- Validates non-private, static, final fields against the supplied
187 public/package final fields "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$". -->
188 <metadata name="altname" value="ConstantName"/>
189 <property name="applyToPublic" value="true"/>
190 <property name="applyToProtected" value="true"/>
191 <property name="applyToPackage" value="true"/>
192 <property name="applyToPrivate" value="false"/>
193 <property name="format" value="^([A-Z][A-Z0-9]*(_[A-Z0-9]+)*|FLAG_.*)$"/>
194 <message key="name.invalidPattern"
195 value="Variable ''{0}'' should be in ALL_CAPS (if it is a constant) or be private (otherwise)."/>
196 <property name="severity" value="error"/>
199 <module name="StaticVariableNameCheck">
200 <!-- Validates static, non-final fields against the supplied
201 expression "^[a-z][a-zA-Z0-9]*_?$". -->
202 <metadata name="altname" value="StaticVariableName"/>
203 <property name="applyToPublic" value="true"/>
204 <property name="applyToProtected" value="true"/>
205 <property name="applyToPackage" value="true"/>
206 <property name="applyToPrivate" value="true"/>
207 <property name="format" value="^[a-z][a-zA-Z0-9]*_?$"/>
208 <property name="severity" value="error"/>
211 <module name="MemberNameCheck">
212 <!-- Validates non-static members against the supplied expression. -->
213 <metadata name="altname" value="MemberName"/>
214 <property name="applyToPublic" value="true"/>
215 <property name="applyToProtected" value="true"/>
216 <property name="applyToPackage" value="true"/>
217 <property name="applyToPrivate" value="true"/>
218 <property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
219 <property name="severity" value="error"/>
222 <module name="MethodNameCheck">
223 <!-- Validates identifiers for method names. -->
224 <metadata name="altname" value="MethodName"/>
225 <property name="format" value="^[a-z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$"/>
226 <property name="severity" value="error"/>
229 <module name="ParameterName">
230 <!-- Validates identifiers for method parameters against the
231 expression "^[a-z][a-zA-Z0-9]*$". -->
232 <property name="severity" value="error"/>
235 <module name="LocalFinalVariableName">
236 <!-- Validates identifiers for local final variables against the
237 expression "^[a-z][a-zA-Z0-9]*$". -->
238 <property name="severity" value="error"/>
241 <module name="LocalVariableName">
242 <!-- Validates identifiers for local variables against the
243 expression "^[a-z][a-zA-Z0-9]*$". -->
244 <property name="severity" value="error"/>
250 LENGTH and CODING CHECKS
254 <module name="LineLength">
255 <!-- Checks if a line is too long. -->
256 <property name="max" value="120" default="120"/>
257 <property name="severity" value="error"/>
260 The default ignore pattern exempts the following elements:
262 - long URLs inside comments
265 <property name="ignorePattern"
266 value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
267 default="^(package .*;\s*)|(import .*;\s*)|( *\* *https?://.*)$"/>
270 <module name="LeftCurly">
271 <!-- Checks for placement of the left curly brace ('{'). -->
272 <property name="severity" value="error"/>
275 <module name="RightCurly">
276 <!-- Checks right curlies on CATCH, ELSE, and TRY blocks are on
277 the same line. e.g., the following example is fine:
284 <!-- This next example is not fine:
292 <property name="option" value="same"/>
293 <property name="severity" value="error"/>
296 <!-- Checks for braces around if and else blocks -->
297 <module name="NeedBraces">
298 <property name="severity" value="error"/>
299 <property name="tokens" value="LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO"/>
302 <module name="UpperEll">
303 <!-- Checks that long constants are defined with an upper ell.-->
304 <property name="severity" value="error"/>
307 <module name="FallThrough">
308 <!-- Warn about falling through to the next case statement. Similar to
309 javac -Xlint:fallthrough, but the check is suppressed if a single-line comment
310 on the last non-blank line preceding the fallen-into case contains 'fall through' (or
311 some other variants which we don't publicized to promote consistency).
313 <property name="reliefPattern"
314 value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on"/>
315 <property name="severity" value="error"/>
325 <module name="ModifierOrder">
326 <!-- Warn if modifier order is inconsistent with JLS3 8.1.1, 8.3.1, and
327 8.4.3. The prescribed order is:
328 public, protected, private, abstract, static, final, transient, volatile,
329 synchronized, native, strictfp
333 <module name="RedundantModifier">
334 <!-- Checks for redundant modifiers in:
335 - interface and annotation definitions,
336 - the final modifier on methods of final classes, and
337 - inner interface declarations that are declared as static.
347 <module name="GenericWhitespace"/>
349 <module name="WhitespaceAround">
350 <!-- Checks that various tokens are surrounded by whitespace.
351 This includes most binary operators and keywords followed
352 by regular or curly braces.
354 <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR,
355 BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN,
356 EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
357 LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
358 LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS,
359 MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION,
360 SL, SLIST, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN"/>
361 <property name="allowEmptyConstructors" value="true"/>
362 <property name="allowEmptyMethods" value="true"/>
363 <property name="severity" value="error"/>
366 <module name="WhitespaceAfter">
367 <!-- Checks that commas, semicolons and typecasts are followed by
370 <property name="tokens" value="COMMA, SEMI, TYPECAST"/>
371 <property name="severity" value="error"/>
374 <module name="NoWhitespaceAfter">
375 <!-- Checks that there is no whitespace after various unary operators.
376 Linebreaks are allowed.
378 <property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS,
380 <property name="allowLineBreaks" value="true"/>
381 <property name="severity" value="error"/>
384 <module name="NoWhitespaceBefore">
385 <!-- Checks that there is no whitespace before various unary operators.
386 Linebreaks are allowed.
388 <property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC"/>
389 <property name="allowLineBreaks" value="true"/>
390 <property name="severity" value="error"/>
393 <module name="ParenPad">
394 <!-- Checks that there is no whitespace before close parens or after
397 <property name="severity" value="error"/>
403 Optional suppression filter. It is optional because when running with Maven, it should be the
404 checkstyle plugin who provides it. It is only used when this file is used in IntelliJ.
406 <module name="SuppressionFilter">
407 <property name="file" value="suppressions.xml"/>
408 <property name="optional" value="true"/>
411 <module name="SuppressionCommentFilter">
412 <property name="offCommentFormat" value="CHECKSTYLE OFF: (.+)"/>
413 <property name="onCommentFormat" value="CHECKSTYLE ON"/>
414 <property name="checkFormat" value="Javadoc.*"/>
415 <property name="messageFormat" value="$1"/>