|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" |
| 3 | + "https://checkstyle.org/dtds/configuration_1_3.dtd"> |
| 4 | + |
| 5 | +<!-- |
| 6 | + Checkstyle-Configuration: LinkedIn Style |
| 7 | + Description: |
| 8 | +LinkedIn Java style. |
| 9 | +--> |
| 10 | +<module name="Checker"> |
| 11 | + <property name="severity" value="warning"/> |
| 12 | + <property name="fileExtensions" value="java"/> |
| 13 | + |
| 14 | + <module name="TreeWalker"> |
| 15 | + <property name="tabWidth" value="2"/> |
| 16 | + <module name="SuppressWarningsHolder"/> |
| 17 | + |
| 18 | + <!-- Allow Checkstyle warnings to be suppressed using trailing comments --> |
| 19 | + <module name="SuppressWithNearbyCommentFilter"/> |
| 20 | + <!-- Allow Checkstyle warnings to be suppressed using block comments --> |
| 21 | + <module name="SuppressionCommentFilter"/> |
| 22 | + |
| 23 | + <!-- ANNOTATIONS --> |
| 24 | + |
| 25 | + <!-- No trailing empty parenthesis or commas --> |
| 26 | + <module name="AnnotationUseStyle"> |
| 27 | + <property name="elementStyle" value="ignore"/> |
| 28 | + </module> |
| 29 | + <!-- Ensure @Override is present when {@inheritDoc} Javadoc tag is present --> |
| 30 | + <module name="MissingOverride"/> |
| 31 | + <!-- Package level annotations belong in package-info.java --> |
| 32 | + <module name="PackageAnnotation"/> |
| 33 | + <!-- Do not allow references to internal tickets --> |
| 34 | + <module name="Regexp"> |
| 35 | + <property name="format" value="(DDSDBUS|LISAMZA|DATAPIPES)-\d+"/> |
| 36 | + <property name="illegalPattern" value="true"/> |
| 37 | + <property name="message" value="Referencing internal ticket names is not allowed"/> |
| 38 | + </module> |
| 39 | + |
| 40 | + <!-- BLOCKS --> |
| 41 | + |
| 42 | + <!-- No empty while, try, finally, do, if, else, for, initializer, switch, or synchronized blocks --> |
| 43 | + <module name="EmptyBlock"/> |
| 44 | + <!-- Block opening brace on same line --> |
| 45 | + <module name="LeftCurly"> |
| 46 | + <property name="option" value="eol"/> |
| 47 | + </module> |
| 48 | + <!-- Block closing brace for else, catch, finally on same line --> |
| 49 | + <module name="RightCurly"> |
| 50 | + <property name="option" value="same"/> |
| 51 | + </module> |
| 52 | + <!-- Always use braces even if optional --> |
| 53 | + <module name="NeedBraces"/> |
| 54 | + |
| 55 | + <!-- CLASS DESIGN --> |
| 56 | + |
| 57 | + <!-- A class with only private constructors must be declared final --> |
| 58 | + <module name="FinalClass"/> |
| 59 | + <!-- Classes containing only static methods should not have a public constructor --> |
| 60 | + <module name="HideUtilityClassConstructor"/> |
| 61 | + |
| 62 | + <!-- CODING --> |
| 63 | + |
| 64 | + <!-- Use Java style array declarations (e.g. String[] names), not C style (e.g. String names[]) --> |
| 65 | + <module name="ArrayTypeStyle"/> |
| 66 | + <!-- If covariant equals defined, standard equals must also be defined --> |
| 67 | + <module name="CovariantEquals"/> |
| 68 | + <!-- Switch 'default' case must appear last --> |
| 69 | + <module name="DefaultComesLast"/> |
| 70 | + <!-- Call equals on string literals to avoid an NPE --> |
| 71 | + <module name="EqualsAvoidNull"/> |
| 72 | + <!-- Override equals and hashCode together --> |
| 73 | + <module name="EqualsHashCode"/> |
| 74 | + <!-- No fall through in switch cases, even the last one --> |
| 75 | + <module name="FallThrough"> |
| 76 | + <property name="checkLastCaseGroup" value="true"/> |
| 77 | + </module> |
| 78 | + <!-- Do not perform assignments embedded within expressions --> |
| 79 | + <module name="InnerAssignment"/> |
| 80 | + <!-- Switch statements must have a 'default' case --> |
| 81 | + <module name="MissingSwitchDefault"/> |
| 82 | + <!-- Do not modify the 'for' loop control variable --> |
| 83 | + <module name="ModifiedControlVariable"/> |
| 84 | + <!-- Each variable declaration must be on a separate line --> |
| 85 | + <module name="MultipleVariableDeclarations"/> |
| 86 | + <!-- Do not use finalize --> |
| 87 | + <module name="NoFinalizer"/> |
| 88 | + <!-- Each statement (i.e. code terminated by a semicolon) must be on a separate line --> |
| 89 | + <module name="OneStatementPerLine"/> |
| 90 | + <!-- Classes must have an explicit package declaration --> |
| 91 | + <module name="PackageDeclaration"/> |
| 92 | + <!-- Do not reassign method parameters --> |
| 93 | + <module name="ParameterAssignment"/> |
| 94 | + <!-- Do not test boolean expressions against the values true or false --> |
| 95 | + <module name="SimplifyBooleanExpression"/> |
| 96 | + <!-- Do not test for boolean conditions and return the values true or false --> |
| 97 | + <module name="SimplifyBooleanReturn"/> |
| 98 | + <!-- Do not use '==' to compare string against a literal; use 'equals' --> |
| 99 | + <module name="StringLiteralEquality"/> |
| 100 | + <!-- Use 'L' with long literals --> |
| 101 | + <module name="UpperEll"/> |
| 102 | + |
| 103 | + <!-- IMPORTS --> |
| 104 | + |
| 105 | + <!-- No imports statements using '*' --> |
| 106 | + <module name="AvoidStarImport"/> |
| 107 | + <!-- Do not import 'sun' packages --> |
| 108 | + <module name="IllegalImport"/> |
| 109 | + <!-- Do not duplicate import statements --> |
| 110 | + <module name="RedundantImport"/> |
| 111 | + <!-- Eliminate unused imports --> |
| 112 | + <module name="UnusedImports"/> |
| 113 | + |
| 114 | + <!-- Import ordering --> |
| 115 | + <module name="ImportOrder"> |
| 116 | + <property name="groups" value="/^javax?\./,/^org\./,*,/^com\.linkedin\./"/> |
| 117 | + <property name="separated" value="true"/> |
| 118 | + <property name="ordered" value="true"/> |
| 119 | + <property name="caseSensitive" value="true"/> |
| 120 | + <property name="sortStaticImportsAlphabetically" value="true"/> |
| 121 | + <property name="option" value="bottom"/> |
| 122 | + </module> |
| 123 | + |
| 124 | + <!-- JAVADOC COMMENTS --> |
| 125 | + |
| 126 | + <!-- If you have a Javadoc comment, make sure it is properly formed --> |
| 127 | + <module name="JavadocStyle"> |
| 128 | + <property name="checkFirstSentence" value="false"/> |
| 129 | + </module> |
| 130 | + |
| 131 | + <!-- MISCELLANEOUS --> |
| 132 | + |
| 133 | + <!-- Ensure filename matches outer class name --> |
| 134 | + <module name="OuterTypeFilename"/> |
| 135 | + |
| 136 | + <!-- MODIFIERS --> |
| 137 | + |
| 138 | + <!-- Avoid redundant modifiers such as public in interface method decls, per the Java Language spec --> |
| 139 | + <module name="RedundantModifier"/> |
| 140 | + |
| 141 | + <!-- NAMING CONVENTIONS --> |
| 142 | + |
| 143 | + <!-- Generic parameters for a class must be uppercase letters separated by underscores (e.g. <V>, <NEW>, <KEY_T>) --> |
| 144 | + <module name="ClassTypeParameterName"> |
| 145 | + <property name="format" value="^[A-Z]+(_[A-Z]+)*$"/> |
| 146 | + </module> |
| 147 | + <!-- Constants must be all uppercase letters separated by underscores --> |
| 148 | + <module name="ConstantName"> |
| 149 | + <property name="format" value="^(_?log)|([A-Z][A-Z0-9]*(_[A-Z0-9]+)*)$"/> |
| 150 | + </module> |
| 151 | + <!-- Local variables must be camel case starting with lowercase letter --> |
| 152 | + <module name="LocalFinalVariableName"/> |
| 153 | + <module name="LocalVariableName"/> |
| 154 | + <!-- Member variables must be camel case starting with an underscore or lowercase letter --> |
| 155 | + <module name="MemberName"> |
| 156 | + <property name="format" value="^[_a-z][a-zA-Z0-9]*$"/> |
| 157 | + </module> |
| 158 | + <!-- Method name must be camel case starting with a lowercase letter --> |
| 159 | + <module name="MethodName"/> |
| 160 | + <!-- Generic parameters for a method must be uppercase letters separated by underscores (e.g. <V>, <NEW>, <KEY_T>) --> |
| 161 | + <module name="MethodTypeParameterName"> |
| 162 | + <property name="format" value="^[A-Z]+(_[A-Z]+)*$"/> |
| 163 | + </module> |
| 164 | + <!-- Package name must be all lowercase letters separated by periods --> |
| 165 | + <module name="PackageName"> |
| 166 | + <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/> |
| 167 | + </module> |
| 168 | + <!-- Parameters must be camel case starting with a lowercase letter --> |
| 169 | + <module name="ParameterName"/> |
| 170 | + <!-- Static variables must be camel case starting with an underscore or lowercase letter --> |
| 171 | + <module name="StaticVariableName"> |
| 172 | + <property name="format" value="^[_a-z][a-zA-Z0-9]*$"/> |
| 173 | + </module> |
| 174 | + <!-- Type names must be camel case starting with an uppercase letter --> |
| 175 | + <module name="TypeName"/> |
| 176 | + |
| 177 | + <!-- WHITESPACE --> |
| 178 | + |
| 179 | + <module name="GenericWhitespace"/> |
| 180 | + <module name="MethodParamPad"/> |
| 181 | + <!-- Do not wrap package and import declarations --> |
| 182 | + <module name="NoLineWrap"/> |
| 183 | + <module name="NoWhitespaceAfter"> |
| 184 | + <property name="tokens" value="BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS"/> |
| 185 | + </module> |
| 186 | + <module name="NoWhitespaceBefore"/> |
| 187 | + <module name="OperatorWrap"/> |
| 188 | + <module name="ParenPad"/> |
| 189 | + <module name="TypecastParenPad"> |
| 190 | + <property name="tokens" value="RPAREN,TYPECAST"/> |
| 191 | + </module> |
| 192 | + <module name="WhitespaceAfter"/> |
| 193 | + <module name="WhitespaceAround"/> |
| 194 | + |
| 195 | + <!-- Do not allow meaningless, IDE generated parameter names --> |
| 196 | + <module name="RegexpSinglelineJava"> |
| 197 | + <property name="format" value="[\s]+arg[\d]+[,\)]"/> |
| 198 | + <property name="message" value="Replace argN with a meaningful parameter name"/> |
| 199 | + </module> |
| 200 | + </module> |
| 201 | + |
| 202 | + <!-- LENGTHS --> |
| 203 | + |
| 204 | + <!-- Desired line length is 120 but allow some overrun beyond that --> |
| 205 | + <module name="LineLength"> |
| 206 | + <property name="max" value="160"/> |
| 207 | + <message key="maxLineLen" |
| 208 | + value="Line is longer than {0,number,integer} characters (found {1,number,integer}). Try to keep lines under 120 characters."/> |
| 209 | + </module> |
| 210 | + |
| 211 | + <!-- Do not allow tab characters in source files --> |
| 212 | + <module name="FileTabCharacter"/> |
| 213 | + |
| 214 | + <!-- Ensure parameter and exception names are present on @param and @throws tags --> |
| 215 | + <module name="RegexpSingleline"> |
| 216 | + <property name="format" value="\*[\s]*@(throws|param)[\s]*$"/> |
| 217 | + <property name="message" value="Missing parameter or exception name"/> |
| 218 | + </module> |
| 219 | + <!-- IDE generated code must be reviewed by developer --> |
| 220 | + <module name="RegexpSingleline"> |
| 221 | + <property name="format" value="\/\/[\s]*TODO[\s]+Auto-generated"/> |
| 222 | + <property name="message" value="Replace IDE generated code with real implementation"/> |
| 223 | + </module> |
| 224 | + <!-- Detect commonly misspelled Javadoc tags --> |
| 225 | + <module name="RegexpSingleline"> |
| 226 | + <property name="format" value="\*[\s]*@(params|throw|returns)[\s]+"/> |
| 227 | + <property name="message" value="Correct misspelled Javadoc tag"/> |
| 228 | + </module> |
| 229 | + |
| 230 | + <!-- Read checker suppressions from a file --> |
| 231 | + <module name="SuppressionFilter"> |
| 232 | + <property name="file" value="${config_loc}/suppressions.xml"/> |
| 233 | + </module> |
| 234 | + |
| 235 | + <!-- Allow SuppressWarnings annotation to suppress Checkstyle issues --> |
| 236 | + <module name="SuppressWarningsFilter"/> |
| 237 | +</module> |
0 commit comments