blob: 6387d2bded608877bf200679cd6048d541243c4c [file] [log] [blame]
tom0eb04ca2014-08-25 14:34:51 -07001<?xml version="1.0"?>
alshabibab984662014-12-04 18:56:18 -08002<!--
Brian O'Connor5ab426f2016-04-09 01:19:45 -07003 ~ Copyright 2014-present Open Networking Laboratory
alshabibab984662014-12-04 18:56:18 -08004 ~
5 ~ Licensed under the Apache License, Version 2.0 (the "License");
6 ~ you may not use this file except in compliance with the License.
7 ~ You may obtain a copy of the License at
8 ~
9 ~ http://www.apache.org/licenses/LICENSE-2.0
10 ~
11 ~ Unless required by applicable law or agreed to in writing, software
12 ~ distributed under the License is distributed on an "AS IS" BASIS,
13 ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ~ See the License for the specific language governing permissions and
15 ~ limitations under the License.
16 -->
tom0eb04ca2014-08-25 14:34:51 -070017<!DOCTYPE module PUBLIC
18 "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
19 "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
20
21
22<!--
23
24 Checkstyle configuration that checks the sun coding conventions from:
25
26 - the Java Language Specification at
27 http://java.sun.com/docs/books/jls/second_edition/html/index.html
28
29 - the Sun Code Conventions at http://java.sun.com/docs/codeconv/
30
31 - the Javadoc guidelines at
32 http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
33
34 - the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html
35
36 - some best practices
37
38 Checkstyle is very configurable. Be sure to read the documentation at
39 http://checkstyle.sf.net (or in your downloaded distribution).
40
41 Most Checks are configurable, be sure to consult the documentation.
42
43 To completely disable a check, just comment it out or delete it from the file.
44
45 Finally, it is worth reading the documentation.
46
47-->
48
49
50<!--
51 The default severity setting in checkstyle is 'error', so some
52 of the rules below are configured to change the severity to
Ray Milkey85267002016-11-16 11:06:35 -080053 'warning'. Over time, these 'warning' settings should be
tom0eb04ca2014-08-25 14:34:51 -070054 removed as more of the ONOS source code is modified to
55 follow the recommended rules.
56-->
57
58
tom0eb04ca2014-08-25 14:34:51 -070059<module name="Checker">
60 <!--
61 If you set the basedir property below, then all reported file
62 names will be relative to the specified directory. See
63 http://checkstyle.sourceforge.net/5.x/config.html#Checker
64
65 <property name="basedir" value="${basedir}"/>
66 -->
67 <!-- Checks that a package-info.java file exists for each package. -->
68 <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage -->
Ray Milkeyccda0b52015-10-30 16:51:06 -070069 <module name="JavadocPackage"/>
tom0eb04ca2014-08-25 14:34:51 -070070
71 <!-- Checks whether files end with a new line. -->
72 <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
73 <module name="NewlineAtEndOfFile"/>
74
75 <!-- Checks that property files contain the same keys. -->
76 <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
77 <module name="Translation"/>
78
79 <!-- Checks for Size Violations. -->
80 <!-- See http://checkstyle.sf.net/config_sizes.html -->
81 <module name="FileLength"/>
82
83 <!-- Checks for whitespace -->
84 <!-- See http://checkstyle.sf.net/config_whitespace.html -->
85 <module name="FileTabCharacter"/>
86
87 <!-- Miscellaneous other checks. -->
88 <!-- See http://checkstyle.sf.net/config_misc.html -->
89 <module name="RegexpSingleline">
90 <property name="format" value="\s+$"/>
91 <property name="minimum" value="0"/>
92 <property name="maximum" value="0"/>
93 <property name="message" value="Line has trailing spaces."/>
94 </module>
95
Madan Jampanic27b6b22016-02-05 11:36:31 -080096 <module name="RegexpMultiline">
97 <property name="format" value="\r\n"/>
98 <property name="maximum" value="0"/>
99 <property name="message" value="Line has windows line endings."/>
100 </module>
101
tom0eb04ca2014-08-25 14:34:51 -0700102 <!-- Checks for Headers -->
103 <!-- See http://checkstyle.sf.net/config_header.html -->
104 <!-- <module name="Header"> -->
105 <!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
106 <!-- <property name="fileExtensions" value="java"/> -->
107 <!-- </module> -->
108
Ray Milkey85267002016-11-16 11:06:35 -0800109 <module name="RegexpHeader">
110 <property name="headerFile" value="tools/build/conf/src/main/resources/onos/onos-java.header"/>
111 </module>
112
113
tom0eb04ca2014-08-25 14:34:51 -0700114 <module name="SuppressionCommentFilter">
Brian O'Connor8b5edbc2016-04-05 15:45:25 -0700115 <property name="offCommentFormat"
116 value="(CHECKSTYLE\:OFF|Generated by the protocol buffer compiler.)"/>
tom0eb04ca2014-08-25 14:34:51 -0700117 <property name="onCommentFormat" value="CHECKSTYLE:ON"/>
118 </module>
119
120 <module name="SuppressWithNearbyCommentFilter">
Brian O'Connor8b5edbc2016-04-05 15:45:25 -0700121 <property name="commentFormat" value="CHECKSTYLE IGNORE THIS LINE"/>
122 <property name="checkFormat" value=".*"/>
123 <property name="influenceFormat" value="0"/>
tom0eb04ca2014-08-25 14:34:51 -0700124 </module>
125
126 <!-- Example: // CHECKSTYLE IGNORE FinalClass FOR NEXT 1 LINES -->
127 <module name="SuppressWithNearbyCommentFilter">
Brian O'Connor8b5edbc2016-04-05 15:45:25 -0700128 <property name="commentFormat"
129 value="CHECKSTYLE IGNORE (\w+) FOR NEXT (\d+) LINES"/>
tom0eb04ca2014-08-25 14:34:51 -0700130 <property name="checkFormat" value="$1"/>
131 <property name="influenceFormat" value="$2"/>
132 </module>
133
134 <module name="TreeWalker">
135
136 <module name="FileContentsHolder"/>
137 <!-- Checks for Javadoc comments. -->
138 <!-- See http://checkstyle.sf.net/config_javadoc.html -->
139 <module name="JavadocMethod">
Ray Milkey0bb1e102016-11-10 14:51:27 -0800140 <property name="scope" value="package"/>
141 <property name="allowMissingJavadoc" value="true"/>
tom0eb04ca2014-08-25 14:34:51 -0700142 <property name="allowUndeclaredRTE" value="true"/>
Ray Milkey0bb1e102016-11-10 14:51:27 -0800143 <property name="suppressLoadErrors" value="true"/>
tom0eb04ca2014-08-25 14:34:51 -0700144 </module>
145 <module name="JavadocType">
146 <property name="severity" value="warning"/>
147 </module>
148 <module name="JavadocVariable">
149 <!-- Suppress check for private member Javadocs.
150 Possibly revist fixing these. -->
151 <property name="scope" value="public"/>
152 <property name="severity" value="warning"/>
153 </module>
154 <module name="JavadocStyle"/>
Brian O'Connor8b5edbc2016-04-05 15:45:25 -0700155 <!-- @author tag should not be used -->
tom0eb04ca2014-08-25 14:34:51 -0700156 <module name="WriteTag">
157 <property name="tag" value="@author"/>
158 <property name="tagFormat" value="\S"/>
159 <property name="severity" value="ignore"/>
160 <property name="tagSeverity" value="error"/>
161 </module>
162
Jonathan Hart51539b82015-10-29 09:53:04 -0700163 <module name="AbbreviationAsWordInName">
Brian O'Connor8b5edbc2016-04-05 15:45:25 -0700164 <property name="allowedAbbreviationLength" value="2"/>
Jonathan Hart51539b82015-10-29 09:53:04 -0700165 </module>
tom0eb04ca2014-08-25 14:34:51 -0700166
167 <!-- Checks for Naming Conventions. -->
168 <!-- See http://checkstyle.sf.net/config_naming.html -->
169 <module name="ConstantName">
170 <!-- ONOS allows the name "log" for static final Loggers -->
171 <property name="format"
172 value="^log$|^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
173 </module>
174 <module name="LocalFinalVariableName"/>
175
176 <module name="LocalVariableName"/>
177
178 <module name="MemberName"/>
179 <module name="MethodName"/>
Jonathan Hart317f4762015-11-09 16:05:36 -0800180 <module name="PackageName">
181 <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
182 </module>
tom0eb04ca2014-08-25 14:34:51 -0700183 <module name="ParameterName"/>
184 <module name="StaticVariableName"/>
185 <module name="TypeName"/>
186
187 <!-- Checks for imports -->
188 <!-- See http://checkstyle.sf.net/config_import.html -->
189 <module name="AvoidStarImport">
Brian O'Connor8b5edbc2016-04-05 15:45:25 -0700190 <property name="allowStaticMemberImports" value="true"/>
tom0eb04ca2014-08-25 14:34:51 -0700191 </module>
192 <module name="IllegalImport"/>
193 <!-- defaults to sun.* packages -->
194 <module name="RedundantImport"/>
195 <module name="UnusedImports"/>
196
197
198 <!-- Checks for Size Violations. -->
199 <!-- See http://checkstyle.sf.net/config_sizes.html -->
200 <module name="LineLength">
201 <!-- ONOS standard usage is 80 columns, but we allow up
202 to 120 to not break the build. -->
203 <property name="max" value="120"/>
204 <property name="ignorePattern" value="^import"/>
205 </module>
206 <module name="MethodLength">
207 <property name="max" value="200"/>
208 </module>
209
alshabib6b5cfec2014-09-18 17:42:18 -0700210 <module name="ParameterNumber">
alshabibba5ac482014-10-02 17:15:20 -0700211 <property name="max" value="15"/>
alshabib6b5cfec2014-09-18 17:42:18 -0700212 <property name="tokens" value="CTOR_DEF"/>
213 </module>
tom0eb04ca2014-08-25 14:34:51 -0700214 <!-- Checks for whitespace -->
215 <!-- See http://checkstyle.sf.net/config_whitespace.html -->
216 <module name="EmptyForIteratorPad"/>
217 <module name="GenericWhitespace"/>
218 <module name="MethodParamPad"/>
219 <module name="NoWhitespaceAfter"/>
220 <module name="NoWhitespaceBefore"/>
221
222 <!-- Disabled for ONOS. Default rules specify undesired behavior for the '?' operator -->
223 <!-- <module name="OperatorWrap"/> -->
224 <module name="ParenPad"/>
225 <module name="TypecastParenPad"/>
226 <module name="WhitespaceAfter"/>
227 <module name="WhitespaceAround">
228 <property name="allowEmptyConstructors" value="true"/>
229 <property name="allowEmptyMethods" value="true"/>
230 </module>
231
232
tom0eb04ca2014-08-25 14:34:51 -0700233 <!-- Modifier Checks -->
234 <!-- See http://checkstyle.sf.net/config_modifiers.html -->
235 <module name="ModifierOrder"/>
236
237 <!-- Disabled for ONOS to allow use of public -->
238 <!-- modifiers in interfaces. -->
239 <!-- <module name="RedundantModifier"/> -->
240
241
242 <!-- Checks for blocks. You know, those {}'s -->
243 <!-- See http://checkstyle.sf.net/config_blocks.html -->
244 <module name="AvoidNestedBlocks">
245 <!-- ONOS alows declarations inside of switch case blocks -->
246 <property name="allowInSwitchCase" value="true"/>
247 </module>
HIGUCHI Yuta94a9eed2015-09-25 15:20:04 -0700248 <module name="EmptyBlock">
249 <!-- allow empty block, as long as there's some comment -->
250 <property name="option" value="text"/>
251 </module>
tom0eb04ca2014-08-25 14:34:51 -0700252 <module name="LeftCurly"/>
253 <module name="NeedBraces"/>
254 <module name="RightCurly"/>
255
256 <!-- Checks for common coding problems -->
257 <!-- See http://checkstyle.sf.net/config_coding.html -->
258 <!-- ONOS allows conditional operators -->
259 <!-- <module name="AvoidInlineConditionals"/> -->
260 <module name="EmptyStatement"/>
261 <module name="EqualsHashCode"/>
262
263 <module name="HiddenField">
264 <property name="ignoreSetter" value="true"/>
265 <property name="ignoreConstructorParameter" value="true"/>
266 </module>
267
268 <module name="IllegalInstantiation"/>
269 <module name="InnerAssignment"/>
270
271 <!-- Many violations of this rule present, revist in a
272 subsequent round of cleanups -->
273 <!-- <module name="MagicNumber"/> -->
274 <module name="MissingSwitchDefault"/>
275
tom0eb04ca2014-08-25 14:34:51 -0700276 <module name="SimplifyBooleanExpression"/>
277 <module name="SimplifyBooleanReturn"/>
278
279 <!-- Checks for class design -->
280 <!-- See http://checkstyle.sf.net/config_design.html -->
281 <!-- ONOS produces many warnings of this type.
282 Fixing all of these is outside the scope of the current cleanup. -->
283 <!-- <module name="DesignForExtension"/> -->
284 <module name="FinalClass"/>
285
286 <module name="HideUtilityClassConstructor"/>
287
288 <module name="InterfaceIsType"/>
289
290 <module name="VisibilityModifier">
291 <property name="severity" value="warning"/>
292 </module>
293
294
tom0eb04ca2014-08-25 14:34:51 -0700295 <!-- Miscellaneous other checks. -->
296 <!-- See http://checkstyle.sf.net/config_misc.html -->
297 <module name="ArrayTypeStyle"/>
298
299 <!-- Many violations of this rule currently, too many to fix
300 in the current cleanup. -->
301 <!-- <module name="FinalParameters"/> -->
302 <!-- ONOS allows TODO markers in checked in source code -->
303 <!-- <module name="TodoComment"/> -->
304 <module name="UpperEll"/>
tom0eb04ca2014-08-25 14:34:51 -0700305 </module>
Brian O'Connor8b5edbc2016-04-05 15:45:25 -0700306
307</module>