diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/ViolationSuppressor.java b/pmd-core/src/main/java/net/sourceforge/pmd/ViolationSuppressor.java index 8462e0a07f..9ffcef1e9d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/ViolationSuppressor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/ViolationSuppressor.java @@ -64,13 +64,6 @@ public interface ViolationSuppressor { * * @implNote This requires special support from the language, namely * an implementation of {@link RootNode#getNoPmdComments()}. - * - * - TODO this could replace the ParserOptions + RootNode#getNoPmdComments - * Just make a custom suppressor with constructor params - * * the suppress marker - * * a lang-specific strategy to get the comments - * - * This would require the service architecture I'd like to put forward. */ ViolationSuppressor NOPMD_COMMENT_SUPPRESSOR = new ViolationSuppressor() { @Override diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRuleViolationFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRuleViolationFactory.java index b19ae205ee..9526056375 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRuleViolationFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRuleViolationFactory.java @@ -5,9 +5,10 @@ package net.sourceforge.pmd.lang.rule; import java.text.MessageFormat; -import java.util.ArrayList; import java.util.Collections; +import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.Nullable; @@ -65,7 +66,7 @@ public abstract class AbstractRuleViolationFactory implements RuleViolationFacto } private void maybeSuppress(RuleContext ruleContext, @Nullable Node node, RuleViolation rv) { - List suppressors = new ArrayList<>(getSuppressors()); + Set suppressors = new LinkedHashSet<>(getSuppressors()); suppressors.add(ViolationSuppressor.NOPMD_COMMENT_SUPPRESSOR); suppressors.add(ViolationSuppressor.REGEX_SUPPRESSOR); suppressors.add(ViolationSuppressor.XPATH_SUPPRESSOR); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java index 7530cddc07..8e8073aced 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java @@ -5,7 +5,6 @@ package net.sourceforge.pmd.lang.rule; import java.io.File; -import java.util.regex.Pattern; import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleContext; @@ -18,7 +17,6 @@ public class ParametricRuleViolation implements RuleViolation { protected final Rule rule; protected final String description; - protected boolean suppressed; protected String filename; protected int beginLine; @@ -54,28 +52,6 @@ public class ParametricRuleViolation implements RuleViolation { endColumn = node.getEndColumn(); } - // Apply Rule specific suppressions - if (node != null && rule != null) { - setSuppression(rule, node); - } - - } - - private void setSuppression(Rule rule, T node) { - - String regex = rule.getProperty(Rule.VIOLATION_SUPPRESS_REGEX_DESCRIPTOR); // Regex - if (regex != null && description != null) { - if (Pattern.matches(regex, description)) { - suppressed = true; - } - } - - if (!suppressed) { // XPath - String xpath = rule.getProperty(Rule.VIOLATION_SUPPRESS_XPATH_DESCRIPTOR); - if (xpath != null) { - suppressed = node.hasDescendantMatchingXPath(xpath); - } - } } protected String expandVariables(String message) {