return allLines;
}
- public boolean match(Issue violation) {
- boolean match = violation.componentKey() != null
- && matchRule(violation.ruleKey());
- if (checkLines && violation.line() != null) {
- match = match && matchLine(violation.line());
+ public boolean match(Issue issue) {
+ boolean match = matchResource(issue.componentKey())
+ && matchRule(issue.ruleKey());
+ if (checkLines) {
+ if (issue.line() == null) {
+ match = false;
+ } else {
+ match = match && matchLine(issue.line());
+ }
}
return match;
}
}
public void addPatternToExcludeLines(String resource, Set<LineRange> lineRanges) {
- addPatternForComponent(resource, new Pattern(resource, "*", lineRanges));
+ addPatternForComponent(resource, new Pattern(resource, "*", lineRanges).setCheckLines(true));
}
public void configurePatternsForComponent(String componentKey, String path) {
package org.sonar.plugins.core.issue.ignore.pattern;
+import org.junit.Ignore;
+
import org.junit.Test;
import org.sonar.api.issue.Issue;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.Rule;
-
import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Pattern pattern = new Pattern("*", "*");
pattern.addLine(12);
- assertThat(pattern.match(create(rule, javaFile, null))).isTrue();
+ assertThat(pattern.match(create(rule, javaFile, null))).isFalse();
assertThat(pattern.match(create(rule, javaFile, 12))).isTrue();
assertThat(pattern.match(create((Rule) null, javaFile, 5))).isFalse();
assertThat(pattern.match(create(rule, null, null))).isFalse();