Skip to content

Commit fe50e01

Browse files
committed
chore(pmd): enable some new rules from PMD 6.0.0
Quotes from https://pmd.github.io/2017/12/15/PMD-6.0.0/#new-rules % The new Java rule DoNotExtendJavaLangThrowable (category errorprone) is a companion for the java-strictexception.xml/DoNotExtendJavaLangError, detecting direct extensions of java.lang.Throwable. The new Java rule ForLoopCanBeForeach (category errorprone) helps to identify those for-loops that can be safely refactored into for-each-loops available since java 1.5. The new Java rule AvoidFileStream (category performance) helps to identify code relying on FileInputStream / FileOutputStream which, by using a finalizer, produces extra / unnecessary overhead to garbage collection, and should be replaced with Files.newInputStream / Files.newOutputStream available since java 1.7. The new Java rule DataClass (category design) detects simple data-holders without behaviour. This might indicate that the behaviour is scattered elsewhere and the data class exposes the internal data structure, which breaks encapsulation. % Note that DataClass rule is disabled because we use data classes extensively.
1 parent 40150b1 commit fe50e01

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/main/config/pmd.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<rule ref="category/java/bestpractices.xml/CheckResultSet" />
2121
<rule ref="category/java/bestpractices.xml/ConstantsInInterface" />
2222
<rule ref="category/java/bestpractices.xml/DefaultLabelNotLastInSwitchStmt" />
23+
<rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach" />
2324
<!--<rule ref="category/java/bestpractices.xml/JUnit4SuitesShouldUseSuiteAnnotation" />-->
2425
<rule ref="category/java/bestpractices.xml/JUnit4TestShouldUseAfterAnnotation" />
2526
<rule ref="category/java/bestpractices.xml/JUnit4TestShouldUseBeforeAnnotation" />
@@ -138,6 +139,7 @@
138139
<rule ref="category/java/design.xml/CouplingBetweenObjects" />
139140
<!-- We use ModifiedCyclomaticComplexity -->
140141
<!--<rule ref="category/java/design.xml/CyclomaticComplexity" />-->
142+
<!--<rule ref="category/java/design.xml/DataClass" />-->
141143
<rule ref="category/java/design.xml/DoNotExtendJavaLangError" />
142144
<rule ref="category/java/design.xml/ExceptionAsFlowControl" />
143145
<rule ref="category/java/design.xml/ExcessiveClassLength" />
@@ -208,6 +210,7 @@
208210
<!--<rule ref="category/java/errorprone.xml/DataflowAnomalyAnalysis" />-->
209211
<rule ref="category/java/errorprone.xml/DoNotCallGarbageCollectionExplicitly" />
210212
<rule ref="category/java/errorprone.xml/DoNotCallSystemExit" />
213+
<rule ref="category/java/errorprone.xml/DoNotExtendJavaLangThrowable" />
211214
<rule ref="category/java/errorprone.xml/DoNotThrowExceptionInFinally" />
212215
<rule ref="category/java/errorprone.xml/DontImportSun" />
213216
<rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices" />
@@ -281,6 +284,7 @@
281284
<rule ref="category/java/performance.xml/AddEmptyString" />
282285
<rule ref="category/java/performance.xml/AppendCharacterWithChar" />
283286
<rule ref="category/java/performance.xml/AvoidArrayLoops" />
287+
<rule ref="category/java/performance.xml/AvoidFileStream" />
284288
<rule ref="category/java/performance.xml/AvoidInstantiatingObjectsInLoops" />
285289
<rule ref="category/java/performance.xml/AvoidUsingShortType" />
286290
<rule ref="category/java/performance.xml/BigIntegerInstantiation" />

0 commit comments

Comments
 (0)