Skip to content

Commit c0cb4f8

Browse files
committed
style(pmd): rule exclusions
1 parent dd794ad commit c0cb4f8

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

buildSrc/src/main/groovy/java-conventions.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ pmd {
5050
toolVersion = net.sourceforge.pmd.PMDVersion.VERSION
5151
}
5252

53+
pmdTest {
54+
ruleSets = ["test-ruleset.xml"]
55+
}
56+
5357
tasks.withType(Pmd).configureEach {
5458
pmdClasspath += files("$rootDir/gradle/config/pmd")
5559
}

gradle/config/pmd/ruleset.xml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
<exclude name="ShortVariable"/>
2727
<exclude name="UseExplicitTypes"/>
2828
</rule>
29+
<rule ref="category/java/codestyle.xml/LinguisticNaming">
30+
<properties>
31+
<property name="checkSetters" value="false"/>
32+
</properties>
33+
</rule>
2934
<rule ref="category/java/codestyle.xml/UseUnderscoresInNumericLiterals">
3035
<properties>
3136
<property name="acceptableDecimalLength" value="5"/>
@@ -38,6 +43,8 @@
3843
<exclude name="DataClass"/>
3944
<exclude name="LawOfDemeter"/>
4045
<exclude name="LoosePackageCoupling"/>
46+
<exclude name="TooManyMethods"/>
47+
<exclude name="UseObjectForClearerAPI"/>
4148
<exclude name="UseUtilityClass"/>
4249
</rule>
4350
<rule ref="category/java/design.xml/NcssCount">
@@ -49,12 +56,7 @@
4956

5057
<rule ref="category/java/errorprone.xml">
5158
<exclude name="UseProperClassLoader"/>
52-
</rule>
53-
<rule ref="category/java/errorprone.xml/AvoidLiteralsInIfCondition">
54-
<properties>
55-
<property name="ignoreMagicNumbers" value="-1,0,1"/>
56-
<property name="ignoreExpressions" value="true"/>
57-
</properties>
59+
<exclude name="AvoidLiteralsInIfCondition"/>
5860
</rule>
5961
<rule ref="category/java/errorprone.xml/TestClassWithoutTestCases">
6062
<properties>

gradle/config/pmd/test-ruleset.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="PMD rule set for tests">
3+
<description>Test rule set</description>
4+
<rule ref="ruleset.xml">
5+
<exclude name="AvoidDuplicateLiterals"/>
6+
</rule>
7+
</ruleset>

0 commit comments

Comments
 (0)