|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<!-- |
| 3 | + Copyright (C) 2019 Google Inc. |
| 4 | +
|
| 5 | + Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 6 | + use this file except in compliance with the License. You may obtain a copy of |
| 7 | + 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, WITHOUT |
| 13 | + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | + License for the specific language governing permissions and limitations under |
| 15 | + 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 | +<!-- This is a checkstyle configuration file. For descriptions of |
| 22 | +what the following rules do, please see the checkstyle configuration |
| 23 | +page at http://checkstyle.sourceforge.net/config.html --> |
| 24 | + |
| 25 | +<module name="Checker"> |
| 26 | + <property name="severity" value="error"/> |
| 27 | + |
| 28 | + <!-- Allows inline SuppressWarnings annotation, by using for example |
| 29 | + "@SuppressWarnings("checkstyle:JavadocMethod")". |
| 30 | + --> |
| 31 | + <module name="SuppressWarningsFilter" /> |
| 32 | + |
| 33 | + <module name="RegexpSingleline"> |
| 34 | + <property name="format" value="Throwables.propagate\("/> |
| 35 | + <property name="message" value="Throwables.propagate is deprecated"/> |
| 36 | + <property name="severity" value="error"/> |
| 37 | + </module> |
| 38 | + |
| 39 | + <!-- Prevent *Tests.java as tools may not pick them up --> |
| 40 | + <module name="RegexpOnFilename"> |
| 41 | + <property name="fileNamePattern" value=".*Tests\.java$" /> |
| 42 | + </module> |
| 43 | + |
| 44 | + <!-- Check that every module has a package-info.java --> |
| 45 | + <module name="JavadocPackage"/> |
| 46 | + |
| 47 | + <module name="SuppressionFilter"> |
| 48 | + <property name="file" value="${checkstyle.suppressions.file}" default="suppressions.xml" /> |
| 49 | + </module> |
| 50 | + |
| 51 | + <!-- All Java AST specific tests live under TreeWalker module. --> |
| 52 | + <module name="TreeWalker"> |
| 53 | + <module name="MissingDeprecated" /> |
| 54 | + |
| 55 | + <module name="RedundantImport"> |
| 56 | + <!-- Checks for redundant import statements. --> |
| 57 | + <property name="severity" value="error"/> |
| 58 | + <message key="import.redundancy" |
| 59 | + value="Redundant import {0}."/> |
| 60 | + </module> |
| 61 | + |
| 62 | + <module name="ImportOrder"> |
| 63 | + <!-- Checks for out of order import statements. --> |
| 64 | + <property name="severity" value="error"/> |
| 65 | + <!-- This ensures that static imports go first. --> |
| 66 | + <property name="option" value="top"/> |
| 67 | + <property name="sortStaticImportsAlphabetically" value="true"/> |
| 68 | + <property name="tokens" value="STATIC_IMPORT, IMPORT"/> |
| 69 | + <property name="separated" value="true"/> |
| 70 | + <message key="import.ordering" |
| 71 | + value="Import {0} appears after other imports that it should precede"/> |
| 72 | + </module> |
| 73 | + |
| 74 | + <module name="AvoidStarImport"> |
| 75 | + <property name="severity" value="error"/> |
| 76 | + </module> |
| 77 | + |
| 78 | + <module name="IllegalImport"> |
| 79 | + <property name="illegalPkgs" value="autovalue.shaded, avro.shaded, com.google.api.client.repackaged, com.google.appengine.repackaged, io.netty.util.internal"/> |
| 80 | + </module> |
| 81 | + |
| 82 | + <module name="RedundantModifier"> |
| 83 | + <!-- Checks for redundant modifiers on various symbol definitions. |
| 84 | + See: http://checkstyle.sourceforge.net/config_modifier.html#RedundantModifier |
| 85 | + --> |
| 86 | + <property name="tokens" value="METHOD_DEF, VARIABLE_DEF, ANNOTATION_FIELD_DEF, INTERFACE_DEF, CLASS_DEF, ENUM_DEF"/> |
| 87 | + </module> |
| 88 | + |
| 89 | + <!-- |
| 90 | + IllegalImport cannot blacklist classes, and c.g.api.client.util is used for some shaded |
| 91 | + code and some useful code. So we need to fall back to Regexp. |
| 92 | + --> |
| 93 | + <module name="RegexpSinglelineJava"> |
| 94 | + <property name="format" value="com\.google\.api\.client\.util\.(ByteStreams|Charsets|Collections2|Joiner|Lists|Maps|Objects|Preconditions|Sets|Strings|Throwables)"/> |
| 95 | + </module> |
| 96 | + |
| 97 | + <module name="UnusedImports"> |
| 98 | + <property name="severity" value="error"/> |
| 99 | + <property name="processJavadoc" value="true"/> |
| 100 | + <message key="import.unused" |
| 101 | + value="Unused import: {0}."/> |
| 102 | + </module> |
| 103 | + |
| 104 | + <module name="IllegalThrows"> |
| 105 | + <property name="illegalClassNames" |
| 106 | + value="java.lang.Error,java.lang.RuntimeException" /> |
| 107 | + </module> |
| 108 | + |
| 109 | + <!-- |
| 110 | +
|
| 111 | + JAVADOC CHECKS |
| 112 | +
|
| 113 | + --> |
| 114 | + |
| 115 | + <!-- Required to work in pair with SuppressWarningsFilter--> |
| 116 | + <module name="SuppressWarningsHolder" /> |
| 117 | + |
| 118 | + <!-- Check that paragraph tags are used correctly in Javadoc. --> |
| 119 | + <!-- |
| 120 | + TODO(https://issues.apache.org/jira/browse/BEAM-4670): re-enable after fixing after spotless |
| 121 | +
|
| 122 | + A lot of our Javadoc has moderately broken HTML. It lacks paragraph tags where it ought |
| 123 | + to have them. Spotless reformats so that checkstyle noticies this. This can be fixed |
| 124 | + a bit at a time. |
| 125 | +
|
| 126 | + <module name="JavadocParagraph"/> |
| 127 | + --> |
| 128 | + |
| 129 | + <module name="JavadocType"> |
| 130 | + <property name="scope" value="protected"/> |
| 131 | + <property name="severity" value="error"/> |
| 132 | + <property name="allowMissingParamTags" value="true"/> |
| 133 | + </module> |
| 134 | + |
| 135 | + <module name="JavadocStyle"> |
| 136 | + <property name="severity" value="error"/> |
| 137 | + <property name="checkHtml" value="true"/> |
| 138 | + </module> |
| 139 | + |
| 140 | + <!-- |
| 141 | +
|
| 142 | + NAMING CHECKS |
| 143 | +
|
| 144 | + --> |
| 145 | + |
| 146 | + <!-- Item 38 - Adhere to generally accepted naming conventions --> |
| 147 | + |
| 148 | + <module name="PackageName"> |
| 149 | + <!-- Validates identifiers for package names against the |
| 150 | + supplied expression. --> |
| 151 | + <!-- Here the default checkstyle rule restricts package name parts to |
| 152 | + seven characters, this is not in line with common practice at Google. |
| 153 | + --> |
| 154 | + <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,})*$"/> |
| 155 | + <property name="severity" value="error"/> |
| 156 | + </module> |
| 157 | + |
| 158 | + <module name="PackageDeclaration" /> |
| 159 | + |
| 160 | + <module name="TypeNameCheck"> |
| 161 | + <!-- Validates static, final fields against the |
| 162 | + expression "^[A-Z][a-zA-Z0-9]*$". --> |
| 163 | + <metadata name="altname" value="TypeName"/> |
| 164 | + <property name="severity" value="error"/> |
| 165 | + </module> |
| 166 | + |
| 167 | + <module name="ConstantNameCheck"> |
| 168 | + <!-- Validates non-private, static, final fields against the supplied |
| 169 | + public/package final fields "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$". --> |
| 170 | + <metadata name="altname" value="ConstantName"/> |
| 171 | + <property name="applyToPublic" value="true"/> |
| 172 | + <property name="applyToProtected" value="true"/> |
| 173 | + <property name="applyToPackage" value="true"/> |
| 174 | + <property name="applyToPrivate" value="false"/> |
| 175 | + <property name="format" value="^([A-Z][A-Z0-9]*(_[A-Z0-9]+)*|FLAG_.*)$"/> |
| 176 | + <message key="name.invalidPattern" |
| 177 | + value="Variable ''{0}'' should be in ALL_CAPS (if it is a constant) or be private (otherwise)."/> |
| 178 | + <property name="severity" value="error"/> |
| 179 | + </module> |
| 180 | + |
| 181 | + <module name="StaticVariableNameCheck"> |
| 182 | + <!-- Validates static, non-final fields against the supplied |
| 183 | + expression "^[a-z][a-zA-Z0-9]*_?$". --> |
| 184 | + <metadata name="altname" value="StaticVariableName"/> |
| 185 | + <property name="applyToPublic" value="true"/> |
| 186 | + <property name="applyToProtected" value="true"/> |
| 187 | + <property name="applyToPackage" value="true"/> |
| 188 | + <property name="applyToPrivate" value="true"/> |
| 189 | + <property name="format" value="^[a-z][a-zA-Z0-9]*_?$"/> |
| 190 | + <property name="severity" value="error"/> |
| 191 | + </module> |
| 192 | + |
| 193 | + <module name="MemberNameCheck"> |
| 194 | + <!-- Validates non-static members against the supplied expression. --> |
| 195 | + <metadata name="altname" value="MemberName"/> |
| 196 | + <property name="applyToPublic" value="true"/> |
| 197 | + <property name="applyToProtected" value="true"/> |
| 198 | + <property name="applyToPackage" value="true"/> |
| 199 | + <property name="applyToPrivate" value="true"/> |
| 200 | + <property name="format" value="^[a-z][a-zA-Z0-9]*$"/> |
| 201 | + <property name="severity" value="error"/> |
| 202 | + </module> |
| 203 | + |
| 204 | + <module name="MethodNameCheck"> |
| 205 | + <!-- Validates identifiers for method names. --> |
| 206 | + <metadata name="altname" value="MethodName"/> |
| 207 | + <property name="format" value="^[a-z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$"/> |
| 208 | + <property name="severity" value="error"/> |
| 209 | + </module> |
| 210 | + |
| 211 | + <module name="ParameterName"> |
| 212 | + <!-- Validates identifiers for method parameters against the |
| 213 | + expression "^[a-z][a-zA-Z0-9]*$". --> |
| 214 | + <property name="severity" value="error"/> |
| 215 | + </module> |
| 216 | + |
| 217 | + <module name="LocalFinalVariableName"> |
| 218 | + <!-- Validates identifiers for local final variables against the |
| 219 | + expression "^[a-z][a-zA-Z0-9]*$". --> |
| 220 | + <property name="severity" value="error"/> |
| 221 | + </module> |
| 222 | + |
| 223 | + <module name="LocalVariableName"> |
| 224 | + <!-- Validates identifiers for local variables against the |
| 225 | + expression "^[a-z][a-zA-Z0-9]*$". --> |
| 226 | + <property name="severity" value="error"/> |
| 227 | + </module> |
| 228 | + |
| 229 | + <!-- Type parameters must be either one of the four blessed letters |
| 230 | + T, K, V, W, X or else be capital-case terminated with a T, |
| 231 | + such as MyGenericParameterT --> |
| 232 | + <module name="ClassTypeParameterName"> |
| 233 | + <property name="format" value="^(((T|K|V|W|X)[0-9]*)|([A-Z][a-z][a-zA-Z]*T))$"/> |
| 234 | + <property name="severity" value="error"/> |
| 235 | + </module> |
| 236 | + |
| 237 | + <module name="MethodTypeParameterName"> |
| 238 | + <property name="format" value="^(((T|K|V|W|X)[0-9]*)|([A-Z][a-z][a-zA-Z]*T))$"/> |
| 239 | + <property name="severity" value="error"/> |
| 240 | + </module> |
| 241 | + |
| 242 | + <module name="InterfaceTypeParameterName"> |
| 243 | + <property name="format" value="^(((T|K|V|W|X)[0-9]*)|([A-Z][a-z][a-zA-Z]*T))$"/> |
| 244 | + <property name="severity" value="error"/> |
| 245 | + </module> |
| 246 | + |
| 247 | + <!-- |
| 248 | +
|
| 249 | + LENGTH and CODING CHECKS |
| 250 | +
|
| 251 | + --> |
| 252 | + |
| 253 | + <!-- |
| 254 | + TODO(https://issues.apache.org/jira/browse/BEAM-4669): re-enable after fixing after spotless |
| 255 | +
|
| 256 | + When spotless re-indents, multi-line strings are often split so close to 100 chars that the |
| 257 | + indentation makes them exceed the max line length. This can be fixed a bit at a time. |
| 258 | +
|
| 259 | + <module name="LineLength"> |
| 260 | + <property name="max" value="100"/> |
| 261 | + <property name="severity" value="error"/> |
| 262 | + <property name="ignorePattern" |
| 263 | + value="^(package .*;\s*)|(import .*;\s*)|( *\* .*https?://.*)$"/> |
| 264 | + </module> |
| 265 | + --> |
| 266 | + |
| 267 | + <!-- Checks for braces around if and else blocks --> |
| 268 | + <module name="NeedBraces"> |
| 269 | + <property name="severity" value="error"/> |
| 270 | + <property name="tokens" value="LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO"/> |
| 271 | + </module> |
| 272 | + |
| 273 | + <module name="UpperEll"> |
| 274 | + <!-- Checks that long constants are defined with an upper ell.--> |
| 275 | + <property name="severity" value="error"/> |
| 276 | + </module> |
| 277 | + |
| 278 | + <module name="FallThrough"> |
| 279 | + <!-- Warn about falling through to the next case statement. Similar to |
| 280 | + javac -Xlint:fallthrough, but the check is suppressed if a single-line comment |
| 281 | + on the last non-blank line preceding the fallen-into case contains 'fall through' (or |
| 282 | + some other variants that we don't publicized to promote consistency). |
| 283 | + --> |
| 284 | + <property name="reliefPattern" |
| 285 | + value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on"/> |
| 286 | + <property name="severity" value="error"/> |
| 287 | + </module> |
| 288 | + |
| 289 | + <!-- Checks for over-complicated boolean expressions. --> |
| 290 | + <module name="SimplifyBooleanExpression"/> |
| 291 | + |
| 292 | + <!-- |
| 293 | +
|
| 294 | + MODIFIERS CHECKS |
| 295 | +
|
| 296 | + --> |
| 297 | + |
| 298 | + <module name="ModifierOrder"> |
| 299 | + <!-- Warn if modifier order is inconsistent with JLS3 8.1.1, 8.3.1, and |
| 300 | + 8.4.3. The prescribed order is: |
| 301 | + public, protected, private, abstract, static, final, transient, volatile, |
| 302 | + synchronized, native, strictfp |
| 303 | + --> |
| 304 | + <property name="severity" value="error"/> |
| 305 | + </module> |
| 306 | + |
| 307 | + |
| 308 | + <!-- Allow use of comment to suppress javadocstyle --> |
| 309 | + <module name="SuppressionCommentFilter"> |
| 310 | + <property name="offCommentFormat" value="CHECKSTYLE.OFF\: ([\w\|]+)"/> |
| 311 | + <property name="onCommentFormat" value="CHECKSTYLE.ON\: ([\w\|]+)"/> |
| 312 | + <property name="checkFormat" value="$1"/> |
| 313 | + </module> |
| 314 | + |
| 315 | + <module name="ArrayTypeStyle"/> |
| 316 | + </module> |
| 317 | + |
| 318 | +</module> |
| 319 | + |
0 commit comments