blob: ce6351f205f862a3dfc1815282776a0bd08f7296 [file] [log] [blame]
tom0eb04ca2014-08-25 14:34:51 -07001<?xml version="1.0"?>
alshabibab984662014-12-04 18:56:18 -08002<!--
Brian O'Connora09fe5b2017-08-03 21:12:30 -07003 ~ Copyright 2014-present Open Networking Foundation
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
Ray Milkey6a51cb92018-03-06 09:03:03 -0800102 <!-- Don't allow usage of deprecated Throwables propagate methods -->
103 <module name="RegexpSingleline">
104 <property name="format" value="Throwables.propagate.*\("/>
105 <property name="minimum" value="0"/>
106 <property name="maximum" value="0"/>
107 <property name="message" value="Throwables propagate methods have been deprecated."/>
108 </module>
109
Ray Milkeyca188042018-04-05 16:57:01 -0700110 <!-- Don't allow usage of Oracle JDK only javafx classes -->
111 <module name="RegexpSingleline">
112 <property name="format" value="javafx.*"/>
113 <property name="minimum" value="0"/>
114 <property name="maximum" value="0"/>
115 <property name="message" value="javafx classes are not supported by all JDKs."/>
116 </module>
117
tom0eb04ca2014-08-25 14:34:51 -0700118 <!-- Checks for Headers -->
119 <!-- See http://checkstyle.sf.net/config_header.html -->
120 <!-- <module name="Header"> -->
121 <!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
122 <!-- <property name="fileExtensions" value="java"/> -->
123 <!-- </module> -->
124
Ray Milkey85267002016-11-16 11:06:35 -0800125 <module name="RegexpHeader">
126 <property name="headerFile" value="tools/build/conf/src/main/resources/onos/onos-java.header"/>
Ray Milkey2d572dd2017-04-14 10:01:24 -0700127 <property name="fileExtensions" value="java"/>
Ray Milkey85267002016-11-16 11:06:35 -0800128 </module>
129
130
tom0eb04ca2014-08-25 14:34:51 -0700131 <module name="SuppressionCommentFilter">
Brian O'Connor8b5edbc2016-04-05 15:45:25 -0700132 <property name="offCommentFormat"
133 value="(CHECKSTYLE\:OFF|Generated by the protocol buffer compiler.)"/>
tom0eb04ca2014-08-25 14:34:51 -0700134 <property name="onCommentFormat" value="CHECKSTYLE:ON"/>
135 </module>
136
137 <module name="SuppressWithNearbyCommentFilter">
Brian O'Connor8b5edbc2016-04-05 15:45:25 -0700138 <property name="commentFormat" value="CHECKSTYLE IGNORE THIS LINE"/>
139 <property name="checkFormat" value=".*"/>
140 <property name="influenceFormat" value="0"/>
tom0eb04ca2014-08-25 14:34:51 -0700141 </module>
142
143 <!-- Example: // CHECKSTYLE IGNORE FinalClass FOR NEXT 1 LINES -->
144 <module name="SuppressWithNearbyCommentFilter">
Brian O'Connor8b5edbc2016-04-05 15:45:25 -0700145 <property name="commentFormat"
146 value="CHECKSTYLE IGNORE (\w+) FOR NEXT (\d+) LINES"/>
tom0eb04ca2014-08-25 14:34:51 -0700147 <property name="checkFormat" value="$1"/>
148 <property name="influenceFormat" value="$2"/>
149 </module>
150
151 <module name="TreeWalker">
152
153 <module name="FileContentsHolder"/>
154 <!-- Checks for Javadoc comments. -->
155 <!-- See http://checkstyle.sf.net/config_javadoc.html -->
156 <module name="JavadocMethod">
Ray Milkey0bb1e102016-11-10 14:51:27 -0800157 <property name="scope" value="package"/>
Yuta HIGUCHI9312a802017-06-12 20:01:27 -0700158 <property name="allowMissingJavadoc" value="true"/>
tom0eb04ca2014-08-25 14:34:51 -0700159 <property name="allowUndeclaredRTE" value="true"/>
Yuta HIGUCHI9312a802017-06-12 20:01:27 -0700160 <property name="suppressLoadErrors" value="true"/>
tom0eb04ca2014-08-25 14:34:51 -0700161 </module>
162 <module name="JavadocType">
163 <property name="severity" value="warning"/>
164 </module>
165 <module name="JavadocVariable">
166 <!-- Suppress check for private member Javadocs.
167 Possibly revist fixing these. -->
168 <property name="scope" value="public"/>
169 <property name="severity" value="warning"/>
170 </module>
171 <module name="JavadocStyle"/>
Brian O'Connor8b5edbc2016-04-05 15:45:25 -0700172 <!-- @author tag should not be used -->
tom0eb04ca2014-08-25 14:34:51 -0700173 <module name="WriteTag">
174 <property name="tag" value="@author"/>
175 <property name="tagFormat" value="\S"/>
176 <property name="severity" value="ignore"/>
177 <property name="tagSeverity" value="error"/>
178 </module>
179
Jonathan Hart51539b82015-10-29 09:53:04 -0700180 <module name="AbbreviationAsWordInName">
Brian O'Connor8b5edbc2016-04-05 15:45:25 -0700181 <property name="allowedAbbreviationLength" value="2"/>
Jonathan Hart51539b82015-10-29 09:53:04 -0700182 </module>
tom0eb04ca2014-08-25 14:34:51 -0700183
184 <!-- Checks for Naming Conventions. -->
185 <!-- See http://checkstyle.sf.net/config_naming.html -->
186 <module name="ConstantName">
187 <!-- ONOS allows the name "log" for static final Loggers -->
188 <property name="format"
189 value="^log$|^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
190 </module>
191 <module name="LocalFinalVariableName"/>
192
193 <module name="LocalVariableName"/>
194
195 <module name="MemberName"/>
196 <module name="MethodName"/>
Jonathan Hart317f4762015-11-09 16:05:36 -0800197 <module name="PackageName">
198 <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
199 </module>
tom0eb04ca2014-08-25 14:34:51 -0700200 <module name="ParameterName"/>
201 <module name="StaticVariableName"/>
202 <module name="TypeName"/>
203
204 <!-- Checks for imports -->
205 <!-- See http://checkstyle.sf.net/config_import.html -->
206 <module name="AvoidStarImport">
Brian O'Connor8b5edbc2016-04-05 15:45:25 -0700207 <property name="allowStaticMemberImports" value="true"/>
tom0eb04ca2014-08-25 14:34:51 -0700208 </module>
209 <module name="IllegalImport"/>
210 <!-- defaults to sun.* packages -->
211 <module name="RedundantImport"/>
212 <module name="UnusedImports"/>
213
214
215 <!-- Checks for Size Violations. -->
216 <!-- See http://checkstyle.sf.net/config_sizes.html -->
217 <module name="LineLength">
218 <!-- ONOS standard usage is 80 columns, but we allow up
219 to 120 to not break the build. -->
220 <property name="max" value="120"/>
221 <property name="ignorePattern" value="^import"/>
222 </module>
223 <module name="MethodLength">
224 <property name="max" value="200"/>
225 </module>
226
alshabib6b5cfec2014-09-18 17:42:18 -0700227 <module name="ParameterNumber">
alshabibba5ac482014-10-02 17:15:20 -0700228 <property name="max" value="15"/>
alshabib6b5cfec2014-09-18 17:42:18 -0700229 <property name="tokens" value="CTOR_DEF"/>
230 </module>
tom0eb04ca2014-08-25 14:34:51 -0700231 <!-- Checks for whitespace -->
232 <!-- See http://checkstyle.sf.net/config_whitespace.html -->
233 <module name="EmptyForIteratorPad"/>
234 <module name="GenericWhitespace"/>
235 <module name="MethodParamPad"/>
236 <module name="NoWhitespaceAfter"/>
237 <module name="NoWhitespaceBefore"/>
238
239 <!-- Disabled for ONOS. Default rules specify undesired behavior for the '?' operator -->
240 <!-- <module name="OperatorWrap"/> -->
241 <module name="ParenPad"/>
242 <module name="TypecastParenPad"/>
243 <module name="WhitespaceAfter"/>
244 <module name="WhitespaceAround">
245 <property name="allowEmptyConstructors" value="true"/>
246 <property name="allowEmptyMethods" value="true"/>
247 </module>
248
249
tom0eb04ca2014-08-25 14:34:51 -0700250 <!-- Modifier Checks -->
251 <!-- See http://checkstyle.sf.net/config_modifiers.html -->
252 <module name="ModifierOrder"/>
253
254 <!-- Disabled for ONOS to allow use of public -->
255 <!-- modifiers in interfaces. -->
256 <!-- <module name="RedundantModifier"/> -->
257
258
259 <!-- Checks for blocks. You know, those {}'s -->
260 <!-- See http://checkstyle.sf.net/config_blocks.html -->
261 <module name="AvoidNestedBlocks">
262 <!-- ONOS alows declarations inside of switch case blocks -->
263 <property name="allowInSwitchCase" value="true"/>
264 </module>
HIGUCHI Yuta94a9eed2015-09-25 15:20:04 -0700265 <module name="EmptyBlock">
266 <!-- allow empty block, as long as there's some comment -->
267 <property name="option" value="text"/>
268 </module>
tom0eb04ca2014-08-25 14:34:51 -0700269 <module name="LeftCurly"/>
270 <module name="NeedBraces"/>
271 <module name="RightCurly"/>
272
273 <!-- Checks for common coding problems -->
274 <!-- See http://checkstyle.sf.net/config_coding.html -->
275 <!-- ONOS allows conditional operators -->
276 <!-- <module name="AvoidInlineConditionals"/> -->
277 <module name="EmptyStatement"/>
278 <module name="EqualsHashCode"/>
279
280 <module name="HiddenField">
281 <property name="ignoreSetter" value="true"/>
282 <property name="ignoreConstructorParameter" value="true"/>
283 </module>
284
285 <module name="IllegalInstantiation"/>
286 <module name="InnerAssignment"/>
287
288 <!-- Many violations of this rule present, revist in a
289 subsequent round of cleanups -->
290 <!-- <module name="MagicNumber"/> -->
291 <module name="MissingSwitchDefault"/>
292
tom0eb04ca2014-08-25 14:34:51 -0700293 <module name="SimplifyBooleanExpression"/>
294 <module name="SimplifyBooleanReturn"/>
295
296 <!-- Checks for class design -->
297 <!-- See http://checkstyle.sf.net/config_design.html -->
298 <!-- ONOS produces many warnings of this type.
299 Fixing all of these is outside the scope of the current cleanup. -->
300 <!-- <module name="DesignForExtension"/> -->
301 <module name="FinalClass"/>
302
303 <module name="HideUtilityClassConstructor"/>
304
305 <module name="InterfaceIsType"/>
306
307 <module name="VisibilityModifier">
308 <property name="severity" value="warning"/>
309 </module>
310
311
tom0eb04ca2014-08-25 14:34:51 -0700312 <!-- Miscellaneous other checks. -->
313 <!-- See http://checkstyle.sf.net/config_misc.html -->
314 <module name="ArrayTypeStyle"/>
315
316 <!-- Many violations of this rule currently, too many to fix
317 in the current cleanup. -->
318 <!-- <module name="FinalParameters"/> -->
319 <!-- ONOS allows TODO markers in checked in source code -->
320 <!-- <module name="TodoComment"/> -->
321 <module name="UpperEll"/>
tom0eb04ca2014-08-25 14:34:51 -0700322 </module>
Brian O'Connor8b5edbc2016-04-05 15:45:25 -0700323
324</module>