0001 <!--
0002 ~ Licensed to the Apache Software Foundation (ASF) under one or more
0003 ~ contributor license agreements. See the NOTICE file distributed with
0004 ~ this work for additional information regarding copyright ownership.
0005 ~ The ASF licenses this file to You under the Apache License, Version 2.0
0006 ~ (the "License"); you may not use this file except in compliance with
0007 ~ the License. You may obtain a copy of the License at
0008 ~
0009 ~ http://www.apache.org/licenses/LICENSE-2.0
0010 ~
0011 ~ Unless required by applicable law or agreed to in writing, software
0012 ~ distributed under the License is distributed on an "AS IS" BASIS,
0013 ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014 ~ See the License for the specific language governing permissions and
0015 ~ limitations under the License.
0016 -->
0017
0018 <!DOCTYPE module PUBLIC
0019 "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
0020 "https://checkstyle.org/dtds/configuration_1_3.dtd">
0021
0022 <!--
0023
0024 Checkstyle configuration based on the Google coding conventions from:
0025
0026 - Google Java Style
0027 https://google.github.io/styleguide/javaguide.html
0028
0029 with Spark-specific changes from:
0030
0031 http://spark.apache.org/contributing.html#code-style-guide
0032
0033 Checkstyle is very configurable. Be sure to read the documentation at
0034 http://checkstyle.sf.net (or in your downloaded distribution).
0035
0036 Most Checks are configurable, be sure to consult the documentation.
0037
0038 To completely disable a check, just comment it out or delete it from the file.
0039
0040 Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov.
0041
0042 -->
0043
0044 <module name = "Checker">
0045 <property name="charset" value="UTF-8"/>
0046
0047 <property name="severity" value="error"/>
0048
0049 <property name="fileExtensions" value="java, properties, xml"/>
0050
0051 <module name="SuppressionFilter">
0052 <property name="file" value="dev/checkstyle-suppressions.xml"/>
0053 </module>
0054
0055 <!-- Checks for whitespace -->
0056 <!-- See http://checkstyle.sf.net/config_whitespace.html -->
0057 <module name="FileTabCharacter">
0058 <property name="eachLine" value="true"/>
0059 </module>
0060
0061 <module name="RegexpSingleline">
0062 <!-- \s matches whitespace character, $ matches end of line. -->
0063 <property name="format" value="\s+$"/>
0064 <property name="message" value="No trailing whitespace allowed."/>
0065 </module>
0066
0067 <module name="LineLength">
0068 <property name="max" value="100"/>
0069 <property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
0070 </module>
0071
0072 <module name="NewlineAtEndOfFile"/>
0073
0074 <module name="TreeWalker">
0075 <!--
0076 If you wish to turn off checking for a section of code, you can put a comment in the source
0077 before and after the section, with the following syntax:
0078
0079 // checkstyle.off: XXX (such as checkstyle.off: NoFinalizer)
0080 ... // stuff that breaks the styles
0081 // checkstyle.on: XXX (such as checkstyle.on: NoFinalizer)
0082 -->
0083 <module name="SuppressionCommentFilter">
0084 <property name="offCommentFormat" value="checkstyle\.off\: ([\w\|]+)"/>
0085 <property name="onCommentFormat" value="checkstyle\.on\: ([\w\|]+)"/>
0086 <property name="checkFormat" value="$1"/>
0087 </module>
0088 <module name="OuterTypeFilename"/>
0089 <module name="IllegalTokenText">
0090 <property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
0091 <property name="format" value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
0092 <property name="message" value="Avoid using corresponding octal or Unicode escape."/>
0093 </module>
0094 <module name="AvoidEscapedUnicodeCharacters">
0095 <property name="allowEscapesForControlCharacters" value="true"/>
0096 <property name="allowByTailComment" value="true"/>
0097 <property name="allowNonPrintableEscapes" value="true"/>
0098 </module>
0099 <module name="NoLineWrap"/>
0100 <module name="EmptyBlock">
0101 <property name="option" value="TEXT"/>
0102 <property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
0103 </module>
0104 <module name="NeedBraces">
0105 <property name="allowSingleLineStatement" value="true"/>
0106 </module>
0107 <module name="OneStatementPerLine"/>
0108 <module name="ArrayTypeStyle"/>
0109 <module name="FallThrough"/>
0110 <module name="UpperEll"/>
0111 <module name="ModifierOrder"/>
0112 <module name="SeparatorWrap">
0113 <property name="tokens" value="DOT"/>
0114 <property name="option" value="nl"/>
0115 </module>
0116 <module name="SeparatorWrap">
0117 <property name="tokens" value="COMMA"/>
0118 <property name="option" value="EOL"/>
0119 </module>
0120 <module name="PackageName">
0121 <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
0122 <message key="name.invalidPattern"
0123 value="Package name ''{0}'' must match pattern ''{1}''."/>
0124 </module>
0125 <module name="ClassTypeParameterName">
0126 <property name="format" value="([A-Z][a-zA-Z0-9]*$)"/>
0127 <message key="name.invalidPattern"
0128 value="Class type name ''{0}'' must match pattern ''{1}''."/>
0129 </module>
0130 <module name="MethodTypeParameterName">
0131 <property name="format" value="([A-Z][a-zA-Z0-9]*)"/>
0132 <message key="name.invalidPattern"
0133 value="Method type name ''{0}'' must match pattern ''{1}''."/>
0134 </module>
0135 <module name="GenericWhitespace">
0136 <message key="ws.followed"
0137 value="GenericWhitespace ''{0}'' is followed by whitespace."/>
0138 <message key="ws.preceded"
0139 value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
0140 <message key="ws.illegalFollow"
0141 value="GenericWhitespace ''{0}'' should followed by whitespace."/>
0142 <message key="ws.notPreceded"
0143 value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
0144 </module>
0145 <!-- TODO: 11/09/15 disabled - indentation is currently inconsistent -->
0146 <!--
0147 <module name="Indentation">
0148 <property name="basicOffset" value="4"/>
0149 <property name="braceAdjustment" value="0"/>
0150 <property name="caseIndent" value="4"/>
0151 <property name="throwsIndent" value="4"/>
0152 <property name="lineWrappingIndentation" value="4"/>
0153 <property name="arrayInitIndent" value="4"/>
0154 </module>
0155 -->
0156 <!-- TODO: 11/09/15 disabled - order is currently wrong in many places -->
0157 <!--
0158 <module name="ImportOrder">
0159 <property name="separated" value="true"/>
0160 <property name="ordered" value="true"/>
0161 <property name="groups" value="/^javax?\./,scala,*,org.apache.spark"/>
0162 </module>
0163 -->
0164 <module name="MethodParamPad"/>
0165 <module name="AnnotationLocation">
0166 <property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
0167 </module>
0168 <module name="AnnotationLocation">
0169 <property name="tokens" value="VARIABLE_DEF"/>
0170 <property name="allowSamelineMultipleAnnotations" value="true"/>
0171 </module>
0172 <module name="MethodName">
0173 <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
0174 <message key="name.invalidPattern"
0175 value="Method name ''{0}'' must match pattern ''{1}''."/>
0176 </module>
0177 <module name="EmptyCatchBlock">
0178 <property name="exceptionVariableName" value="expected"/>
0179 </module>
0180 <module name="CommentsIndentation"/>
0181 <module name="UnusedImports"/>
0182 <module name="RedundantImport"/>
0183 <module name="RedundantModifier"/>
0184 <module name="RegexpSinglelineJava">
0185 <property name="format" value="throw new \w+Error\("/>
0186 <property name="message" value="Avoid throwing error in application code."/>
0187 </module>
0188
0189 </module>
0190 </module>