we have a project which is checked by PMD for violations of e.g. unused private methods. Our problem is that we don't know if it is possible to ignore private Methods which are annotated with @PostConstruct
.
The rule is defined as following:
<rule ref="rulesets/java/unusedcode.xml/UnusedPrivateMethod"/>
My goal is to define it once to ignore annotated methods. I would like to prevent writing @SupressWarnings
on every method.
With the hint and advice from HairyFotr i was able to configure my ruleset to ignore private
methods with @PostConstruct
.
The rule I had to use is:
<rule ref="rulesets/java/unusedcode.xml/UnusedPrivateMethod">
<properties>
<property name="violationSuppressXPath"
value="//ClassOrInterfaceBodyDeclaration/Annotation/MarkerAnnotation/Name[@Image='PostConstruct']" />
</properties>
</rule>