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