Skip to content

Commit 8dfcae7

Browse files
ginoaugustinevladak
authored andcommitted
Upgrade PMD and remove deprecated rulesets
Signed-off-by: Gino Augustine <[email protected]>
1 parent 5037bf6 commit 8dfcae7

File tree

2 files changed

+157
-35
lines changed

2 files changed

+157
-35
lines changed

dev/pmd_ruleset.xml

Lines changed: 154 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,158 @@
88
<description>
99
Settings for PMD, tuned for the OpenGrok project.
1010
</description>
11-
12-
<rule ref="rulesets/java/strings.xml"/>
13-
<rule ref="rulesets/java/basic.xml"/>
14-
<rule ref="rulesets/java/braces.xml"/>
15-
<rule ref="rulesets/java/clone.xml"/>
16-
<rule ref="rulesets/java/design.xml"/>
17-
<rule ref="rulesets/java/finalizers.xml"/>
18-
<rule ref="rulesets/java/imports.xml"/>
19-
<rule ref="rulesets/java/junit.xml">
20-
<!-- enable bellow to push people to write asserts which are easier to understand -->
21-
<exclude name="JUnitAssertionsShouldIncludeMessage"/>
22-
</rule>
23-
<rule ref="rulesets/java/logging-java.xml"/>
24-
<rule ref="rulesets/java/migrating.xml"/>
25-
<rule ref="rulesets/java/optimizations.xml">
26-
<exclude name="AvoidInstantiatingObjectsInLoops"/>
27-
<!-- Enable the following when we have fever reported warnings -->
28-
<exclude name="LocalVariableCouldBeFinal"/>
29-
<exclude name="MethodArgumentCouldBeFinal"/>
30-
</rule>
31-
<rule ref="rulesets/java/strictexception.xml"/>
32-
<rule ref="rulesets/java/strings.xml"/>
33-
<rule ref="rulesets/java/sunsecure.xml"/>
34-
<rule ref="rulesets/java/typeresolution.xml">
35-
<!-- <properties>
36-
<property name="IgnoreJUnitCompletely" value="true"/>
37-
</properties> -->
38-
</rule>
39-
<rule ref="rulesets/java/unusedcode.xml"/>
40-
<rule ref="rulesets/java/javabeans.xml/MissingSerialVersionUID"/>
41-
11+
<rule ref="category/java/errorprone.xml/AvoidDuplicateLiterals"/>
12+
<rule ref="category/java/errorprone.xml/StringBufferInstantiationWithChar"/>
13+
<rule ref="category/java/errorprone.xml/UnnecessaryCaseChange"/>
14+
<rule ref="category/java/errorprone.xml/UseEqualsToCompareStrings"/>
15+
<rule ref="category/java/bestpractices.xml/AvoidStringBufferField"/>
16+
<rule ref="category/java/performance.xml/AppendCharacterWithChar"/>
17+
<rule ref="category/java/performance.xml/ConsecutiveAppendsShouldReuse"/>
18+
<rule ref="category/java/performance.xml/ConsecutiveLiteralAppends"/>
19+
<rule ref="category/java/performance.xml/InefficientEmptyStringCheck"/>
20+
<rule ref="category/java/performance.xml/InefficientStringBuffering"/>
21+
<rule ref="category/java/performance.xml/InsufficientStringBufferDeclaration"/>
22+
<rule ref="category/java/performance.xml/StringInstantiation"/>
23+
<rule ref="category/java/performance.xml/StringToString"/>
24+
<rule ref="category/java/performance.xml/UseIndexOfChar"/>
25+
<rule ref="category/java/performance.xml/UselessStringValueOf"/>
26+
<rule ref="category/java/performance.xml/UseStringBufferLength"/>
27+
<rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop"/>
28+
<rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor"/>
29+
<rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators"/>
30+
<rule ref="category/java/errorprone.xml/AvoidUsingOctalValues"/>
31+
<rule ref="category/java/errorprone.xml/BrokenNullCheck"/>
32+
<rule ref="category/java/errorprone.xml/CheckSkipResult"/>
33+
<rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray"/>
34+
<rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices"/>
35+
<rule ref="category/java/errorprone.xml/JumbledIncrementer"/>
36+
<rule ref="category/java/errorprone.xml/MisplacedNullCheck"/>
37+
<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode"/>
38+
<rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock"/>
39+
<rule ref="category/java/errorprone.xml/UnconditionalIfStatement"/>
40+
<rule ref="category/java/multithreading.xml/AvoidThreadGroup"/>
41+
<rule ref="category/java/multithreading.xml/DontCallThreadRun"/>
42+
<rule ref="category/java/multithreading.xml/DoubleCheckedLocking"/>
43+
<rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP"/>
44+
<rule ref="category/java/bestpractices.xml/CheckResultSet"/>
45+
<rule ref="category/java/codestyle.xml/ExtendsObject"/>
46+
<rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop"/>
47+
<rule ref="category/java/performance.xml/BigIntegerInstantiation"/>
48+
<rule ref="category/java/design.xml/CollapsibleIfStatements"/>
49+
<rule ref="category/java/design.xml/SimplifiedTernary"/>
50+
<rule ref="category/java/errorprone.xml/CloneMethodMustBePublic" />
51+
<rule ref="category/java/errorprone.xml/CloneMethodMustImplementCloneable" />
52+
<rule ref="category/java/errorprone.xml/CloneMethodReturnTypeMustMatchClassName" />
53+
<rule ref="category/java/errorprone.xml/ProperCloneImplementation" />
54+
<rule ref="category/java/design.xml/AbstractClassWithoutAnyMethod" />
55+
<rule ref="category/java/design.xml/AvoidDeeplyNestedIfStmts" />
56+
<rule ref="category/java/design.xml/ClassWithOnlyPrivateConstructorsShouldBeFinal" />
57+
<rule ref="category/java/design.xml/DataClass" />
58+
<rule ref="category/java/design.xml/FinalFieldCouldBeStatic" />
59+
<rule ref="category/java/design.xml/GodClass" />
60+
<rule ref="category/java/design.xml/ImmutableField" />
61+
<rule ref="category/java/design.xml/LogicInversion" />
62+
<rule ref="category/java/design.xml/SimplifyBooleanExpressions" />
63+
<rule ref="category/java/design.xml/SimplifyBooleanReturns" />
64+
<rule ref="category/java/design.xml/SimplifyConditional" />
65+
<rule ref="category/java/design.xml/SingularField" />
66+
<rule ref="category/java/design.xml/SwitchDensity" />
67+
<rule ref="category/java/design.xml/UseUtilityClass" />
68+
<rule ref="category/java/errorprone.xml/AssignmentToNonFinalStatic" />
69+
<rule ref="category/java/errorprone.xml/AvoidInstanceofChecksInCatchClause" />
70+
<rule ref="category/java/errorprone.xml/CloseResource" />
71+
<rule ref="category/java/errorprone.xml/CompareObjectsWithEquals" />
72+
<rule ref="category/java/errorprone.xml/ConstructorCallsOverridableMethod" />
73+
<rule ref="category/java/errorprone.xml/EqualsNull" />
74+
<rule ref="category/java/errorprone.xml/IdempotentOperations" />
75+
<rule ref="category/java/errorprone.xml/InstantiationToGetClass" />
76+
<rule ref="category/java/errorprone.xml/MissingStaticMethodInNonInstantiatableClass" />
77+
<rule ref="category/java/errorprone.xml/NonCaseLabelInSwitchStatement" />
78+
<rule ref="category/java/errorprone.xml/NonStaticInitializer" />
79+
<rule ref="category/java/errorprone.xml/SimpleDateFormatNeedsLocale" />
80+
<rule ref="category/java/errorprone.xml/SingleMethodSingleton" />
81+
<rule ref="category/java/errorprone.xml/SingletonClassReturningNewInstance" />
82+
<rule ref="category/java/errorprone.xml/UseLocaleWithCaseConversions" />
83+
<rule ref="category/java/codestyle.xml/AvoidProtectedFieldInFinalClass" />
84+
<rule ref="category/java/codestyle.xml/AvoidProtectedMethodInFinalClassNotExtending" />
85+
<rule ref="category/java/codestyle.xml/ConfusingTernary" />
86+
<rule ref="category/java/codestyle.xml/EmptyMethodInAbstractClassShouldBeAbstract" />
87+
<rule ref="category/java/codestyle.xml/FieldDeclarationsShouldBeAtStartOfClass" />
88+
<rule ref="category/java/codestyle.xml/UnnecessaryLocalBeforeReturn" />
89+
<rule ref="category/java/multithreading.xml/AvoidSynchronizedAtMethodLevel" />
90+
<rule ref="category/java/multithreading.xml/NonThreadSafeSingleton" />
91+
<rule ref="category/java/multithreading.xml/UseNotifyAllInsteadOfNotify" />
92+
<rule ref="category/java/bestpractices.xml/AbstractClassWithoutAbstractMethod" />
93+
<rule ref="category/java/bestpractices.xml/AccessorClassGeneration" />
94+
<rule ref="category/java/bestpractices.xml/AccessorMethodGeneration" />
95+
<rule ref="category/java/bestpractices.xml/AvoidReassigningParameters" />
96+
<rule ref="category/java/bestpractices.xml/ConstantsInInterface" />
97+
<rule ref="category/java/bestpractices.xml/DefaultLabelNotLastInSwitchStmt" />
98+
<rule ref="category/java/bestpractices.xml/PreserveStackTrace" />
99+
<rule ref="category/java/bestpractices.xml/SwitchStmtsShouldHaveDefault" />
100+
<rule ref="category/java/bestpractices.xml/UseCollectionIsEmpty" />
101+
<rule ref="category/java/bestpractices.xml/UseVarargs" />
102+
<rule ref="category/java/performance.xml/OptimizableToArrayCall" />
103+
<rule ref="category/java/performance.xml/TooFewBranchesForASwitchStatement" />
104+
<rule ref="category/java/documentation.xml/UncommentedEmptyConstructor" />
105+
<rule ref="category/java/documentation.xml/UncommentedEmptyMethodBody" />
106+
<rule ref="category/java/errorprone.xml/AvoidCallingFinalize" />
107+
<rule ref="category/java/errorprone.xml/EmptyFinalizer" />
108+
<rule ref="category/java/errorprone.xml/FinalizeDoesNotCallSuperFinalize" />
109+
<rule ref="category/java/errorprone.xml/FinalizeOnlyCallsSuperFinalize" />
110+
<rule ref="category/java/errorprone.xml/FinalizeOverloaded" />
111+
<rule ref="category/java/errorprone.xml/FinalizeShouldBeProtected" />
112+
<rule ref="category/java/codestyle.xml/TooManyStaticImports" />
113+
<rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName" />
114+
<rule ref="category/java/codestyle.xml/ControlStatementBraces"/>
115+
<rule ref="category/java/errorprone.xml/JUnitSpelling"/>
116+
<rule ref="category/java/errorprone.xml/JUnitStaticSuite"/>
117+
<rule ref="category/java/errorprone.xml/TestClassWithoutTestCases"/>
118+
<rule ref="category/java/errorprone.xml/UnnecessaryBooleanAssertion"/>
119+
<rule ref="category/java/bestpractices.xml/JUnitTestContainsTooManyAsserts"/>
120+
<rule ref="category/java/bestpractices.xml/JUnitTestsShouldIncludeAssert"/>
121+
<rule ref="category/java/errorprone.xml/MoreThanOneLogger" />
122+
<rule ref="category/java/bestpractices.xml/AvoidPrintStackTrace" />
123+
<rule ref="category/java/bestpractices.xml/GuardLogStatement" name="GuardLogStatementJavaUtil" />
124+
<rule ref="category/java/bestpractices.xml/SystemPrintln" />
125+
<rule ref="category/java/errorprone.xml/AvoidAssertAsIdentifier" />
126+
<rule ref="category/java/errorprone.xml/AvoidEnumAsIdentifier" />
127+
<rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach" />
128+
<rule ref="category/java/bestpractices.xml/JUnit4SuitesShouldUseSuiteAnnotation" />
129+
<rule ref="category/java/bestpractices.xml/JUnit4TestShouldUseAfterAnnotation" />
130+
<rule ref="category/java/bestpractices.xml/JUnit4TestShouldUseBeforeAnnotation" />
131+
<rule ref="category/java/bestpractices.xml/JUnit4TestShouldUseTestAnnotation" />
132+
<rule ref="category/java/bestpractices.xml/JUnitUseExpected" />
133+
<rule ref="category/java/bestpractices.xml/ReplaceEnumerationWithIterator" />
134+
<rule ref="category/java/bestpractices.xml/ReplaceHashtableWithMap" />
135+
<rule ref="category/java/bestpractices.xml/ReplaceVectorWithList" />
136+
<rule ref="category/java/codestyle.xml/PrematureDeclaration"/>
137+
<rule ref="category/java/performance.xml/AddEmptyString"/>
138+
<rule ref="category/java/performance.xml/AvoidArrayLoops"/>
139+
<rule ref="category/java/performance.xml/RedundantFieldInitializer"/>
140+
<rule ref="category/java/performance.xml/UseArrayListInsteadOfVector"/>
141+
<rule ref="category/java/performance.xml/UseArraysAsList"/>
142+
<rule ref="category/java/performance.xml/UseStringBufferForStringAppends"/>
143+
144+
<rule ref="category/java/errorprone.xml/AvoidCatchingNPE" />
145+
<rule ref="category/java/errorprone.xml/AvoidCatchingThrowable" />
146+
<rule ref="category/java/errorprone.xml/AvoidLosingExceptionInformation" />
147+
<rule ref="category/java/errorprone.xml/DoNotThrowExceptionInFinally" />
148+
<rule ref="category/java/design.xml/AvoidCatchingGenericException" />
149+
<rule ref="category/java/design.xml/AvoidRethrowingException" />
150+
<rule ref="category/java/design.xml/AvoidThrowingNewInstanceOfSameException" />
151+
<rule ref="category/java/design.xml/AvoidThrowingNullPointerException" />
152+
<rule ref="category/java/design.xml/AvoidThrowingRawExceptionTypes" />
153+
<rule ref="category/java/design.xml/DoNotExtendJavaLangError" />
154+
<rule ref="category/java/design.xml/ExceptionAsFlowControl" />
155+
<rule ref="category/java/design.xml/SignatureDeclareThrowsException" />
156+
<rule ref="category/java/bestpractices.xml/ArrayIsStoredDirectly" />
157+
<rule ref="category/java/bestpractices.xml/MethodReturnsInternalArray" />
158+
<rule ref="category/java/bestpractices.xml/LooseCoupling" />
159+
<rule ref="category/java/bestpractices.xml/UnusedFormalParameter" />
160+
<rule ref="category/java/bestpractices.xml/UnusedLocalVariable" />
161+
<rule ref="category/java/bestpractices.xml/UnusedPrivateField" />
162+
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod" />
163+
<rule ref="category/java/errorprone.xml/MissingSerialVersionUID" />
164+
42165
</ruleset>

pom.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,12 @@ Portions Copyright (c) 2018, 2020, Chris Fraire <[email protected]>.
464464
<plugin>
465465
<groupId>org.apache.maven.plugins</groupId>
466466
<artifactId>maven-pmd-plugin</artifactId>
467-
<version>3.14.0</version>
467+
<version>3.21.2</version>
468468
<reportSets>
469469
<reportSet>
470470
<reports>
471-
<report>pmd</report>
472-
<report>cpd</report>
471+
<report>aggregate-pmd</report>
472+
<report>aggregate-cpd</report>
473473
</reports>
474474
</reportSet>
475475
</reportSets>
@@ -478,7 +478,6 @@ Portions Copyright (c) 2018, 2020, Chris Fraire <[email protected]>.
478478
<ruleset>dev/pmd_ruleset.xml</ruleset>
479479
</rulesets>
480480
<targetJdk>${java.version}</targetJdk>
481-
<aggregate>true</aggregate>
482481
</configuration>
483482
</plugin>
484483
<plugin>

0 commit comments

Comments
 (0)