use of org.sonar.scanner.issue.ignore.pattern.LineRange 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.LineRange in project sonarqube by SonarSource.
the class IssueExclusionsRegexpScannerTest method shouldAddPatternToExcludeLines.
@Test
public void shouldAddPatternToExcludeLines() throws Exception {
regexpScanner.scan(javaFile, new File(Resources.getResource("org/sonar/scanner/issue/ignore/scanner/IssueExclusionsRegexpScannerTest/file-with-double-regexp.txt").toURI()), UTF_8);
Set<LineRange> lineRanges = Sets.newHashSet();
lineRanges.add(new LineRange(21, 25));
verify(patternsInitializer).getPatternMatcher();
verify(patternMatcher, times(1)).addPatternToExcludeLines(javaFile, lineRanges);
verifyNoMoreInteractions(patternsInitializer);
}
use of org.sonar.scanner.issue.ignore.pattern.LineRange in project sonarqube by SonarSource.
the class LineRangeTest method shouldTestInclusionInRangeOfLines.
@Test
public void shouldTestInclusionInRangeOfLines() {
LineRange range = new LineRange(12, 15);
assertThat(range.in(3)).isFalse();
assertThat(range.in(12)).isTrue();
assertThat(range.in(13)).isTrue();
assertThat(range.in(14)).isTrue();
assertThat(range.in(15)).isTrue();
assertThat(range.in(16)).isFalse();
}
use of org.sonar.scanner.issue.ignore.pattern.LineRange in project sonarqube by SonarSource.
the class LineRangeTest method testEquals.
@Test
public void testEquals() throws Exception {
LineRange range = new LineRange(12, 15);
assertThat(range).isEqualTo(range);
assertThat(range).isEqualTo(new LineRange(12, 15));
assertThat(range).isNotEqualTo(new LineRange(12, 2000));
assertThat(range).isNotEqualTo(new LineRange(1000, 2000));
assertThat(range).isNotEqualTo(null);
assertThat(range).isNotEqualTo(new StringBuffer());
}
use of org.sonar.scanner.issue.ignore.pattern.LineRange in project sonarqube by SonarSource.
the class LineRangeTest method shouldConvertLineRangeToLines.
@Test
public void shouldConvertLineRangeToLines() {
LineRange range = new LineRange(12, 15);
assertThat(range.toLines()).containsOnly(12, 13, 14, 15);
}
Aggregations