When looking at PMD documentation it appears that for apex code there is no way to do a suppression for a single line of code. I have a lot of false positives that have been making builds fail so I need to find away around this besides for suppressing the rule for the whole class. Has anyone found a way around this for APEX?
Asked
Active
Viewed 2,126 times
1 Answers
3
PMD has 3 ways to suppress warnings in Apex:
- Using
@SuppressWarnings
, which works on any element that is annotateable (classes, fields, methods, etc.) - Using
violationSuppressRegex
- Using
violationSuppressXPath
See also: https://pmd.github.io/pmd-6.4.0/pmd_userdocs_suppressing_warnings.html#annotations
Update:
As of PMD 6.22.0, usage of // NOPMD
comments is also a possibility.

Johnco
- 4,037
- 4
- 34
- 43