Skip to content

Commit 333e009

Browse files
committed
CheckStyle: Update rule set
- Remove HideUtilityClassConstructor check. Fixing these violations would require adding ~104 empty private constructors to hide default constructors. This should not be forced upon contributors. - Ignore MethodName check. Changing public method names will break any extensions that uses them. This should not be done without deprecating all violating methods first. - Remove MissingCtor check. This would require adding ~1100 empty constructors to not directly rely on the default one. This should not be forced upon contributors and does not make the code more clear. - Change whitespace check for "try", which now enforces whitespace usage "try(" and "try {". - Disable "SuperClone" and "SuperFinalize" check. These checks even require to call super.clone() and super.finalize() when their class extends directly from Object, in which case adding them is pointless and at most distracting. - Fix whitespace check for between if/for/while and their '('.
1 parent 065ca39 commit 333e009

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed

checkstyle.xml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@
6363
<!-- Ensure proper whitespace usage around "<" and ">" for generic types -->
6464
<module name="GenericWhitespace"/>
6565

66-
<!-- Ensure that classes with only static methods do not have a public constructor -->
67-
<module name="HideUtilityClassConstructor"/>
68-
6966
<!-- Disallow native literals -->
7067
<module name="IllegalToken">
7168
<property name="tokens" value="LITERAL_NATIVE"/>
@@ -86,17 +83,17 @@
8683
<module name="MemberName"/>
8784

8885
<!-- Ensure method name format and disallow methods to be named the same as the class (and therefore constructor). Default format: "^[a-z][a-zA-Z0-9]*$" -->
89-
<module name="MethodName"/>
86+
<module name="MethodName">
87+
<!-- TODO: Disable rule or fix violations with the chance to break extensions. There are 479 violations as of 14-06-2018 dd-mm-yyyy -->
88+
<property name="severity" value="ignore"/>
89+
</module>
9090

9191
<!-- Check method parameter padding -->
9292
<module name="MethodParamPad"/>
9393

9494
<!-- Check method type name format. Default format: "^[A-Z]$" -->
9595
<module name="MethodTypeParameterName"/>
9696

97-
<!-- Ensure that non-abstract classes define a constructor and not rely on the default one -->
98-
<module name="MissingCtor"/>
99-
10097
<!-- Ensure that both the @Deprecated and the @deprecated javadoc tag are present when one is present -->
10198
<module name="MissingDeprecated"/>
10299

@@ -137,7 +134,7 @@
137134
<property name="allowEmptyCatches" value="true"/>
138135
<property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR,
139136
BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAMBDA, LAND, LCURLY, LE, LITERAL_CATCH, LITERAL_DO,
140-
LITERAL_ELSE, LITERAL_FINALLY, LITERAL_RETURN, LITERAL_TRY,
137+
LITERAL_ELSE, LITERAL_FINALLY, LITERAL_RETURN,
141138
LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION,
142139
RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN, TYPE_EXTENSION_AND"/>
143140
</module>
@@ -163,9 +160,6 @@
163160
<!-- Disallow redundant (double or default-available class) imports -->
164161
<module name="RedundantImport"/>
165162

166-
<!-- Require "this" for non-static field access -->
167-
<module name="RequireThis"/>
168-
169163
<!-- Ensure usage of "}" for the given tokens -->
170164
<module name="RightCurly">
171165
<property name="tokens" value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE"/>
@@ -189,12 +183,6 @@
189183
<!-- Disallow the "==" operator for string literals -->
190184
<module name="StringLiteralEquality"/>
191185

192-
<!-- Ensure that an overriding clone() method invokes super.clone() -->
193-
<module name="SuperClone"/>
194-
195-
<!-- Ensure that an overriding finalize() method invokes super.finalize() -->
196-
<module name="SuperFinalize"/>
197-
198186
<!-- Disallow whitespaces between type cast parenthesis (No whitespace at X: "(XObjectX) obj") -->
199187
<module name="TypecastParenPad"/>
200188

@@ -219,10 +207,24 @@
219207
<!-- Disallow whitespaces between if/for/while and '(' -->
220208
<module name="RegexpSingleline">
221209
<property name="severity" value="error"/>
222-
<property name="format" value="(^|[^w\._])(if|for|while)[\s]+\("/>
210+
<property name="format" value="(^|[^\w\._])(if|for|while)[\s]+\("/>
223211
<property name="message" value="Whitespace between if/for/while and '(' is not allowed."/>
224212
</module>
225213

214+
<!-- Ensure whitespace between try and '{' -->
215+
<module name="RegexpSingleline">
216+
<property name="severity" value="error"/>
217+
<property name="format" value="(^|[^\w\._])try\{"/>
218+
<property name="message" value="'try' is not followed by whitespace."/>
219+
</module>
220+
221+
<!-- Disallow whitespaces between try and '(' (try-with-resources) -->
222+
<module name="RegexpSingleline">
223+
<property name="severity" value="error"/>
224+
<property name="format" value="(^|[^\w\._])try[\s]+\("/>
225+
<property name="message" value="'try' with resources is followed by whitespace."/>
226+
</module>
227+
226228
<!-- Ensure that every file ends with a newline -->
227229
<module name="NewlineAtEndOfFile"/>
228230

checkstyle_suppressions.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,11 @@
99
<!-- Ignore type name check for package "com.laytonsmith.core.functions" since function classes use a different format -->
1010
<suppress checks="TypeName" files="com[\\/]laytonsmith[\\/]core[\\/]functions.*\.java$"/>
1111

12+
<!-- Ignore local variable name check for package "com.laytonsmith.core.functions" since many variables are called after CH functions -->
13+
<suppress checks="LocalVariableName" files="com[\\/]laytonsmith[\\/]core[\\/]functions.*\.java$"/>
14+
15+
<!-- Ignore type name check for package "com.laytonsmith.core.events drivers" since event driver classes use a different format -->
16+
<suppress checks="TypeName" files="com[\\/]laytonsmith[\\/]core[\\/]events[\\/]drivers.*\.java$"/>
17+
18+
1219
</suppressions>

0 commit comments

Comments
 (0)