Skip to content

Commit

Permalink
[MPMD-312] The rule BooleanInstantiation is deprecated
Browse files Browse the repository at this point in the history
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
  • Loading branch information
adangel committed Sep 2, 2021
1 parent bf682a7 commit 38701da
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down Expand Up @@ -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>
2 changes: 1 addition & 1 deletion src/main/resources/rulesets/maven.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down Expand Up @@ -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>
2 changes: 1 addition & 1 deletion src/site/apt/examples/usingRuleSets.apt.vm
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down Expand Up @@ -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" />
+-----+
6 changes: 6 additions & 0 deletions src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ public void testDefaultConfiguration()
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()
Expand Down

0 comments on commit 38701da

Please sign in to comment.