1 <?xml version="1.0" encoding="UTF-8"?>
4 ~ ================================================================================
5 ~ Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 ~ ================================================================================
7 ~ Licensed under the Apache License, Version 2.0 (the "License");
8 ~ you may not use this file except in compliance with the License.
9 ~ You may obtain a copy of the License at
11 ~ http://www.apache.org/licenses/LICENSE-2.0
13 ~ Unless required by applicable law or agreed to in writing, software
14 ~ distributed under the License is distributed on an "AS IS" BASIS,
15 ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 ~ See the License for the specific language governing permissions and
17 ~ limitations under the License.
18 ~ ============LICENSE_END=========================================================
22 <!DOCTYPE module PUBLIC
23 "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
24 "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
26 <!-- This is a checkstyle configuration file. For descriptions of
27 what the following rules do, please see the checkstyle configuration
28 page at http://checkstyle.sourceforge.net/config.html -->
30 <module name="Checker">
35 COPYRIGHT HEADER CHECKS
40 <module name="FileTabCharacter">
41 <property name="severity" value="error"/>
42 <!-- Checks that there are no tab characters in the file. -->
47 LENGTH CHECKS FOR FILES
51 <module name="FileLength">
52 <property name="max" value="3000"/>
53 <property name="severity" value="warning"/>
57 <module name="NewlineAtEndOfFile">
58 <property name="lineSeparator" value="lf"/>
61 <module name="RegexpSingleline">
62 <!-- Checks that FIXME is not used in comments. TODO is preferred. -->
63 <property name="format" value="((//.*)|(\*.*))FIXME"/>
64 <property name="message"
65 value='TODO is preferred to FIXME. e.g. "TODO: (ENG-123) - Refactor when v2 is released."'/>
68 <module name="RegexpSingleline">
69 <!-- Checks that TODOs are named with some basic formatting. Checks for the following pattern TODO: (
71 <property name="format" value="((//.*)|(\*.*))TODO[^: (]"/>
72 <property name="message"
73 value='All TODOs should be named. e.g. "TODO: (ENG-123) - Refactor when v2 is released."'/>
76 <module name="JavadocPackage">
77 <!-- Checks that each Java package has a Javadoc file used for commenting.
78 Only allows a package-info.java, not package.html. -->
79 <property name="severity" value="error"/>
82 <!-- All Java AST specific tests live under TreeWalker module. -->
83 <module name="TreeWalker">
85 <!-- required for SupressionCommentFilter and SuppressWithNearbyCommentFilter -->
86 <module name="FileContentsHolder"/>
94 <module name="AvoidStarImport">
95 <property name="allowClassImports" value="false"/>
96 <property name="severity" value="error"/>
99 <module name="RedundantImport">
100 <!-- Checks for redundant import statements. -->
101 <property name="severity" value="error"/>
105 <module name="ImportOrder">
106 <property name="severity" value="error"/>
107 <property name="ordered" value="true"/>
108 <property name="option" value="bottom"/>
109 <property name="tokens" value="STATIC_IMPORT, IMPORT"/>
113 <module name="IllegalImport">
114 <property name="illegalPkgs" value="junit.framework"/>
123 <module name="MethodLength">
124 <property name="tokens" value="METHOD_DEF"/>
125 <property name="max" value="300"/>
126 <property name="countEmpty" value="false"/>
127 <property name="severity" value="warning"/>
136 <!-- Checks for Javadoc comments. -->
137 <!-- See http://checkstyle.sf.net/config_javadoc.html -->
138 <module name="JavadocMethod">
139 <property name="scope" value="protected"/>
140 <property name="severity" value="error"/>
141 <property name="allowMissingJavadoc" value="true"/>
142 <property name="allowMissingParamTags" value="true"/>
143 <property name="allowMissingReturnTag" value="true"/>
144 <property name="allowMissingThrowsTags" value="true"/>
145 <property name="allowThrowsTagsForSubclasses" value="true"/>
146 <property name="allowUndeclaredRTE" value="true"/>
149 <module name="JavadocType">
150 <property name="scope" value="protected"/>
151 <property name="severity" value="error"/>
154 <module name="JavadocStyle">
155 <property name="severity" value="error"/>
164 <!-- Item 38 - Adhere to generally accepted naming conventions -->
166 <module name="PackageName">
167 <!-- Validates identifiers for package names against the
168 supplied expression. -->
169 <!-- Here the default checkstyle rule restricts package name parts to
170 seven characters, this is not in line with common practice at Google.
172 <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,})*$"/>
173 <property name="severity" value="error"/>
176 <module name="TypeNameCheck">
177 <!-- Validates static, final fields against the
178 expression "^[A-Z][a-zA-Z0-9]*$". -->
179 <metadata name="altname" value="TypeName"/>
180 <property name="severity" value="error"/>
183 <module name="ConstantNameCheck">
184 <!-- Validates non-private, static, final fields against the supplied
185 public/package final fields "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$". -->
186 <metadata name="altname" value="ConstantName"/>
187 <property name="applyToPublic" value="true"/>
188 <property name="applyToProtected" value="true"/>
189 <property name="applyToPackage" value="true"/>
190 <property name="applyToPrivate" value="false"/>
191 <property name="format" value="^log(ger)?|([A-Z][A-Z0-9]*(_[A-Z0-9]+)*|FLAG_.*)$"/>
192 <message key="name.invalidPattern"
193 value="Variable ''{0}'' should be in ALL_CAPS (if it is a constant) or be private (otherwise)."/>
194 <property name="severity" value="error"/>
197 <module name="StaticVariableNameCheck">
198 <!-- Validates static, non-final fields against the supplied
199 expression "^[a-z][a-zA-Z0-9]*_?$". -->
200 <metadata name="altname" value="StaticVariableName"/>
201 <property name="applyToPublic" value="true"/>
202 <property name="applyToProtected" value="true"/>
203 <property name="applyToPackage" value="true"/>
204 <property name="applyToPrivate" value="true"/>
205 <property name="format" value="^[a-z][a-zA-Z0-9]*_?$"/>
206 <property name="severity" value="error"/>
209 <module name="MemberNameCheck">
210 <!-- Validates non-static members against the supplied expression. -->
211 <metadata name="altname" value="MemberName"/>
212 <property name="applyToPublic" value="true"/>
213 <property name="applyToProtected" value="true"/>
214 <property name="applyToPackage" value="true"/>
215 <property name="applyToPrivate" value="true"/>
216 <property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
217 <property name="severity" value="error"/>
220 <module name="MethodNameCheck">
221 <!-- Validates identifiers for method names. -->
222 <metadata name="altname" value="MethodName"/>
223 <property name="format" value="^[a-z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$"/>
224 <property name="severity" value="error"/>
227 <module name="ParameterName">
228 <!-- Validates identifiers for method parameters against the
229 expression "^[a-z][a-zA-Z0-9]*$". -->
230 <property name="severity" value="error"/>
233 <module name="LocalFinalVariableName">
234 <!-- Validates identifiers for local final variables against the
235 expression "^[a-z][a-zA-Z0-9]*$". -->
236 <property name="severity" value="error"/>
239 <module name="LocalVariableName">
240 <!-- Validates identifiers for local variables against the
241 expression "^[a-z][a-zA-Z0-9]*$". -->
242 <property name="severity" value="error"/>
248 LENGTH and CODING CHECKS
252 <module name="LineLength">
253 <!-- Checks if a line is too long. -->
254 <property name="max" value="120" default="120"/>
255 <property name="severity" value="error"/>
258 The default ignore pattern exempts the following elements:
260 - long URLs inside comments
263 <property name="ignorePattern"
264 value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
265 default="^(package .*;\s*)|(import .*;\s*)|( *\* *https?://.*)$"/>
268 <module name="LeftCurly">
269 <!-- Checks for placement of the left curly brace ('{'). -->
270 <property name="severity" value="error"/>
273 <module name="RightCurly">
274 <!-- Checks right curlies on CATCH, ELSE, and TRY blocks are on
275 the same line. e.g., the following example is fine:
282 <!-- This next example is not fine:
290 <property name="option" value="same"/>
291 <property name="severity" value="error"/>
294 <!-- Checks for braces around if and else blocks -->
295 <module name="NeedBraces">
296 <property name="severity" value="error"/>
297 <property name="tokens" value="LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO"/>
300 <module name="UpperEll">
301 <!-- Checks that long constants are defined with an upper ell.-->
302 <property name="severity" value="error"/>
305 <module name="FallThrough">
306 <!-- Warn about falling through to the next case statement. Similar to
307 javac -Xlint:fallthrough, but the check is suppressed if a single-line comment
308 on the last non-blank line preceding the fallen-into case contains 'fall through' (or
309 some other variants which we don't publicized to promote consistency).
311 <property name="reliefPattern"
312 value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on"/>
313 <property name="severity" value="error"/>
323 <module name="ModifierOrder">
324 <!-- Warn if modifier order is inconsistent with JLS3 8.1.1, 8.3.1, and
325 8.4.3. The prescribed order is:
326 public, protected, private, abstract, static, final, transient, volatile,
327 synchronized, native, strictfp
331 <module name="RedundantModifier">
332 <!-- Checks for redundant modifiers in:
333 - interface and annotation definitions,
334 - the final modifier on methods of final classes, and
335 - inner interface declarations that are declared as static.
345 <module name="GenericWhitespace"/>
347 <module name="WhitespaceAround">
348 <!-- Checks that various tokens are surrounded by whitespace.
349 This includes most binary operators and keywords followed
350 by regular or curly braces.
352 <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR,
353 BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN,
354 EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
355 LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
356 LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS,
357 MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION,
358 SL, SLIST, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN"/>
359 <property name="allowEmptyConstructors" value="true"/>
360 <property name="allowEmptyMethods" value="true"/>
361 <property name="severity" value="error"/>
364 <module name="WhitespaceAfter">
365 <!-- Checks that commas, semicolons and typecasts are followed by
368 <property name="tokens" value="COMMA, SEMI, TYPECAST"/>
369 <property name="severity" value="error"/>
372 <module name="NoWhitespaceAfter">
373 <!-- Checks that there is no whitespace after various unary operators.
374 Linebreaks are allowed.
376 <property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS,
378 <property name="allowLineBreaks" value="true"/>
379 <property name="severity" value="error"/>
382 <module name="NoWhitespaceBefore">
383 <!-- Checks that there is no whitespace before various unary operators.
384 Linebreaks are allowed.
386 <property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC"/>
387 <property name="allowLineBreaks" value="true"/>
388 <property name="severity" value="error"/>
391 <module name="ParenPad">
392 <!-- Checks that there is no whitespace before close parens or after
395 <property name="severity" value="error"/>
401 Optional suppression filter. It is optional because when running with Maven, it should be the
402 checkstyle plugin who provides it. It is only used when this file is used in IntelliJ.
404 <module name="SuppressionFilter">
405 <property name="file" value="suppressions.xml"/>
406 <property name="optional" value="true"/>
409 <module name="SuppressionCommentFilter">
410 <property name="offCommentFormat" value="CHECKSTYLE OFF: (.+)"/>
411 <property name="onCommentFormat" value="CHECKSTYLE ON"/>
412 <property name="checkFormat" value="Javadoc.*"/>
413 <property name="messageFormat" value="$1"/>