Skip to content

[java] Property ignoredAnnotations does not work for SingularField and ImmutableField #1056

@mkordas

Description

@mkordas

Affects PMD Version:
6.2.0

Rule:
ImmutableField and SingularField

Description:
Newly announced parameter ignoredAnnotations is present in these rules, but it doesn't ignore any violations.
Method net.sourceforge.pmd.lang.java.rule.AbstractIgnoredAnnotationRule#hasIgnoredAnnotation is used only in UnusedPrivateField and UnusedPrivateMethod rules and feature works well for them.

Code Sample demonstrating the issue:

    <rule ref="category/java/design.xml/SingularField">
        <properties>
            <property name="ignoredAnnotations" value="java.lang.Deprecated"/>
        </properties>
    </rule>
            public class Source {
                @Deprecated
                private Object o; //violation!

                Object m() {
                    o = new Object();
                    return o;
                }
            }

Running PMD through: Gradle

Metadata

Metadata

Assignees

Labels

a:bugPMD crashes or fails to analyse a file.

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