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/01 18:30:19 UTC

[maven-pmd-plugin] 01/01: [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 MPMD-312-deprecated-rules
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git

commit 5fc1fdfbef97984f5035ade6b59f395c223cd9ae
Author: Andreas Dangel <ad...@apache.org>
AuthorDate: Wed Sep 1 20:26:38 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.
---
 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 ++++++
 4 files changed, 9 insertions(+), 3 deletions(-)

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()