blob: cf8fe4d1c698c898f23a3add916c9f743fe6725a [file] [log] [blame]
Ray Milkey2d572dd2017-04-14 10:01:24 -07001<?xml version="1.0"?>
2<!--
Brian O'Connora09fe5b2017-08-03 21:12:30 -07003 ~ Copyright 2014-present Open Networking Foundation
Ray Milkey2d572dd2017-04-14 10:01:24 -07004 ~
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 -->
17<!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
53 'warning'. Over time, these 'warning' settings should be
54 removed as more of the ONOS source code is modified to
55 follow the recommended rules.
56-->
57
58
59<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 -->
69 <module name="JavadocPackage"/>
70
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
96 <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 Milkeyca188042018-04-05 16:57:01 -0700102 <!-- 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
110 <!-- 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 Milkey2d572dd2017-04-14 10:01:24 -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
125 <module name="RegexpHeader">
126 <!-- The following line is different for maven due to how the maven checkstyle plugin works -->
127 <property name="headerFile" value="${checkstyle.header.file}"/>
128 <property name="fileExtensions" value="java"/>
129 </module>
130
131
132 <module name="SuppressionCommentFilter">
133 <property name="offCommentFormat"
134 value="(CHECKSTYLE\:OFF|Generated by the protocol buffer compiler.)"/>
135 <property name="onCommentFormat" value="CHECKSTYLE:ON"/>
136 </module>
137
138 <module name="SuppressWithNearbyCommentFilter">
139 <property name="commentFormat" value="CHECKSTYLE IGNORE THIS LINE"/>
140 <property name="checkFormat" value=".*"/>
141 <property name="influenceFormat" value="0"/>
142 </module>
143
144 <!-- Example: // CHECKSTYLE IGNORE FinalClass FOR NEXT 1 LINES -->
145 <module name="SuppressWithNearbyCommentFilter">
146 <property name="commentFormat"
147 value="CHECKSTYLE IGNORE (\w+) FOR NEXT (\d+) LINES"/>
148 <property name="checkFormat" value="$1"/>
149 <property name="influenceFormat" value="$2"/>
150 </module>
151
152 <module name="TreeWalker">
153
154 <module name="FileContentsHolder"/>
155 <!-- Checks for Javadoc comments. -->
156 <!-- See http://checkstyle.sf.net/config_javadoc.html -->
157 <module name="JavadocMethod">
158 <property name="scope" value="package"/>
Yuta HIGUCHI9312a802017-06-12 20:01:27 -0700159 <property name="allowMissingJavadoc" value="true"/>
Ray Milkey2d572dd2017-04-14 10:01:24 -0700160 <property name="allowUndeclaredRTE" value="true"/>
Yuta HIGUCHI9312a802017-06-12 20:01:27 -0700161 <property name="suppressLoadErrors" value="true"/>
Ray Milkey2d572dd2017-04-14 10:01:24 -0700162 </module>
163 <module name="JavadocType">
164 <property name="severity" value="warning"/>
165 </module>
166 <module name="JavadocVariable">
167 <!-- Suppress check for private member Javadocs.
168 Possibly revist fixing these. -->
169 <property name="scope" value="public"/>
170 <property name="severity" value="warning"/>
171 </module>
172 <module name="JavadocStyle"/>
173 <!-- @author tag should not be used -->
174 <module name="WriteTag">
175 <property name="tag" value="@author"/>
176 <property name="tagFormat" value="\S"/>
177 <property name="severity" value="ignore"/>
178 <property name="tagSeverity" value="error"/>
179 </module>
180
181 <module name="AbbreviationAsWordInName">
182 <property name="allowedAbbreviationLength" value="2"/>
183 </module>
184
185 <!-- Checks for Naming Conventions. -->
186 <!-- See http://checkstyle.sf.net/config_naming.html -->
187 <module name="ConstantName">
188 <!-- ONOS allows the name "log" for static final Loggers -->
189 <property name="format"
190 value="^log$|^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
191 </module>
192 <module name="LocalFinalVariableName"/>
193
194 <module name="LocalVariableName"/>
195
196 <module name="MemberName"/>
197 <module name="MethodName"/>
198 <module name="PackageName">
199 <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
200 </module>
201 <module name="ParameterName"/>
202 <module name="StaticVariableName"/>
203 <module name="TypeName"/>
204
205 <!-- Checks for imports -->
206 <!-- See http://checkstyle.sf.net/config_import.html -->
207 <module name="AvoidStarImport">
208 <property name="allowStaticMemberImports" value="true"/>
209 </module>
210 <module name="IllegalImport"/>
211 <!-- defaults to sun.* packages -->
212 <module name="RedundantImport"/>
213 <module name="UnusedImports"/>
214
215
216 <!-- Checks for Size Violations. -->
217 <!-- See http://checkstyle.sf.net/config_sizes.html -->
218 <module name="LineLength">
219 <!-- ONOS standard usage is 80 columns, but we allow up
220 to 120 to not break the build. -->
221 <property name="max" value="120"/>
222 <property name="ignorePattern" value="^import"/>
223 </module>
224 <module name="MethodLength">
225 <property name="max" value="200"/>
226 </module>
227
228 <module name="ParameterNumber">
229 <property name="max" value="15"/>
230 <property name="tokens" value="CTOR_DEF"/>
231 </module>
232 <!-- Checks for whitespace -->
233 <!-- See http://checkstyle.sf.net/config_whitespace.html -->
234 <module name="EmptyForIteratorPad"/>
235 <module name="GenericWhitespace"/>
236 <module name="MethodParamPad"/>
237 <module name="NoWhitespaceAfter"/>
238 <module name="NoWhitespaceBefore"/>
239
240 <!-- Disabled for ONOS. Default rules specify undesired behavior for the '?' operator -->
241 <!-- <module name="OperatorWrap"/> -->
242 <module name="ParenPad"/>
243 <module name="TypecastParenPad"/>
244 <module name="WhitespaceAfter"/>
245 <module name="WhitespaceAround">
246 <property name="allowEmptyConstructors" value="true"/>
247 <property name="allowEmptyMethods" value="true"/>
248 </module>
249
250
251 <!-- Modifier Checks -->
252 <!-- See http://checkstyle.sf.net/config_modifiers.html -->
253 <module name="ModifierOrder"/>
254
255 <!-- Disabled for ONOS to allow use of public -->
256 <!-- modifiers in interfaces. -->
257 <!-- <module name="RedundantModifier"/> -->
258
259
260 <!-- Checks for blocks. You know, those {}'s -->
261 <!-- See http://checkstyle.sf.net/config_blocks.html -->
262 <module name="AvoidNestedBlocks">
263 <!-- ONOS alows declarations inside of switch case blocks -->
264 <property name="allowInSwitchCase" value="true"/>
265 </module>
266 <module name="EmptyBlock">
267 <!-- allow empty block, as long as there's some comment -->
268 <property name="option" value="text"/>
269 </module>
270 <module name="LeftCurly"/>
271 <module name="NeedBraces"/>
272 <module name="RightCurly"/>
273
274 <!-- Checks for common coding problems -->
275 <!-- See http://checkstyle.sf.net/config_coding.html -->
276 <!-- ONOS allows conditional operators -->
277 <!-- <module name="AvoidInlineConditionals"/> -->
278 <module name="EmptyStatement"/>
279 <module name="EqualsHashCode"/>
280
281 <module name="HiddenField">
282 <property name="ignoreSetter" value="true"/>
283 <property name="ignoreConstructorParameter" value="true"/>
284 </module>
285
286 <module name="IllegalInstantiation"/>
287 <module name="InnerAssignment"/>
288
289 <!-- Many violations of this rule present, revist in a
290 subsequent round of cleanups -->
291 <!-- <module name="MagicNumber"/> -->
292 <module name="MissingSwitchDefault"/>
293
294 <module name="SimplifyBooleanExpression"/>
295 <module name="SimplifyBooleanReturn"/>
296
297 <!-- Checks for class design -->
298 <!-- See http://checkstyle.sf.net/config_design.html -->
299 <!-- ONOS produces many warnings of this type.
300 Fixing all of these is outside the scope of the current cleanup. -->
301 <!-- <module name="DesignForExtension"/> -->
302 <module name="FinalClass"/>
303
304 <module name="HideUtilityClassConstructor"/>
305
306 <module name="InterfaceIsType"/>
307
308 <module name="VisibilityModifier">
309 <property name="severity" value="warning"/>
310 </module>
311
312
313 <!-- Miscellaneous other checks. -->
314 <!-- See http://checkstyle.sf.net/config_misc.html -->
315 <module name="ArrayTypeStyle"/>
316
317 <!-- Many violations of this rule currently, too many to fix
318 in the current cleanup. -->
319 <!-- <module name="FinalParameters"/> -->
320 <!-- ONOS allows TODO markers in checked in source code -->
321 <!-- <module name="TodoComment"/> -->
322 <module name="UpperEll"/>
323 </module>
324
325</module>