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