[java] UnusedPrivateField doesn't find annotated unused private fields anymore #4166
Labels
a:false-negative
PMD doesn't flag a problematic piece of code
an:enhancement
An improvement on existing features / rules
Milestone
Rule: UnusedPrivateField
With PMD 6.50 the rule UnusedPrivateField was changed to completely ignore any private field with an annotation (see #4100).
But what if the previous behaviour was totally ok? How to restore it? In my case I do want to find unused private fields even with annotation.
If you need a use case for that: Java Selenium Tests
There you annotate WebElements with the locator that points to the corresponding Element on the web page.
It looks like this:
A class like this could have a bunch of WebElements and if some of them are unused, you don't see it.
If I don't use myElement, I want to remove it and I want PMD to find it.
Maybe at least a kind of whitelist could be added to configure PMD to find fields even if they have annotations that are on this list.
The text was updated successfully, but these errors were encountered: