forked from phoedos/pmd
Cleanup a bit
This commit is contained in:
@ -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
|
||||
|
@ -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<ViolationSuppressor> suppressors = new ArrayList<>(getSuppressors());
|
||||
Set<ViolationSuppressor> suppressors = new LinkedHashSet<>(getSuppressors());
|
||||
suppressors.add(ViolationSuppressor.NOPMD_COMMENT_SUPPRESSOR);
|
||||
suppressors.add(ViolationSuppressor.REGEX_SUPPRESSOR);
|
||||
suppressors.add(ViolationSuppressor.XPATH_SUPPRESSOR);
|
||||
|
@ -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<T extends Node> 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<T extends Node> 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) {
|
||||
|
Reference in New Issue
Block a user