Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 1 | <?xml version="1.0"?> |
| 2 | <!DOCTYPE module PUBLIC |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 3 | "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" |
| 4 | "https://checkstyle.org/dtds/configuration_1_3.dtd"> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 5 | |
| 6 | <!-- |
| 7 | |
| 8 | Checkstyle configuration that checks the sun coding conventions from: |
| 9 | |
| 10 | - the Java Language Specification at |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 11 | https://docs.oracle.com/javase/specs/jls/se11/html/index.html |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 12 | |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 13 | - the Sun Code Conventions at https://www.oracle.com/technetwork/java/codeconvtoc-136057.html |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 14 | |
| 15 | - the Javadoc guidelines at |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 16 | https://www.oracle.com/technetwork/java/javase/documentation/index-137868.html |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 17 | |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 18 | - the JDK Api documentation https://docs.oracle.com/en/java/javase/11/ |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 19 | |
| 20 | - some best practices |
| 21 | |
| 22 | Checkstyle is very configurable. Be sure to read the documentation at |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 23 | https://checkstyle.org (or in your downloaded distribution). |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 24 | |
| 25 | Most Checks are configurable, be sure to consult the documentation. |
| 26 | |
| 27 | To completely disable a check, just comment it out or delete it from the file. |
| 28 | |
| 29 | Finally, it is worth reading the documentation. |
| 30 | |
| 31 | --> |
| 32 | |
| 33 | <module name="Checker"> |
| 34 | <!-- |
| 35 | If you set the basedir property below, then all reported file |
| 36 | names will be relative to the specified directory. See |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 37 | https://checkstyle.org/5.x/config.html#Checker |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 38 | |
| 39 | <property name="basedir" value="${basedir}"/> |
| 40 | --> |
| 41 | |
| 42 | <property name="fileExtensions" value="java, properties, xml"/> |
| 43 | |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 44 | <!-- Excludes all 'module-info.java' files --> |
| 45 | <!-- See https://checkstyle.org/config_filefilters.html --> |
| 46 | <module name="BeforeExecutionExclusionFileFilter"> |
| 47 | <property name="fileNamePattern" value="module\-info\.java$"/> |
| 48 | </module> |
| 49 | |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 50 | <!-- Checks that a package-info.java file exists for each package. --> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 51 | <!-- See https://checkstyle.org/config_javadoc.html#JavadocPackage --> |
| 52 | <!-- <module name="JavadocPackage"/> --> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 53 | |
| 54 | <!-- Checks whether files end with a new line. --> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 55 | <!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile --> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 56 | <module name="NewlineAtEndOfFile"/> |
| 57 | |
| 58 | <!-- Checks that property files contain the same keys. --> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 59 | <!-- See https://checkstyle.org/config_misc.html#Translation --> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 60 | <module name="Translation"/> |
| 61 | |
| 62 | <!-- Checks for Size Violations. --> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 63 | <!-- See https://checkstyle.org/config_sizes.html --> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 64 | <module name="FileLength"/> |
| 65 | |
| 66 | <!-- Checks for whitespace --> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 67 | <!-- See https://checkstyle.org/config_whitespace.html --> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 68 | <module name="FileTabCharacter"/> |
| 69 | |
| 70 | <!-- Miscellaneous other checks. --> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 71 | <!-- See https://checkstyle.org/config_misc.html --> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 72 | <module name="RegexpSingleline"> |
| 73 | <property name="format" value="\s+$"/> |
| 74 | <property name="minimum" value="0"/> |
| 75 | <property name="maximum" value="0"/> |
| 76 | <property name="message" value="Line has trailing spaces."/> |
| 77 | </module> |
| 78 | |
| 79 | <!-- Checks for Headers --> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 80 | <!-- See https://checkstyle.org/config_header.html --> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 81 | <!-- <module name="Header"> --> |
| 82 | <!-- <property name="headerFile" value="${checkstyle.header.file}"/> --> |
| 83 | <!-- <property name="fileExtensions" value="java"/> --> |
| 84 | <!-- </module> --> |
| 85 | |
| 86 | <module name="TreeWalker"> |
| 87 | |
| 88 | <!-- Checks for Javadoc comments. --> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 89 | <!-- See https://checkstyle.org/config_javadoc.html --> |
| 90 | <module name="InvalidJavadocPosition"/> |
| 91 | <module name="JavadocMethod"/> |
| 92 | <module name="JavadocType"/> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 93 | <module name="JavadocVariable"> |
| 94 | <property name="excludeScope" value="private"/> |
| 95 | </module> |
| 96 | <module name="JavadocStyle"/> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 97 | <!-- <module name="MissingJavadocMethod"/> --> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 98 | |
| 99 | <!-- Checks for Naming Conventions. --> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 100 | <!-- See https://checkstyle.org/config_naming.html --> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 101 | <module name="ConstantName"/> |
| 102 | <module name="LocalFinalVariableName"/> |
| 103 | <module name="LocalVariableName"/> |
| 104 | <module name="MemberName"/> |
| 105 | <module name="MethodName"/> |
| 106 | <module name="PackageName"/> |
| 107 | <module name="ParameterName"/> |
| 108 | <module name="StaticVariableName"/> |
| 109 | <module name="TypeName"/> |
| 110 | |
| 111 | <!-- Checks for imports --> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 112 | <!-- See https://checkstyle.org/config_import.html --> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 113 | <module name="AvoidStarImport"/> |
| 114 | <module name="IllegalImport"/> <!-- defaults to sun.* packages --> |
| 115 | <module name="RedundantImport"/> |
| 116 | <module name="UnusedImports"> |
| 117 | <property name="processJavadoc" value="false"/> |
| 118 | </module> |
| 119 | |
| 120 | <!-- Checks for Size Violations. --> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 121 | <!-- See https://checkstyle.org/config_sizes.html --> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 122 | <module name="LineLength"> |
| 123 | <property name="max" value="120"/> |
| 124 | </module> |
| 125 | <module name="MethodLength"/> |
| 126 | <module name="ParameterNumber"/> |
| 127 | |
| 128 | <!-- Checks for whitespace --> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 129 | <!-- See https://checkstyle.org/config_whitespace.html --> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 130 | <module name="EmptyForIteratorPad"/> |
| 131 | <module name="GenericWhitespace"/> |
| 132 | <module name="MethodParamPad"/> |
| 133 | <module name="NoWhitespaceAfter"/> |
| 134 | <module name="NoWhitespaceBefore"/> |
| 135 | <module name="OperatorWrap"> |
| 136 | <property name="option" value="eol"/> |
| 137 | </module> |
| 138 | <module name="ParenPad"/> |
| 139 | <module name="TypecastParenPad"/> |
| 140 | <module name="WhitespaceAfter"/> |
| 141 | <module name="WhitespaceAround"/> |
| 142 | |
| 143 | <!-- Modifier Checks --> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 144 | <!-- See https://checkstyle.org/config_modifiers.html --> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 145 | <module name="ModifierOrder"/> |
| 146 | <module name="RedundantModifier"/> |
| 147 | |
| 148 | <!-- Checks for blocks. You know, those {}'s --> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 149 | <!-- See https://checkstyle.org/config_blocks.html --> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 150 | <module name="AvoidNestedBlocks"/> |
| 151 | <module name="EmptyBlock"/> |
| 152 | <module name="LeftCurly"/> |
| 153 | <module name="NeedBraces"/> |
| 154 | <module name="RightCurly"/> |
| 155 | |
| 156 | <!-- Checks for common coding problems --> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 157 | <!-- See https://checkstyle.org/config_coding.html --> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 158 | <module name="EmptyStatement"/> |
| 159 | <module name="EqualsHashCode"/> |
| 160 | <!-- <module name="HiddenField"/> --> |
| 161 | <module name="IllegalInstantiation"/> |
| 162 | <module name="InnerAssignment"/> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 163 | <!-- <module name="MagicNumber"/> --> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 164 | <module name="MissingSwitchDefault"/> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 165 | <module name="MultipleVariableDeclarations"/> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 166 | <module name="SimplifyBooleanExpression"/> |
| 167 | <module name="SimplifyBooleanReturn"/> |
| 168 | |
| 169 | <!-- Checks for class design --> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 170 | <!-- See https://checkstyle.org/config_design.html --> |
| 171 | <!-- <module name="DesignForExtension"/> --> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 172 | <module name="FinalClass"/> |
| 173 | <module name="HideUtilityClassConstructor"/> |
| 174 | <module name="InterfaceIsType"/> |
| 175 | <module name="VisibilityModifier"/> |
| 176 | |
| 177 | <!-- Miscellaneous other checks. --> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 178 | <!-- See https://checkstyle.org/config_misc.html --> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 179 | <module name="ArrayTypeStyle"/> |
| 180 | <module name="FinalParameters"/> |
Davide Pesavento | b6df513 | 2019-09-24 14:05:00 -0400 | [diff] [blame] | 181 | <!-- <module name="TodoComment"/> --> |
Alexander Afanasyev | e36e1af | 2016-02-19 18:06:05 -0800 | [diff] [blame] | 182 | <module name="UpperEll"/> |
| 183 | |
| 184 | </module> |
| 185 | |
| 186 | </module> |