You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ad...@apache.org on 2021/09/02 08:22:34 UTC
[maven-pmd-plugin] 01/04: [MPMD-312] The rule BooleanInstantiation
is deprecated
This is an automated email from the ASF dual-hosted git repository.
adangel pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git
commit 38701dab48b91e9a44611b7cf5b586a7778a6439
Author: Andreas Dangel <ad...@apache.org>
AuthorDate: Thu Sep 2 10:10:45 2021 +0200
[MPMD-312] The rule BooleanInstantiation is deprecated
Since PMD 6.37.0, BooleanInstantiation is deprecated.
The new rule PrimitiveWrapperInstantiation should be
used instead.
Also exclude asm:asm, as pmd brings in a newer version
as org.ow2.asm:asm
---
pom.xml | 7 +++++++
src/main/resources/rulesets/java/maven-pmd-plugin-default.xml | 2 +-
src/main/resources/rulesets/maven.xml | 2 +-
src/site/apt/examples/usingRuleSets.apt.vm | 2 +-
src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java | 6 ++++++
5 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index 7fcf25a..c5ccdee 100644
--- a/pom.xml
+++ b/pom.xml
@@ -138,6 +138,13 @@ under the License.
<artifactId>maven-embedder</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
+ <exclusions>
+ <!-- exclude old asm:asm, as pmd brings in a newer version (org.ow2.asm:asm) -->
+ <exclusion>
+ <groupId>asm</groupId>
+ <artifactId>asm</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<!-- pmd -->
diff --git a/src/main/resources/rulesets/java/maven-pmd-plugin-default.xml b/src/main/resources/rulesets/java/maven-pmd-plugin-default.xml
index 7604fdc..912089a 100644
--- a/src/main/resources/rulesets/java/maven-pmd-plugin-default.xml
+++ b/src/main/resources/rulesets/java/maven-pmd-plugin-default.xml
@@ -34,6 +34,7 @@ under the License.
<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" />
@@ -85,6 +86,5 @@ under the License.
<rule ref="category/java/multithreading.xml/DoubleCheckedLocking" />
<rule ref="category/java/performance.xml/BigIntegerInstantiation" />
- <rule ref="category/java/performance.xml/BooleanInstantiation" />
</ruleset>
diff --git a/src/main/resources/rulesets/maven.xml b/src/main/resources/rulesets/maven.xml
index 4386fdf..aab8afe 100644
--- a/src/main/resources/rulesets/maven.xml
+++ b/src/main/resources/rulesets/maven.xml
@@ -35,6 +35,7 @@ under the License.
<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" />
@@ -90,6 +91,5 @@ under the License.
<rule ref="category/java/multithreading.xml/DoubleCheckedLocking" />
<rule ref="category/java/performance.xml/BigIntegerInstantiation" />
- <rule ref="category/java/performance.xml/BooleanInstantiation" />
</ruleset>
diff --git a/src/site/apt/examples/usingRuleSets.apt.vm b/src/site/apt/examples/usingRuleSets.apt.vm
index 51cc118..cf5ac84 100644
--- a/src/site/apt/examples/usingRuleSets.apt.vm
+++ b/src/site/apt/examples/usingRuleSets.apt.vm
@@ -96,6 +96,7 @@ The default ruleset
+-----+
<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" />
@@ -147,5 +148,4 @@ The default ruleset
<rule ref="category/java/multithreading.xml/DoubleCheckedLocking" />
<rule ref="category/java/performance.xml/BigIntegerInstantiation" />
- <rule ref="category/java/performance.xml/BooleanInstantiation" />
+-----+
diff --git a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
index 7e175a9..5fa2952 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
@@ -105,6 +105,12 @@ public class PmdReportTest
assertTrue( str.contains( "Priority 4</h3>" ) );
// the file App.java is mentioned 3 times: in prio 3, in prio 4 and in the files section
assertEquals( 3, StringUtils.countMatches( str, "def/configuration/App.java" ) );
+
+ // there must be no warnings (like deprecated rules) in the log output
+ String output = CapturingPrintStream.getOutput();
+ assertFalse( output.contains( "deprecated Rule name" ) );
+ assertFalse( output.contains( "Discontinue using Rule name" ) );
+ assertFalse( output.contains( "is referenced multiple times" ) );
}
public void testDefaultConfigurationNotRenderRuleViolationPriority()