This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git
commit 8accd0d266c0be9a08e1aaa1ae8200ba913a2643 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Wed May 3 08:26:11 2023 -0400 Add PMD rule ClassWithOnlyPrivateConstructorsShouldBeFinal --- pom.xml | 9 +++ src/conf/maven-pmd-plugin.xml | 84 ++++++++++++++++++++++ .../commons/io/file/spi/FileSystemProviders.java | 2 +- .../apache/commons/io/output/NullAppendable.java | 2 +- .../io/file/AccumulatorPathVisitorTest.java | 3 +- 5 files changed, 96 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 3bc2a17a..296d508c 100644 --- a/pom.xml +++ b/pom.xml @@ -458,6 +458,15 @@ file comparators, endian transformation classes, and much more. <groupId>com.github.siom79.japicmp</groupId> <artifactId>japicmp-maven-plugin</artifactId> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-pmd-plugin</artifactId> + <configuration> + <rulesets> + <ruleset>src/conf/maven-pmd-plugin.xml</ruleset> + </rulesets> + </configuration> + </plugin> </plugins> </build> diff --git a/src/conf/maven-pmd-plugin.xml b/src/conf/maven-pmd-plugin.xml new file mode 100644 index 00000000..a89254da --- /dev/null +++ b/src/conf/maven-pmd-plugin.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<ruleset name="Default Maven PMD Plugin Ruleset" + xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd"> + + <description> + The default ruleset used by the Maven PMD Plugin, when no other ruleset is specified. + It contains the rules of the old (pre PMD 6.0.0) rulesets java-basic, java-empty, java-imports, + java-unnecessary, java-unusedcode. + + This ruleset might be used as a starting point for an own customized ruleset [0]. + + [0] https://pmd.github.io/latest/pmd_userdocs_making_rulesets.html + </description> + + <rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP" /> + <rule ref="category/java/bestpractices.xml/CheckResultSet" /> + <rule ref="category/java/bestpractices.xml/PrimitiveWrapperInstantiation" /> + <rule ref="category/java/bestpractices.xml/UnusedFormalParameter" /> + <rule ref="category/java/bestpractices.xml/UnusedLocalVariable" /> + <rule ref="category/java/bestpractices.xml/UnusedPrivateField" /> + <rule ref="category/java/bestpractices.xml/UnusedPrivateMethod" /> + + <rule ref="category/java/codestyle.xml/EmptyControlStatement" /> + <rule ref="category/java/codestyle.xml/ExtendsObject" /> + <rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop" /> + <rule ref="category/java/codestyle.xml/TooManyStaticImports" /> + <rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName" /> + <rule ref="category/java/codestyle.xml/UnnecessaryImport" /> + <rule ref="category/java/codestyle.xml/UnnecessaryModifier" /> + <rule ref="category/java/codestyle.xml/UnnecessaryReturn" /> + <rule ref="category/java/codestyle.xml/UnnecessarySemicolon" /> + <rule ref="category/java/codestyle.xml/UselessParentheses" /> + <rule ref="category/java/codestyle.xml/UselessQualifiedThis" /> + + <rule ref="category/java/design.xml/CollapsibleIfStatements" /> + <rule ref="category/java/design.xml/SimplifiedTernary" /> + <rule ref="category/java/design.xml/UselessOverridingMethod" /> + <rule ref="category/java/design.xml/ClassWithOnlyPrivateConstructorsShouldBeFinal" /> + + <rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop" /> + <rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor" /> + <rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators" /> + <rule ref="category/java/errorprone.xml/AvoidUsingOctalValues" /> + <rule ref="category/java/errorprone.xml/BrokenNullCheck" /> + <rule ref="category/java/errorprone.xml/CheckSkipResult" /> + <rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray" /> + <rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices" /> + <rule ref="category/java/errorprone.xml/EmptyCatchBlock" /> + <rule ref="category/java/errorprone.xml/JumbledIncrementer" /> + <rule ref="category/java/errorprone.xml/MisplacedNullCheck" /> + <rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode" /> + <rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock" /> + <rule ref="category/java/errorprone.xml/UnconditionalIfStatement" /> + <rule ref="category/java/errorprone.xml/UnnecessaryConversionTemporary" /> + <rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals" /> + <rule ref="category/java/errorprone.xml/UselessOperationOnImmutable" /> + + <rule ref="category/java/multithreading.xml/AvoidThreadGroup" /> + <rule ref="category/java/multithreading.xml/DontCallThreadRun" /> + <rule ref="category/java/multithreading.xml/DoubleCheckedLocking" /> + + <rule ref="category/java/performance.xml/BigIntegerInstantiation" /> + +</ruleset> diff --git a/src/main/java/org/apache/commons/io/file/spi/FileSystemProviders.java b/src/main/java/org/apache/commons/io/file/spi/FileSystemProviders.java index 4058b795..a64b4e76 100644 --- a/src/main/java/org/apache/commons/io/file/spi/FileSystemProviders.java +++ b/src/main/java/org/apache/commons/io/file/spi/FileSystemProviders.java @@ -31,7 +31,7 @@ import java.util.Objects; * * @since 2.9.0 */ -public class FileSystemProviders { +public class FileSystemProviders { // NOPMD Class will be final in 3.0. private static final FileSystemProviders INSTALLED = new FileSystemProviders(FileSystemProvider.installedProviders()); diff --git a/src/main/java/org/apache/commons/io/output/NullAppendable.java b/src/main/java/org/apache/commons/io/output/NullAppendable.java index e2eaf33c..14ed4fab 100644 --- a/src/main/java/org/apache/commons/io/output/NullAppendable.java +++ b/src/main/java/org/apache/commons/io/output/NullAppendable.java @@ -27,7 +27,7 @@ import java.io.IOException; * * @since 2.8.0 */ -public class NullAppendable implements Appendable { +public class NullAppendable implements Appendable { // NOPMD Class will be final in 3.0. /** * A singleton. diff --git a/src/test/java/org/apache/commons/io/file/AccumulatorPathVisitorTest.java b/src/test/java/org/apache/commons/io/file/AccumulatorPathVisitorTest.java index a3a9ece6..3cdf0654 100644 --- a/src/test/java/org/apache/commons/io/file/AccumulatorPathVisitorTest.java +++ b/src/test/java/org/apache/commons/io/file/AccumulatorPathVisitorTest.java @@ -74,8 +74,7 @@ public class AccumulatorPathVisitorTest { Arguments.of((Supplier<AccumulatorPathVisitor>) () -> new AccumulatorPathVisitor( Counters.bigIntegerPathCounters(), CountingPathVisitor.defaultDirFilter(), - CountingPathVisitor.defaultFileFilter(), - IOBiFunction.noop()))); + CountingPathVisitor.defaultFileFilter()))); // @formatter:on }