Skip to content

Commit 293e57d

Browse files
committed
Fix pmd: Ignore TooManyStaticImports.
This requires adding the default ruleset and then modifying with suppressions.
1 parent bad1a22 commit 293e57d

2 files changed

Lines changed: 110 additions & 1 deletion

File tree

pom.xml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ CSV files of various types.
155155
<checkstyle.header.file>${basedir}/LICENSE-header.txt</checkstyle.header.file>
156156
<checkstyle.resourceExcludes>LICENSE.txt, NOTICE.txt, **/maven-archiver/pom.properties</checkstyle.resourceExcludes>
157157

158+
<pmd.version>3.12.0</pmd.version>
158159
<japicmp.skip>false</japicmp.skip>
159160

160161
<commons.release.isDistModule>true</commons.release.isDistModule>
@@ -213,6 +214,20 @@ CSV files of various types.
213214
<excludeFilterFile>${basedir}/src/main/resources/findbugs/findbugs-exclude-filter.xml</excludeFilterFile>
214215
</configuration>
215216
</plugin>
217+
<!-- Allow pmd to be run interactively; keep in sync with report config below -->
218+
<plugin>
219+
<groupId>org.apache.maven.plugins</groupId>
220+
<artifactId>maven-pmd-plugin</artifactId>
221+
<version>${pmd.version}</version>
222+
<configuration>
223+
<targetJdk>${maven.compiler.target}</targetJdk>
224+
<skipEmptyReport>false</skipEmptyReport>
225+
<analysisCache>true</analysisCache>
226+
<rulesets>
227+
<ruleset>${basedir}/src/main/resources/pmd/pmd-ruleset.xml</ruleset>
228+
</rulesets>
229+
</configuration>
230+
</plugin>
216231

217232
<!-- We need to add our test data files to rat exclusions -->
218233
<!-- Needed for command-line access, e.g mvn apache-rat:rat and mvn apache-rat:check -->
@@ -268,9 +283,14 @@ CSV files of various types.
268283
<plugin>
269284
<groupId>org.apache.maven.plugins</groupId>
270285
<artifactId>maven-pmd-plugin</artifactId>
271-
<version>3.12.0</version>
286+
<version>${pmd.version}</version>
272287
<configuration>
273288
<targetJdk>${maven.compiler.target}</targetJdk>
289+
<skipEmptyReport>false</skipEmptyReport>
290+
<analysisCache>true</analysisCache>
291+
<rulesets>
292+
<ruleset>${basedir}/src/main/resources/pmd/pmd-ruleset.xml</ruleset>
293+
</rulesets>
274294
</configuration>
275295
</plugin>
276296
<plugin>
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
<ruleset name="commons-rng-customized"
19+
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
20+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
22+
<description>
23+
This ruleset checks the code for discouraged programming constructs.
24+
</description>
25+
26+
<!-- Default ruleset for maven-pmd-plugin -->
27+
<rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP"/>
28+
<rule ref="category/java/bestpractices.xml/CheckResultSet"/>
29+
<rule ref="category/java/bestpractices.xml/UnusedImports"/>
30+
<rule ref="category/java/bestpractices.xml/UnusedFormalParameter"/>
31+
<rule ref="category/java/bestpractices.xml/UnusedLocalVariable"/>
32+
<rule ref="category/java/bestpractices.xml/UnusedPrivateField"/>
33+
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod"/>
34+
<rule ref="category/java/codestyle.xml/DontImportJavaLang"/>
35+
<rule ref="category/java/codestyle.xml/DuplicateImports"/>
36+
<rule ref="category/java/codestyle.xml/ExtendsObject"/>
37+
<rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop"/>
38+
<rule ref="category/java/codestyle.xml/TooManyStaticImports"/>
39+
<rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName"/>
40+
<rule ref="category/java/codestyle.xml/UnnecessaryModifier"/>
41+
<rule ref="category/java/codestyle.xml/UnnecessaryReturn"/>
42+
<rule ref="category/java/codestyle.xml/UselessParentheses"/>
43+
<rule ref="category/java/codestyle.xml/UselessQualifiedThis"/>
44+
<rule ref="category/java/design.xml/CollapsibleIfStatements"/>
45+
<rule ref="category/java/design.xml/SimplifiedTernary"/>
46+
<rule ref="category/java/design.xml/UselessOverridingMethod"/>
47+
<rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop"/>
48+
<rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor"/>
49+
<rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators"/>
50+
<rule ref="category/java/errorprone.xml/AvoidUsingOctalValues"/>
51+
<rule ref="category/java/errorprone.xml/BrokenNullCheck"/>
52+
<rule ref="category/java/errorprone.xml/CheckSkipResult"/>
53+
<rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray"/>
54+
<rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices"/>
55+
<rule ref="category/java/errorprone.xml/EmptyCatchBlock"/>
56+
<rule ref="category/java/errorprone.xml/EmptyFinallyBlock"/>
57+
<rule ref="category/java/errorprone.xml/EmptyIfStmt"/>
58+
<rule ref="category/java/errorprone.xml/EmptyInitializer"/>
59+
<rule ref="category/java/errorprone.xml/EmptyStatementBlock"/>
60+
<rule ref="category/java/errorprone.xml/EmptyStatementNotInLoop"/>
61+
<rule ref="category/java/errorprone.xml/EmptySwitchStatements"/>
62+
<rule ref="category/java/errorprone.xml/EmptySynchronizedBlock"/>
63+
<rule ref="category/java/errorprone.xml/EmptyTryBlock"/>
64+
<rule ref="category/java/errorprone.xml/EmptyWhileStmt"/>
65+
<rule ref="category/java/errorprone.xml/ImportFromSamePackage"/>
66+
<rule ref="category/java/errorprone.xml/JumbledIncrementer"/>
67+
<rule ref="category/java/errorprone.xml/MisplacedNullCheck"/>
68+
<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode"/>
69+
<rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock"/>
70+
<rule ref="category/java/errorprone.xml/UnconditionalIfStatement"/>
71+
<rule ref="category/java/errorprone.xml/UnnecessaryConversionTemporary"/>
72+
<rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals"/>
73+
<rule ref="category/java/errorprone.xml/UselessOperationOnImmutable"/>
74+
<rule ref="category/java/multithreading.xml/AvoidThreadGroup"/>
75+
<rule ref="category/java/multithreading.xml/DontCallThreadRun"/>
76+
<rule ref="category/java/multithreading.xml/DoubleCheckedLocking"/>
77+
<rule ref="category/java/performance.xml/BigIntegerInstantiation"/>
78+
<rule ref="category/java/performance.xml/BooleanInstantiation"/>
79+
80+
<!-- Rule customisations. -->
81+
82+
<rule ref="category/java/codestyle.xml/TooManyStaticImports">
83+
<properties>
84+
<property name="violationSuppressXPath"
85+
value="//ClassOrInterfaceDeclaration[@Image='CSVFormat' or @Image='Lexer']"/>
86+
</properties>
87+
</rule>
88+
89+
</ruleset>

0 commit comments

Comments
 (0)