Skip to content

[java] UnusedPrivateMethod violation for disabled class in 6.23.0 #2454

@mrclmh

Description

@mrclmh

Affects PMD Version: 6.23.0

Rule:
UnusedPrivateMethod

https://pmd.github.io/pmd-6.23.0/pmd_rules_java_bestpractices.html#unusedprivatemethod

Description:
In 6.22.0 the rule uses the classes listed in the ignoredAnnotationsproperty as expected. In 6.23.0 I'm getting a violation for the class javax.annotation.PreDestroyon a private method.

Code Sample demonstrating the issue:

import javax.annotation.PreDestroy;

@PreDestroy
private void shutdown() {
    server.shutdown();
}

Ruleset:

<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod">
    <properties>
        <property name="ignoredAnnotations" value="java.lang.Deprecated|javax.annotation.PostConstruct|
            javax.annotation.PreDestroy|org.springframework.context.event.EventListener|
            org.springframework.scheduling.annotation.Scheduled"/>
    </properties>
</rule>

Expected outcome:
The private method annotated with @PreDestroy should not be a violation.

  • Does PMD report a violation, where there shouldn't be one? -> false-positive

Running PMD through: Gradle

Metadata

Metadata

Assignees

Labels

a:bugPMD crashes or fails to analyse a file.a:false-positivePMD flags a piece of code that is not problematic

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions