Skip to content

Commit c25ba73

Browse files
committed
Configure PMD rules explicitly
PMD rules are configured explicitly for these categories: Best Practices, Code Style & Design
1 parent 032addc commit c25ba73

File tree

2 files changed

+171
-13
lines changed

2 files changed

+171
-13
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
root = true
22

3-
[*.{groovy,java,js,html,css}]
3+
[*.{groovy,java,js,html,css,xml}]
44
charset = utf-8
55
end_of_line = lf
66
indent_size = 4

config/pmd/ruleset.xml

Lines changed: 170 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,177 @@
11
<?xml version="1.0"?>
22

33
<ruleset name="Custom Rules"
4-
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
5-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6-
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
4+
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
77

8-
<description>
9-
Exercises for Programmers - custom rules
10-
</description>
8+
<description>
9+
Exercises for Programmers - custom rules
10+
</description>
1111

12-
<rule ref="category/java/errorprone.xml"/>
13-
<rule ref="category/java/bestpractices.xml">
14-
<exclude name="JUnitTestsShouldIncludeAssert"/>
15-
<exclude name="JUnitTestContainsTooManyAsserts"/>
16-
</rule>
17-
<rule ref="category/java/performance.xml"/>
12+
<!-- Best Practices -->
13+
<rule ref="category/java/bestpractices.xml/AbstractClassWithoutAbstractMethod"/>
14+
<rule ref="category/java/bestpractices.xml/AccessorClassGeneration"/>
15+
<rule ref="category/java/bestpractices.xml/AccessorMethodGeneration"/>
16+
<rule ref="category/java/bestpractices.xml/ArrayIsStoredDirectly"/>
17+
<rule ref="category/java/bestpractices.xml/AvoidMessageDigestField"/>
18+
<rule ref="category/java/bestpractices.xml/AvoidPrintStackTrace"/>
19+
<rule ref="category/java/bestpractices.xml/AvoidReassigningCatchVariables"/>
20+
<rule ref="category/java/bestpractices.xml/AvoidReassigningLoopVariables"/>
21+
<rule ref="category/java/bestpractices.xml/AvoidReassigningParameters"/>
22+
<rule ref="category/java/bestpractices.xml/AvoidStringBufferField"/>
23+
<rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP"/>
24+
<rule ref="category/java/bestpractices.xml/CheckResultSet"/>
25+
<rule ref="category/java/bestpractices.xml/ConstantsInInterface"/>
26+
<rule ref="category/java/bestpractices.xml/DefaultLabelNotLastInSwitchStmt"/>
27+
<rule ref="category/java/bestpractices.xml/DoubleBraceInitialization"/>
28+
<rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach"/>
29+
<rule ref="category/java/bestpractices.xml/ForLoopVariableCount"/>
30+
<rule ref="category/java/bestpractices.xml/GuardLogStatement"/>
31+
<rule ref="category/java/bestpractices.xml/JUnit5TestShouldBePackagePrivate"/>
32+
<rule ref="category/java/bestpractices.xml/JUnitAssertionsShouldIncludeMessage"/>
33+
<rule ref="category/java/bestpractices.xml/JUnitTestContainsTooManyAsserts">
34+
<properties>
35+
<property name="maximumAsserts" value="7"/>
36+
</properties>
37+
</rule>
38+
<rule ref="category/java/bestpractices.xml/LiteralsFirstInComparisons"/>
39+
<rule ref="category/java/bestpractices.xml/LooseCoupling"/>
40+
<rule ref="category/java/bestpractices.xml/MethodReturnsInternalArray"/>
41+
<rule ref="category/java/bestpractices.xml/MissingOverride"/>
42+
<rule ref="category/java/bestpractices.xml/OneDeclarationPerLine"/>
43+
<rule ref="category/java/bestpractices.xml/PreserveStackTrace"/>
44+
<rule ref="category/java/bestpractices.xml/PrimitiveWrapperInstantiation"/>
45+
<rule ref="category/java/bestpractices.xml/ReplaceEnumerationWithIterator"/>
46+
<rule ref="category/java/bestpractices.xml/ReplaceHashtableWithMap"/>
47+
<rule ref="category/java/bestpractices.xml/ReplaceVectorWithList"/>
48+
<rule ref="category/java/bestpractices.xml/SimplifiableTestAssertion"/>
49+
<rule ref="category/java/bestpractices.xml/SwitchStmtsShouldHaveDefault"/>
50+
<rule ref="category/java/bestpractices.xml/SystemPrintln"/>
51+
<rule ref="category/java/bestpractices.xml/UnnecessaryVarargsArrayCreation"/>
52+
<rule ref="category/java/bestpractices.xml/UnusedAssignment"/>
53+
<rule ref="category/java/bestpractices.xml/UnusedFormalParameter"/>
54+
<rule ref="category/java/bestpractices.xml/UnusedLocalVariable"/>
55+
<rule ref="category/java/bestpractices.xml/UnusedPrivateField"/>
56+
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod"/>
57+
<rule ref="category/java/bestpractices.xml/UseCollectionIsEmpty"/>
58+
<rule ref="category/java/bestpractices.xml/UseEnumCollections"/>
59+
<rule ref="category/java/bestpractices.xml/UseStandardCharsets"/>
60+
<rule ref="category/java/bestpractices.xml/UseTryWithResources"/>
61+
<rule ref="category/java/bestpractices.xml/UseVarargs"/>
62+
<rule ref="category/java/bestpractices.xml/WhileLoopWithLiteralBoolean"/>
63+
<!-- Best Practices -->
1864

65+
<!-- Code Style -->
66+
<rule ref="category/java/codestyle.xml/AvoidDollarSigns"/>
67+
<rule ref="category/java/codestyle.xml/AvoidProtectedFieldInFinalClass"/>
68+
<rule ref="category/java/codestyle.xml/AvoidProtectedMethodInFinalClassNotExtending"/>
69+
<rule ref="category/java/codestyle.xml/AvoidUsingNativeCode"/>
70+
<rule ref="category/java/codestyle.xml/BooleanGetMethodName"/>
71+
<rule ref="category/java/codestyle.xml/ClassNamingConventions"/>
72+
<rule ref="category/java/codestyle.xml/ConfusingTernary"/>
73+
<rule ref="category/java/codestyle.xml/ControlStatementBraces"/>
74+
<rule ref="category/java/codestyle.xml/EmptyControlStatement"/>
75+
<rule ref="category/java/codestyle.xml/EmptyMethodInAbstractClassShouldBeAbstract"/>
76+
<rule ref="category/java/codestyle.xml/ExtendsObject"/>
77+
<rule ref="category/java/codestyle.xml/FieldDeclarationsShouldBeAtStartOfClass"/>
78+
<rule ref="category/java/codestyle.xml/FieldNamingConventions"/>
79+
<rule ref="category/java/codestyle.xml/FinalParameterInAbstractMethod"/>
80+
<rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop"/>
81+
<rule ref="category/java/codestyle.xml/FormalParameterNamingConventions"/>
82+
<rule ref="category/java/codestyle.xml/GenericsNaming"/>
83+
<rule ref="category/java/codestyle.xml/IdenticalCatchBranches"/>
84+
<rule ref="category/java/codestyle.xml/LambdaCanBeMethodReference"/>
85+
<rule ref="category/java/codestyle.xml/LinguisticNaming"/>
86+
<rule ref="category/java/codestyle.xml/LocalHomeNamingConvention"/>
87+
<rule ref="category/java/codestyle.xml/LocalInterfaceSessionNamingConvention"/>
88+
<rule ref="category/java/codestyle.xml/LocalVariableNamingConventions"/>
89+
<rule ref="category/java/codestyle.xml/LongVariable"/>
90+
<rule ref="category/java/codestyle.xml/MethodNamingConventions">
91+
<properties>
92+
<property name="junit5TestPattern" value="^[a-z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$"/>
93+
</properties>
94+
</rule>
95+
<rule ref="category/java/codestyle.xml/NoPackage"/>
96+
<rule ref="category/java/codestyle.xml/PackageCase"/>
97+
<rule ref="category/java/codestyle.xml/PrematureDeclaration"/>
98+
<rule ref="category/java/codestyle.xml/ShortMethodName">
99+
<properties>
100+
<property name="minimum" value="2"/>
101+
</properties>
102+
</rule>
103+
<rule ref="category/java/codestyle.xml/ShortVariable"/>
104+
<rule ref="category/java/codestyle.xml/TooManyStaticImports"/>
105+
<rule ref="category/java/codestyle.xml/UnnecessaryAnnotationValueElement"/>
106+
<rule ref="category/java/codestyle.xml/UnnecessaryBoxing"/>
107+
<rule ref="category/java/codestyle.xml/UnnecessaryCast"/>
108+
<rule ref="category/java/codestyle.xml/UnnecessaryConstructor"/>
109+
<rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName"/>
110+
<rule ref="category/java/codestyle.xml/UnnecessaryImport"/>
111+
<rule ref="category/java/codestyle.xml/UnnecessaryLocalBeforeReturn"/>
112+
<rule ref="category/java/codestyle.xml/UnnecessaryModifier"/>
113+
<rule ref="category/java/codestyle.xml/UnnecessaryReturn"/>
114+
<rule ref="category/java/codestyle.xml/UnnecessarySemicolon"/>
115+
<rule ref="category/java/codestyle.xml/UseDiamondOperator"/>
116+
<rule ref="category/java/codestyle.xml/UseExplicitTypes"/>
117+
<rule ref="category/java/codestyle.xml/UselessParentheses"/>
118+
<rule ref="category/java/codestyle.xml/UselessQualifiedThis"/>
119+
<rule ref="category/java/codestyle.xml/UseShortArrayInitializer"/>
120+
<rule ref="category/java/codestyle.xml/UseUnderscoresInNumericLiterals"/>
121+
<!-- Code Style -->
122+
123+
<!-- Design -->
124+
<rule ref="category/java/design.xml/AbstractClassWithoutAnyMethod"/>
125+
<rule ref="category/java/design.xml/AvoidCatchingGenericException"/>
126+
<rule ref="category/java/design.xml/AvoidDeeplyNestedIfStmts"/>
127+
<rule ref="category/java/design.xml/AvoidRethrowingException"/>
128+
<rule ref="category/java/design.xml/AvoidThrowingNewInstanceOfSameException"/>
129+
<rule ref="category/java/design.xml/AvoidThrowingNullPointerException"/>
130+
<rule ref="category/java/design.xml/AvoidThrowingRawExceptionTypes"/>
131+
<rule ref="category/java/design.xml/AvoidUncheckedExceptionsInSignatures"/>
132+
<rule ref="category/java/design.xml/ClassWithOnlyPrivateConstructorsShouldBeFinal"/>
133+
<rule ref="category/java/design.xml/CognitiveComplexity"/>
134+
<rule ref="category/java/design.xml/CollapsibleIfStatements"/>
135+
<rule ref="category/java/design.xml/CouplingBetweenObjects"/>
136+
<rule ref="category/java/design.xml/CyclomaticComplexity"/>
137+
<rule ref="category/java/design.xml/DataClass"/>
138+
<rule ref="category/java/design.xml/DoNotExtendJavaLangError"/>
139+
<rule ref="category/java/design.xml/ExceptionAsFlowControl"/>
140+
<rule ref="category/java/design.xml/ExcessiveImports"/>
141+
<rule ref="category/java/design.xml/ExcessiveParameterList"/>
142+
<rule ref="category/java/design.xml/ExcessivePublicCount"/>
143+
<rule ref="category/java/design.xml/FinalFieldCouldBeStatic"/>
144+
<rule ref="category/java/design.xml/GodClass"/>
145+
<rule ref="category/java/design.xml/ImmutableField"/>
146+
<rule ref="category/java/design.xml/InvalidJavaBean"/>
147+
<rule ref="category/java/design.xml/LawOfDemeter"/>
148+
<rule ref="category/java/design.xml/LogicInversion"/>
149+
<rule ref="category/java/design.xml/MutableStaticState"/>
150+
<rule ref="category/java/design.xml/NcssCount"/>
151+
<rule ref="category/java/design.xml/NPathComplexity"/>
152+
<rule ref="category/java/design.xml/SignatureDeclareThrowsException">
153+
<properties>
154+
<property name="IgnoreJUnitCompletely" value="false"/>
155+
</properties>
156+
</rule>
157+
<rule ref="category/java/design.xml/SimplifiedTernary"/>
158+
<rule ref="category/java/design.xml/SimplifyBooleanExpressions"/>
159+
<rule ref="category/java/design.xml/SimplifyBooleanReturns"/>
160+
<rule ref="category/java/design.xml/SimplifyConditional"/>
161+
<rule ref="category/java/design.xml/SingularField"/>
162+
<rule ref="category/java/design.xml/SwitchDensity"/>
163+
<rule ref="category/java/design.xml/TooManyFields"/>
164+
<rule ref="category/java/design.xml/TooManyMethods">
165+
<properties>
166+
<property name="maxmethods" value="15"/>
167+
</properties>
168+
</rule>
169+
<rule ref="category/java/design.xml/UselessOverridingMethod"/>
170+
<rule ref="category/java/design.xml/UseObjectForClearerAPI"/>
171+
<!-- Design -->
172+
173+
<rule ref="category/java/errorprone.xml"/>
174+
<rule ref="category/java/multithreading.xml"/>
175+
<rule ref="category/java/performance.xml"/>
176+
<rule ref="category/java/security.xml"/>
19177
</ruleset>

0 commit comments

Comments
 (0)