| <?xml version="1.0"?> |
| <!-- |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this work except in compliance with the License. |
| You may obtain a copy of the License in the LICENSE file, or at: |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| <!DOCTYPE module PUBLIC |
| "-//Puppy Crawl//DTD Check Configuration 1.3//EN" |
| "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> |
| |
| <!-- |
| |
| Checkstyle configuration that checks the sun coding conventions from: |
| |
| - the Java Language Specification at |
| http://java.sun.com/docs/books/jls/second_edition/html/index.html |
| |
| - the Sun Code Conventions at http://java.sun.com/docs/codeconv/ |
| |
| - the Javadoc guidelines at |
| http://java.sun.com/j2se/javadoc/writingdoccomments/index.html |
| |
| - the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html |
| |
| - some best practices |
| |
| Checkstyle is very configurable. Be sure to read the documentation at |
| http://checkstyle.sf.net (or in your downloaded distribution). |
| |
| Most Checks are configurable, be sure to consult the documentation. |
| |
| To completely disable a check, just comment it out or delete it from the file. |
| |
| Finally, it is worth reading the documentation. |
| |
| TODO(wfarner): Iterate on this file to converge towards the google style checks provided |
| by checkstyle: |
| https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml |
| --> |
| |
| <module name="Checker"> |
| <!-- |
| If you set the basedir property below, then all reported file |
| names will be relative to the specified directory. See |
| http://checkstyle.sourceforge.net/config.html#Checker |
| <property name="basedir" value="${basedir}"/> |
| --> |
| |
| <!-- Checks whether files end with a new line. --> |
| <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile --> |
| <module name="NewlineAtEndOfFile"/> |
| |
| <!-- Disallows multiple sequential newlines. --> |
| <module name="RegexpMultiline"> |
| <property name="format" value="\n{3,}"/> |
| <property name="message" value="File contains a sequence of empty lines."/> |
| </module> |
| |
| <!-- Checks for whitespace --> |
| <!-- See http://checkstyle.sf.net/config_whitespace.html --> |
| <module name="FileTabCharacter"> |
| <property name="eachLine" value="true"/> |
| </module> |
| |
| <!-- Miscellaneous other checks. --> |
| <!-- See http://checkstyle.sf.net/config_misc.html --> |
| <module name="RegexpSingleline"> |
| <property name="format" value="\s+$"/> |
| <property name="minimum" value="0"/> |
| <property name="maximum" value="0"/> |
| <property name="message" value="Line has trailing spaces."/> |
| </module> |
| |
| <module name="RegexpHeader"> |
| <property name="headerFile" value="config/checkstyle/apache.header.regex"/> |
| <property name="fileExtensions" value="java"/> |
| </module> |
| |
| <module name="TreeWalker"> |
| <property name="tabWidth" value="2"/> |
| |
| <module name="Indentation"> |
| <property name="basicOffset" value="2"/> |
| <property name="braceAdjustment" value="0"/> |
| <property name="caseIndent" value="2"/> |
| <property name="throwsIndent" value="4"/> |
| <property name="lineWrappingIndentation" value="4"/> |
| <property name="arrayInitIndent" value="2"/> |
| </module> |
| |
| <!-- needed for SuppressWithNearbyCommentFilter --> |
| <module name="FileContentsHolder"/> |
| |
| <!-- Annotations --> |
| <module name="AnnotationUseStyle"/> |
| <module name="MissingDeprecated"/> |
| <module name="MissingOverride"/> |
| <module name="PackageAnnotation"/> |
| |
| <module name="JavadocType"> |
| <property name="excludeScope" value="private"/> |
| </module> |
| <module name="JavadocStyle"> |
| <property name="checkEmptyJavadoc" value="true"/> |
| </module> |
| <module name="JavadocVariable"> |
| <property name="excludeScope" value="private"/> |
| </module> |
| |
| <!-- Checks for Naming Conventions. --> |
| <module name="ClassTypeParameterName"/> |
| <module name="ConstantName"/> |
| <module name="LocalFinalVariableName"> |
| <!-- allow VAR_NAME and varName in local final variables, |
| leave it up to user to use them appropriately depending on whether |
| or not the variable is A_CONSTANT_VARIBLE, or aMutableVariable. |
| --> |
| <property name="format" value="^(([a-z][a-zA-Z0-9]*)|([A-Z][A-Z0-9]*(_[A-Z0-9]+)*))$" /> |
| </module> |
| <module name="LocalVariableName"/> |
| <module name="MemberName"/> |
| <module name="MethodTypeParameterName"/> |
| <module name="PackageName"/> |
| <module name="ParameterName"/> |
| <module name="StaticVariableName"/> |
| <module name="TypeName"/> |
| |
| <!-- Checks for imports --> |
| <!-- See http://checkstyle.sf.net/config_import.html --> |
| <module name="AvoidStarImport"> |
| <property name="excludes" value="org.junit.Assert"/> |
| <property name="excludes" value="java.util.*"/> |
| </module> |
| <module name="IllegalImport"/> <!-- defaults to sun.* packages --> |
| <module name="RedundantImport"/> |
| <module name="UnusedImports"/> |
| <module name="ImportOrder"> |
| <property name="groups" |
| value="/^javax?\./,scala,com,net,org"/> |
| <property name="ordered" value="true"/> |
| <property name="separated" value="true"/> |
| <property name="option" value="bottom"/> |
| <message key="import.ordering" |
| value="Wrong order for ''{0}'' import. Order should be: java, javax, scala, com, net, org. |
| Each group should be separated by a single blank line." /> |
| </module> |
| |
| <!-- Checks for Size Violations. --> |
| <!-- See http://checkstyle.sf.net/config_sizes.html --> |
| <module name="LineLength"> |
| <property name="max" value="100"/> |
| <property name="ignorePattern" value="^import"/> |
| </module> |
| <module name="OuterTypeNumber"/> |
| |
| <!-- Checks for whitespace --> |
| <!-- See http://checkstyle.sf.net/config_whitespace.html --> |
| <module name="EmptyForInitializerPad"/> |
| <module name="EmptyForIteratorPad"/> |
| <module name="MethodParamPad"/> |
| <module name="NoWhitespaceAfter"/> |
| <module name="NoWhitespaceBefore"/> |
| <module name="OperatorWrap"/> |
| <module name="ParenPad"/> |
| <module name="TypecastParenPad"/> |
| <module name="WhitespaceAfter"/> |
| <module name="WhitespaceAround"> |
| <!-- Intentionally excludes RCURLY (default) since it trips on anonymous |
| inner class declarations when chained with a method call. |
| --> |
| <property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN, |
| BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,EQUAL,GE,GT,LAND, |
| LCURLY,LE,LITERAL_ASSERT,LITERAL_CATCH,LITERAL_DO, |
| LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF, |
| LITERAL_RETURN,LITERAL_SYNCHRONIZED,LITERAL_TRY, |
| LITERAL_WHILE,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN, |
| NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,SL,SLIST,SL_ASSIGN, |
| SR,SR_ASSIGN,STAR,STAR_ASSIGN,TYPE_EXTENSION_AND"/> |
| </module> |
| |
| <!-- Modifier Checks --> |
| <!-- See http://checkstyle.sf.net/config_modifiers.html --> |
| <module name="ModifierOrder"/> |
| <module name="RedundantModifier"/> |
| |
| <!-- Checks for blocks. You know, those {}'s --> |
| <!-- See http://checkstyle.sf.net/config_blocks.html --> |
| <module name="AvoidNestedBlocks"/> |
| <module name="EmptyBlock"> |
| <!-- Allow comments to satisfy the EmptyBlock check --> |
| <property name="option" value="text"/> |
| </module> |
| <module name="LeftCurly"/> |
| <module name="NeedBraces"/> |
| <module name="RightCurly"/> |
| |
| <!-- Checks for common coding problems --> |
| <!-- See http://checkstyle.sf.net/config_coding.html --> |
| <module name="CovariantEquals"/> |
| <module name="EmptyStatement"/> |
| <module name="EqualsAvoidNull"/> |
| <module name="EqualsHashCode"/> |
| <module name="HiddenField"> |
| <property name="ignoreConstructorParameter" value="true"/> |
| <property name="ignoreSetter" value="true"/> |
| <property name="setterCanReturnItsClass" value="true"/> |
| </module> |
| |
| <!-- disallow calling constructors on these classes |
| calling factories is the only way to create these objects |
| --> |
| <module name="IllegalInstantiation"> |
| <property name="classes" value="java.lang.Boolean"/> |
| </module> |
| <module name="IllegalToken"> |
| <property name="tokens" value="LITERAL_NATIVE"/> |
| </module> |
| <module name="InnerAssignment"/> |
| <module name="MissingSwitchDefault"/> |
| <module name="ModifiedControlVariable"/> |
| <module name="SimplifyBooleanExpression"/> |
| <module name="SimplifyBooleanReturn"/> |
| <module name="StringLiteralEquality"/> |
| <module name="SuppressWarnings"/> |
| <module name="NestedForDepth"> |
| <property name="max" value="2"/> |
| </module> |
| <module name="NoClone"/> |
| <module name="NoFinalizer"/> |
| <module name="SuperClone"/> |
| <module name="SuperFinalize"/> |
| <module name="PackageDeclaration" /> |
| <module name="ParameterAssignment"/> |
| <module name="DefaultComesLast"/> |
| <module name="FallThrough"/> |
| <module name="MultipleVariableDeclarations"/> |
| <module name="UnnecessaryParentheses"/> |
| <module name="OneStatementPerLine"/> |
| |
| <module name="FinalClass"/> |
| <module name="HideUtilityClassConstructor"/> |
| <module name="InterfaceIsType"/> |
| <module name="MutableException"/> |
| |
| <!-- Miscellaneous other checks. --> |
| <!-- See http://checkstyle.sf.net/config_misc.html --> |
| <module name="ArrayTypeStyle"/> |
| <module name="UpperEll"/> |
| <module name="ArrayTypeStyle"/> |
| <module name="OuterTypeFilename"/> |
| |
| <!-- Discourage use of System.exit() --> |
| <module name="RegexpSinglelineJava"> |
| <property name="format" value="System.exit"/> |
| <property name="ignoreComments" value="true"/> |
| <property name="message" |
| value="Don't System.exit(), throw a RuntimeException()" /> |
| </module> |
| </module> |
| |
| <module name="SuppressionFilter"> |
| <property name="file" value="config/checkstyle/suppressions.xml"/> |
| </module> |
| </module> |