[java] Verify UnusedPrivateMethod #4625

Fixes #4625
This commit is contained in:
Andreas Dangel
2024-02-29 08:40:22 +01:00
parent 2b70986f09
commit ce8ca0652d
2 changed files with 21 additions and 0 deletions

View File

@ -275,6 +275,8 @@ The rules have been moved into categories with PMD 6.
* [#3751](https://github.com/pmd/pmd/issues/3751): \[java] Rename some node types
* [#4628](https://github.com/pmd/pmd/pull/4628): \[java] Support loading classes from java runtime images
* [#4753](https://github.com/pmd/pmd/issues/4753): \[java] PMD crashes while using generics and wildcards
* java-bestpractives
* [#4625](https://github.com/pmd/pmd/issues/4625): \[java] UnusedPrivateMethod false positive: Autoboxing into Number
* java-codestyle
* [#2847](https://github.com/pmd/pmd/issues/2847): \[java] New Rule: Use Explicit Types
* [#4578](https://github.com/pmd/pmd/issues/4578): \[java] CommentDefaultAccessModifier comment needs to be before annotation if present
@ -1403,6 +1405,7 @@ Language specific fixes:
* [#4516](https://github.com/pmd/pmd/issues/4516): \[java] UnusedLocalVariable: false-negative with try-with-resources
* [#4517](https://github.com/pmd/pmd/issues/4517): \[java] UnusedLocalVariable: false-negative with compound assignments
* [#4518](https://github.com/pmd/pmd/issues/4518): \[java] UnusedLocalVariable: false-positive with multiple for-loop indices
* [#4625](https://github.com/pmd/pmd/issues/4625): \[java] UnusedPrivateMethod false positive: Autoboxing into Number
* [#4634](https://github.com/pmd/pmd/issues/4634): \[java] JUnit4TestShouldUseTestAnnotation false positive with TestNG
* java-codestyle
* [#1208](https://github.com/pmd/pmd/issues/1208): \[java] PrematureDeclaration rule false-positive on variable declared to measure time

View File

@ -1788,4 +1788,22 @@ public class UnusedAssignmentRule {
}
]]></code>
</test-code>
<test-code>
<description>[java] UnusedPrivateMethod false positive: Autoboxing into Number #4625</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Example {
public Example() {
foo(2);
}
//src/Example.java:8: UnusedPrivateMethod: Avoid unused private methods such as 'foo(Number)'.
private void foo(Number bar) {
System.out.println(bar);
}
}
]]></code>
</test-code>
</test-data>