Search in sources :

Example 1 with IssuePattern

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);
}
Also used : IssuePattern(org.sonar.scanner.issue.ignore.pattern.IssuePattern) Test(org.junit.Test)

Example 2 with IssuePattern

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();
}
Also used : IssuePattern(org.sonar.scanner.issue.ignore.pattern.IssuePattern) Test(org.junit.Test)

Example 3 with IssuePattern

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));
}
Also used : IssuePattern(org.sonar.scanner.issue.ignore.pattern.IssuePattern) LineRange(org.sonar.scanner.issue.ignore.pattern.LineRange) Test(org.junit.Test)

Example 4 with IssuePattern

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);
}
Also used : IssuePattern(org.sonar.scanner.issue.ignore.pattern.IssuePattern) Test(org.junit.Test)

Example 5 with IssuePattern

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");
}
Also used : IssuePattern(org.sonar.scanner.issue.ignore.pattern.IssuePattern) Test(org.junit.Test)

Aggregations

IssuePattern (org.sonar.scanner.issue.ignore.pattern.IssuePattern)17 Test (org.junit.Test)16 RuleKey (org.sonar.api.rule.RuleKey)6 DefaultActiveRules (org.sonar.api.batch.rule.internal.DefaultActiveRules)5 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)2 InputComponent (org.sonar.api.batch.fs.InputComponent)1 NewActiveRule (org.sonar.api.batch.rule.internal.NewActiveRule)1 AnalysisWarnings (org.sonar.api.notifications.AnalysisWarnings)1 WildcardPattern (org.sonar.api.utils.WildcardPattern)1 DefaultFilterableIssue (org.sonar.scanner.issue.DefaultFilterableIssue)1 LineRange (org.sonar.scanner.issue.ignore.pattern.LineRange)1