Package net.sourceforge.pmd.reporting
Interface ViolationSuppressor
- All Known Implementing Classes:
AbstractAnnotationSuppressor
public interface ViolationSuppressor
An object that suppresses rule violations. Suppressors are used by
RuleContext
to filter out violations. In PMD 6.0.x,
the Report
object filtered violations itself - but it has
no knowledge of language-specific suppressors.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Wrapper around a suppression comment.static interface
Represents an instance of a "suppressor" that didn't suppress anything. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ViolationSuppressor
Suppressor for regular NOPMD comments.static final ViolationSuppressor
Suppressor for the violationSuppressRegex property.static final ViolationSuppressor
Suppressor for the violationSuppressXPath property. -
Method Summary
Modifier and TypeMethodDescriptiongetId()
A name, for reporting and documentation purposes.getUnusedSuppressors
(RootNode tree) Return the set of suppressor nodes related to this suppressor that were not used during the analysis.static @Nullable Report.SuppressedViolation
suppressOrNull
(List<ViolationSuppressor> suppressorList, RuleViolation rv, Node node) Apply a list of suppressors on the violation.@Nullable Report.SuppressedViolation
suppressOrNull
(RuleViolation rv, @NonNull Node node) Returns aReport.SuppressedViolation
if the given violation is suppressed by this object.
-
Field Details
-
REGEX_SUPPRESSOR
Suppressor for the violationSuppressRegex property. -
XPATH_SUPPRESSOR
Suppressor for the violationSuppressXPath property. -
NOPMD_COMMENT_SUPPRESSOR
Suppressor for regular NOPMD comments.- Implementation Note:
- This requires special support from the language, namely,
the parser must fill in suppression comments through
AstInfo.withSuppressionComments(Collection)
.
-
-
Method Details
-
getId
String getId()A name, for reporting and documentation purposes. -
suppressOrNull
Returns aReport.SuppressedViolation
if the given violation is suppressed by this object. The node and the rule are provided for context. Returns null if the violation is not suppressed. -
getUnusedSuppressors
Return the set of suppressor nodes related to this suppressor that were not used during the analysis. For instance, for an annotation suppressor, the set contains suppressor nodes wrapping annotations. This must be implemented if this suppressor wants to play well with the unused PMD suppression rule.- Parameters:
tree
- Root node of a file- Returns:
- A set
- Since:
- 7.14.0
-
suppressOrNull
static @Nullable Report.SuppressedViolation suppressOrNull(List<ViolationSuppressor> suppressorList, RuleViolation rv, Node node) Apply a list of suppressors on the violation. Returns the violation of the first suppressor that matches the input violation. If no suppressor matches, then returns null.
-