blob: 68334864eed7a0719d38c0444f9a58003ad1d475 [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
Ray Milkeydbd38212018-07-02 09:18:09 -0700118 <!-- Don't allow usage of RuntimeException -->
119 <module name="RegexpSingleline">
120 <property name="format" value="throw[ ]*new[ ]*RuntimeException"/>
121 <property name="minimum" value="0"/>
122 <property name="maximum" value="0"/>
123 <property name="message" value="Don't throw generic exception types"/>
124 </module>
125
tom0eb04ca2014-08-25 14:34:51 -0700126 <!-- Checks for Headers -->
127 <!-- See http://checkstyle.sf.net/config_header.html -->
128 <!-- <module name="Header"> -->
129 <!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
130 <!-- <property name="fileExtensions" value="java"/> -->
131 <!-- </module> -->
132
Ray Milkeyb7949e72018-06-19 18:31:02 -0700133 <module name="SuppressionFilter">
134 <property name="file" value="tools/build/conf/src/main/resources/onos/suppressions.xml"/>
135 </module>
136
Ray Milkey85267002016-11-16 11:06:35 -0800137 <module name="RegexpHeader">
Yuta HIGUCHIe7e71a82018-05-18 16:36:43 -0700138 <!-- The following line is different for maven due to how the maven checkstyle plugin works -->
Ray Milkey85267002016-11-16 11:06:35 -0800139 <property name="headerFile" value="tools/build/conf/src/main/resources/onos/onos-java.header"/>
Ray Milkey2d572dd2017-04-14 10:01:24 -0700140 <property name="fileExtensions" value="java"/>
Ray Milkey85267002016-11-16 11:06:35 -0800141 </module>
142
Yuta HIGUCHIe7e71a82018-05-18 16:36:43 -0700143 <module name="SuppressWarningsFilter" />
Ray Milkey85267002016-11-16 11:06:35 -0800144
Yuta HIGUCHIe7e71a82018-05-18 16:36:43 -0700145 <module name="SuppressWithPlainTextCommentFilter"/>
tom0eb04ca2014-08-25 14:34:51 -0700146
147 <module name="TreeWalker">
Yuta HIGUCHIe7e71a82018-05-18 16:36:43 -0700148 <module name="SuppressWarningsHolder" />
tom0eb04ca2014-08-25 14:34:51 -0700149
Yuta HIGUCHIe7e71a82018-05-18 16:36:43 -0700150 <module name="SuppressionCommentFilter">
151 <property name="offCommentFormat"
152 value="(CHECKSTYLE\:OFF|Generated by the protocol buffer compiler.)"/>
153 <property name="onCommentFormat" value="CHECKSTYLE:ON"/>
154 </module>
155
156 <module name="SuppressWithNearbyCommentFilter">
157 <property name="commentFormat" value="CHECKSTYLE IGNORE THIS LINE"/>
158 <property name="checkFormat" value=".*"/>
159 <property name="influenceFormat" value="0"/>
160 </module>
161
162 <!-- Example: // CHECKSTYLE IGNORE FinalClass FOR NEXT 1 LINES -->
163 <module name="SuppressWithNearbyCommentFilter">
164 <property name="commentFormat"
165 value="CHECKSTYLE IGNORE (\w+) FOR NEXT (\d+) LINES"/>
166 <property name="checkFormat" value="$1"/>
167 <property name="influenceFormat" value="$2"/>
168 </module>
169
tom0eb04ca2014-08-25 14:34:51 -0700170 <!-- Checks for Javadoc comments. -->
171 <!-- See http://checkstyle.sf.net/config_javadoc.html -->
172 <module name="JavadocMethod">
Ray Milkey0bb1e102016-11-10 14:51:27 -0800173 <property name="scope" value="package"/>
Yuta HIGUCHI9312a802017-06-12 20:01:27 -0700174 <property name="allowMissingJavadoc" value="true"/>
tom0eb04ca2014-08-25 14:34:51 -0700175 <property name="allowUndeclaredRTE" value="true"/>
Yuta HIGUCHI9312a802017-06-12 20:01:27 -0700176 <property name="suppressLoadErrors" value="true"/>
tom0eb04ca2014-08-25 14:34:51 -0700177 </module>
178 <module name="JavadocType">
Ray Milkeyb7949e72018-06-19 18:31:02 -0700179 <property name="severity" value="ignore"/>
tom0eb04ca2014-08-25 14:34:51 -0700180 </module>
181 <module name="JavadocVariable">
182 <!-- Suppress check for private member Javadocs.
183 Possibly revist fixing these. -->
184 <property name="scope" value="public"/>
Ray Milkeyb7949e72018-06-19 18:31:02 -0700185 <property name="severity" value="ignore"/>
tom0eb04ca2014-08-25 14:34:51 -0700186 </module>
187 <module name="JavadocStyle"/>
Brian O'Connor8b5edbc2016-04-05 15:45:25 -0700188 <!-- @author tag should not be used -->
tom0eb04ca2014-08-25 14:34:51 -0700189 <module name="WriteTag">
190 <property name="tag" value="@author"/>
191 <property name="tagFormat" value="\S"/>
192 <property name="severity" value="ignore"/>
193 <property name="tagSeverity" value="error"/>
194 </module>
195
Jonathan Hart51539b82015-10-29 09:53:04 -0700196 <module name="AbbreviationAsWordInName">
Brian O'Connor8b5edbc2016-04-05 15:45:25 -0700197 <property name="allowedAbbreviationLength" value="2"/>
Jonathan Hart51539b82015-10-29 09:53:04 -0700198 </module>
tom0eb04ca2014-08-25 14:34:51 -0700199
200 <!-- Checks for Naming Conventions. -->
201 <!-- See http://checkstyle.sf.net/config_naming.html -->
202 <module name="ConstantName">
203 <!-- ONOS allows the name "log" for static final Loggers -->
204 <property name="format"
205 value="^log$|^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
206 </module>
207 <module name="LocalFinalVariableName"/>
208
209 <module name="LocalVariableName"/>
210
211 <module name="MemberName"/>
212 <module name="MethodName"/>
Jonathan Hart317f4762015-11-09 16:05:36 -0800213 <module name="PackageName">
214 <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
215 </module>
tom0eb04ca2014-08-25 14:34:51 -0700216 <module name="ParameterName"/>
217 <module name="StaticVariableName"/>
218 <module name="TypeName"/>
219
220 <!-- Checks for imports -->
221 <!-- See http://checkstyle.sf.net/config_import.html -->
222 <module name="AvoidStarImport">
Brian O'Connor8b5edbc2016-04-05 15:45:25 -0700223 <property name="allowStaticMemberImports" value="true"/>
tom0eb04ca2014-08-25 14:34:51 -0700224 </module>
225 <module name="IllegalImport"/>
226 <!-- defaults to sun.* packages -->
227 <module name="RedundantImport"/>
228 <module name="UnusedImports"/>
229
230
231 <!-- Checks for Size Violations. -->
232 <!-- See http://checkstyle.sf.net/config_sizes.html -->
233 <module name="LineLength">
234 <!-- ONOS standard usage is 80 columns, but we allow up
235 to 120 to not break the build. -->
236 <property name="max" value="120"/>
237 <property name="ignorePattern" value="^import"/>
238 </module>
239 <module name="MethodLength">
240 <property name="max" value="200"/>
241 </module>
242
alshabib6b5cfec2014-09-18 17:42:18 -0700243 <module name="ParameterNumber">
alshabibba5ac482014-10-02 17:15:20 -0700244 <property name="max" value="15"/>
alshabib6b5cfec2014-09-18 17:42:18 -0700245 <property name="tokens" value="CTOR_DEF"/>
246 </module>
tom0eb04ca2014-08-25 14:34:51 -0700247 <!-- Checks for whitespace -->
248 <!-- See http://checkstyle.sf.net/config_whitespace.html -->
249 <module name="EmptyForIteratorPad"/>
250 <module name="GenericWhitespace"/>
251 <module name="MethodParamPad"/>
252 <module name="NoWhitespaceAfter"/>
253 <module name="NoWhitespaceBefore"/>
254
255 <!-- Disabled for ONOS. Default rules specify undesired behavior for the '?' operator -->
256 <!-- <module name="OperatorWrap"/> -->
257 <module name="ParenPad"/>
258 <module name="TypecastParenPad"/>
259 <module name="WhitespaceAfter"/>
260 <module name="WhitespaceAround">
261 <property name="allowEmptyConstructors" value="true"/>
262 <property name="allowEmptyMethods" value="true"/>
263 </module>
264
265
tom0eb04ca2014-08-25 14:34:51 -0700266 <!-- Modifier Checks -->
267 <!-- See http://checkstyle.sf.net/config_modifiers.html -->
268 <module name="ModifierOrder"/>
269
270 <!-- Disabled for ONOS to allow use of public -->
271 <!-- modifiers in interfaces. -->
272 <!-- <module name="RedundantModifier"/> -->
273
274
275 <!-- Checks for blocks. You know, those {}'s -->
276 <!-- See http://checkstyle.sf.net/config_blocks.html -->
277 <module name="AvoidNestedBlocks">
278 <!-- ONOS alows declarations inside of switch case blocks -->
279 <property name="allowInSwitchCase" value="true"/>
280 </module>
HIGUCHI Yuta94a9eed2015-09-25 15:20:04 -0700281 <module name="EmptyBlock">
282 <!-- allow empty block, as long as there's some comment -->
283 <property name="option" value="text"/>
284 </module>
tom0eb04ca2014-08-25 14:34:51 -0700285 <module name="LeftCurly"/>
286 <module name="NeedBraces"/>
287 <module name="RightCurly"/>
288
289 <!-- Checks for common coding problems -->
290 <!-- See http://checkstyle.sf.net/config_coding.html -->
291 <!-- ONOS allows conditional operators -->
292 <!-- <module name="AvoidInlineConditionals"/> -->
293 <module name="EmptyStatement"/>
294 <module name="EqualsHashCode"/>
295
296 <module name="HiddenField">
297 <property name="ignoreSetter" value="true"/>
298 <property name="ignoreConstructorParameter" value="true"/>
299 </module>
300
301 <module name="IllegalInstantiation"/>
302 <module name="InnerAssignment"/>
303
304 <!-- Many violations of this rule present, revist in a
305 subsequent round of cleanups -->
306 <!-- <module name="MagicNumber"/> -->
307 <module name="MissingSwitchDefault"/>
308
tom0eb04ca2014-08-25 14:34:51 -0700309 <module name="SimplifyBooleanExpression"/>
310 <module name="SimplifyBooleanReturn"/>
311
312 <!-- Checks for class design -->
313 <!-- See http://checkstyle.sf.net/config_design.html -->
314 <!-- ONOS produces many warnings of this type.
315 Fixing all of these is outside the scope of the current cleanup. -->
316 <!-- <module name="DesignForExtension"/> -->
317 <module name="FinalClass"/>
318
319 <module name="HideUtilityClassConstructor"/>
320
321 <module name="InterfaceIsType"/>
322
323 <module name="VisibilityModifier">
Ray Milkeyb7949e72018-06-19 18:31:02 -0700324 <property name="severity" value="ignore"/>
tom0eb04ca2014-08-25 14:34:51 -0700325 </module>
326
327
tom0eb04ca2014-08-25 14:34:51 -0700328 <!-- Miscellaneous other checks. -->
329 <!-- See http://checkstyle.sf.net/config_misc.html -->
330 <module name="ArrayTypeStyle"/>
331
332 <!-- Many violations of this rule currently, too many to fix
333 in the current cleanup. -->
334 <!-- <module name="FinalParameters"/> -->
335 <!-- ONOS allows TODO markers in checked in source code -->
336 <!-- <module name="TodoComment"/> -->
337 <module name="UpperEll"/>
tom0eb04ca2014-08-25 14:34:51 -0700338 </module>
Brian O'Connor8b5edbc2016-04-05 15:45:25 -0700339
340</module>