use of org.sonar.scanner.issue.ignore.pattern.IssuePattern in project sonarqube by SonarSource.
the class PatternDecoderTest method shouldReadLineIds.
@Test
public void shouldReadLineIds() {
IssuePattern pattern = decoder.decodeLine("*;*;[10,25,98]");
assertThat(pattern.isCheckLines()).isTrue();
assertThat(pattern.getAllLines()).containsOnly(10, 25, 98);
}
use of org.sonar.scanner.issue.ignore.pattern.IssuePattern in project sonarqube by SonarSource.
the class PatternDecoderTest method shouldNotExcludeLines.
@Test
public void shouldNotExcludeLines() {
// [] is different than *
// - all violations are excluded on *
// * no violations are excluded on []
IssuePattern pattern = decoder.decodeLine("*;*;[]");
assertThat(pattern.isCheckLines()).isTrue();
assertThat(pattern.getAllLines()).isEmpty();
}
use of org.sonar.scanner.issue.ignore.pattern.IssuePattern in project sonarqube by SonarSource.
the class PatternMatcherTest method shouldReturnExtraPatternForLinesOfResource.
@Test
public void shouldReturnExtraPatternForLinesOfResource() {
String file = "foo";
Set<LineRange> lineRanges = Sets.newHashSet();
lineRanges.add(new LineRange(25, 28));
patternMatcher.addPatternToExcludeLines(file, lineRanges);
IssuePattern extraPattern = patternMatcher.getPatternsForComponent(file).iterator().next();
assertThat(extraPattern.matchResource(file)).isTrue();
assertThat(extraPattern.getAllLines()).isEqualTo(Sets.newHashSet(25, 26, 27, 28));
}
use of org.sonar.scanner.issue.ignore.pattern.IssuePattern in project sonarqube by SonarSource.
the class PatternDecoderTest method shouldReadRangeOfLineIds.
@Test
public void shouldReadRangeOfLineIds() {
IssuePattern pattern = decoder.decodeLine("*;*;[10-12,25,97-100]");
assertThat(pattern.isCheckLines()).isTrue();
assertThat(pattern.getAllLines()).containsOnly(10, 11, 12, 25, 97, 98, 99, 100);
}
use of org.sonar.scanner.issue.ignore.pattern.IssuePattern in project sonarqube by SonarSource.
the class PatternDecoderTest method shouldReadAllFilePattern.
@Test
public void shouldReadAllFilePattern() {
IssuePattern pattern = decoder.decodeLine("SONAR-ALL-OFF");
assertThat(pattern.getResourcePattern()).isNull();
assertThat(pattern.getAllFileRegexp()).isEqualTo("SONAR-ALL-OFF");
}
Aggregations