Skip to content

Commit 8accd0d

Browse files
committed
Add PMD rule ClassWithOnlyPrivateConstructorsShouldBeFinal
1 parent a116fc2 commit 8accd0d

5 files changed

Lines changed: 96 additions & 4 deletions

File tree

pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,15 @@ file comparators, endian transformation classes, and much more.
458458
<groupId>com.github.siom79.japicmp</groupId>
459459
<artifactId>japicmp-maven-plugin</artifactId>
460460
</plugin>
461+
<plugin>
462+
<groupId>org.apache.maven.plugins</groupId>
463+
<artifactId>maven-pmd-plugin</artifactId>
464+
<configuration>
465+
<rulesets>
466+
<ruleset>src/conf/maven-pmd-plugin.xml</ruleset>
467+
</rulesets>
468+
</configuration>
469+
</plugin>
461470
</plugins>
462471
</build>
463472

src/conf/maven-pmd-plugin.xml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+
<ruleset name="Default Maven PMD Plugin Ruleset"
21+
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
22+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
24+
25+
<description>
26+
The default ruleset used by the Maven PMD Plugin, when no other ruleset is specified.
27+
It contains the rules of the old (pre PMD 6.0.0) rulesets java-basic, java-empty, java-imports,
28+
java-unnecessary, java-unusedcode.
29+
30+
This ruleset might be used as a starting point for an own customized ruleset [0].
31+
32+
[0] https://pmd.github.io/latest/pmd_userdocs_making_rulesets.html
33+
</description>
34+
35+
<rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP" />
36+
<rule ref="category/java/bestpractices.xml/CheckResultSet" />
37+
<rule ref="category/java/bestpractices.xml/PrimitiveWrapperInstantiation" />
38+
<rule ref="category/java/bestpractices.xml/UnusedFormalParameter" />
39+
<rule ref="category/java/bestpractices.xml/UnusedLocalVariable" />
40+
<rule ref="category/java/bestpractices.xml/UnusedPrivateField" />
41+
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod" />
42+
43+
<rule ref="category/java/codestyle.xml/EmptyControlStatement" />
44+
<rule ref="category/java/codestyle.xml/ExtendsObject" />
45+
<rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop" />
46+
<rule ref="category/java/codestyle.xml/TooManyStaticImports" />
47+
<rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName" />
48+
<rule ref="category/java/codestyle.xml/UnnecessaryImport" />
49+
<rule ref="category/java/codestyle.xml/UnnecessaryModifier" />
50+
<rule ref="category/java/codestyle.xml/UnnecessaryReturn" />
51+
<rule ref="category/java/codestyle.xml/UnnecessarySemicolon" />
52+
<rule ref="category/java/codestyle.xml/UselessParentheses" />
53+
<rule ref="category/java/codestyle.xml/UselessQualifiedThis" />
54+
55+
<rule ref="category/java/design.xml/CollapsibleIfStatements" />
56+
<rule ref="category/java/design.xml/SimplifiedTernary" />
57+
<rule ref="category/java/design.xml/UselessOverridingMethod" />
58+
<rule ref="category/java/design.xml/ClassWithOnlyPrivateConstructorsShouldBeFinal" />
59+
60+
<rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop" />
61+
<rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor" />
62+
<rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators" />
63+
<rule ref="category/java/errorprone.xml/AvoidUsingOctalValues" />
64+
<rule ref="category/java/errorprone.xml/BrokenNullCheck" />
65+
<rule ref="category/java/errorprone.xml/CheckSkipResult" />
66+
<rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray" />
67+
<rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices" />
68+
<rule ref="category/java/errorprone.xml/EmptyCatchBlock" />
69+
<rule ref="category/java/errorprone.xml/JumbledIncrementer" />
70+
<rule ref="category/java/errorprone.xml/MisplacedNullCheck" />
71+
<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode" />
72+
<rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock" />
73+
<rule ref="category/java/errorprone.xml/UnconditionalIfStatement" />
74+
<rule ref="category/java/errorprone.xml/UnnecessaryConversionTemporary" />
75+
<rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals" />
76+
<rule ref="category/java/errorprone.xml/UselessOperationOnImmutable" />
77+
78+
<rule ref="category/java/multithreading.xml/AvoidThreadGroup" />
79+
<rule ref="category/java/multithreading.xml/DontCallThreadRun" />
80+
<rule ref="category/java/multithreading.xml/DoubleCheckedLocking" />
81+
82+
<rule ref="category/java/performance.xml/BigIntegerInstantiation" />
83+
84+
</ruleset>

src/main/java/org/apache/commons/io/file/spi/FileSystemProviders.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*
3232
* @since 2.9.0
3333
*/
34-
public class FileSystemProviders {
34+
public class FileSystemProviders { // NOPMD Class will be final in 3.0.
3535

3636
private static final FileSystemProviders INSTALLED = new FileSystemProviders(FileSystemProvider.installedProviders());
3737

src/main/java/org/apache/commons/io/output/NullAppendable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*
2828
* @since 2.8.0
2929
*/
30-
public class NullAppendable implements Appendable {
30+
public class NullAppendable implements Appendable { // NOPMD Class will be final in 3.0.
3131

3232
/**
3333
* A singleton.

src/test/java/org/apache/commons/io/file/AccumulatorPathVisitorTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ static Stream<Arguments> testParametersIgnoreFailures() {
7474
Arguments.of((Supplier<AccumulatorPathVisitor>) () -> new AccumulatorPathVisitor(
7575
Counters.bigIntegerPathCounters(),
7676
CountingPathVisitor.defaultDirFilter(),
77-
CountingPathVisitor.defaultFileFilter(),
78-
IOBiFunction.noop())));
77+
CountingPathVisitor.defaultFileFilter())));
7978
// @formatter:on
8079
}
8180

0 commit comments

Comments
 (0)