Affects PMD Version:
7.14.0
Description:
Adding UnnecessaryWarningSuppression to a custom ruleset causes UnusedPrivateField to be reported as unnecessary. Removing the suppression, PMD reports the field is unused.
Exception Stacktrace:
No stack trace
Code references/examples
The custom ruleset has:
<rule ref="category/java/bestpractices.xml/UnusedPrivateField"/>
Steps to reproduce:
Adding UnnecessaryWarningSuppression to a custom ruleset causes UnusedPrivateField to be reported as unnecessary. Removing the suppression, PMD reports the field is unused.
Running PMD through: Maven
Workaround
My guess is the issue arises because UnusedPrivateField, according to docs, ignores annotated private fields.
Indeed, changing the configuration as follows, resolves the issue, and UnnecessaryWarningSuppression no longer reports the suppression to be unnecessary:
<rule ref="category/java/bestpractices.xml/UnusedPrivateField"> <properties> <property name="reportForAnnotations" value="java.lang.SuppressWarnings" /> </properties> </rule>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4