Package org.sonar.batch.issue.ignore.pattern

Examples of org.sonar.batch.issue.ignore.pattern.IssuePattern


  @Override
  public boolean accept(Issue issue, IssueFilterChain chain) {
    boolean atLeastOneRuleMatched = false;
    boolean atLeastOnePatternFullyMatched = false;
    IssuePattern matchingPattern = null;

    for (IssuePattern pattern : patternInitializer.getMulticriteriaPatterns()) {
      if (pattern.getRulePattern().match(issue.ruleKey().toString())) {
        atLeastOneRuleMatched = true;
        String pathForComponent = patternInitializer.getPathForComponent(issue.componentKey());
View Full Code Here


      return chain.accept(issue);
    }
  }

  private boolean hasMatchFor(Issue issue) {
    IssuePattern pattern = patternMatcher.getMatchingPattern(issue);
    if (pattern != null) {
      logExclusion(issue, pattern);
      return true;
    }
    return false;
View Full Code Here

  @Test
  public void shouldReturnExtraPatternForResource() {
    String file = "foo";
    patternMatcher.addPatternToExcludeResource(file);

    IssuePattern extraPattern = patternMatcher.getPatternsForComponent(file).iterator().next();
    assertThat(extraPattern.matchResource(file)).isTrue();
    assertThat(extraPattern.isCheckLines()).isFalse();
  }
View Full Code Here

    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));
  }
View Full Code Here

  }

  @Test
  public void shouldMatchRule() {
    RuleKey rule = Rule.create("checkstyle", "IllegalRegexp", "").ruleKey();
    assertThat(new IssuePattern("*", "*").matchRule(rule)).isTrue();
    assertThat(new IssuePattern("*", "checkstyle:*").matchRule(rule)).isTrue();
    assertThat(new IssuePattern("*", "checkstyle:IllegalRegexp").matchRule(rule)).isTrue();
    assertThat(new IssuePattern("*", "checkstyle:Illegal*").matchRule(rule)).isTrue();
    assertThat(new IssuePattern("*", "*:*Illegal*").matchRule(rule)).isTrue();

    assertThat(new IssuePattern("*", "pmd:IllegalRegexp").matchRule(rule)).isFalse();
    assertThat(new IssuePattern("*", "pmd:*").matchRule(rule)).isFalse();
    assertThat(new IssuePattern("*", "*:Foo*IllegalRegexp").matchRule(rule)).isFalse();
  }
View Full Code Here

  @Test
  public void shouldMatchViolation() {
    Rule rule = Rule.create("checkstyle", "IllegalRegexp", "");
    String javaFile = "org.foo.Bar";

    IssuePattern pattern = new IssuePattern("*", "*");
    pattern.addLine(12);

    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();
    assertThat(pattern.match(create((Rule) null, null, null))).isFalse();
  }
View Full Code Here

    return mockIssue;
  }

  @Test
  public void shouldNotMatchNullRule() {
    assertThat(new IssuePattern("*", "*").matchRule(null)).isFalse();
  }
View Full Code Here

    assertThat(new IssuePattern("*", "*").matchRule(null)).isFalse();
  }

  @Test
  public void shouldPrintPatternToString() {
    IssuePattern pattern = new IssuePattern("*", "checkstyle:*");

    assertThat(pattern.toString()).isEqualTo("IssuePattern[resourcePattern=*,rulePattern=checkstyle:*,lines=[],lineRanges=[],beginBlockRegexp=<null>,endBlockRegexp=<null>,allFileRegexp=<null>,checkLines=true]");
  }
View Full Code Here

    assertThat(PatternDecoder.isLinesRange("[13,24-65,84-89,122]")).isTrue();
  }

  @Test
  public void shouldReadStarPatterns() {
    IssuePattern pattern = decoder.decodeLine("*;*;*");

    assertThat(pattern.getResourcePattern().toString()).isEqualTo("*");
    assertThat(pattern.getRulePattern().toString()).isEqualTo("*");
    assertThat(pattern.isCheckLines()).isFalse();
  }
View Full Code Here

    assertThat(pattern.isCheckLines()).isFalse();
  }

  @Test
  public void shouldReadLineIds() {
    IssuePattern pattern = decoder.decodeLine("*;*;[10,25,98]");

    assertThat(pattern.isCheckLines()).isTrue();
    assertThat(pattern.getAllLines()).containsOnly(10, 25, 98);
  }
View Full Code Here

TOP

Related Classes of org.sonar.batch.issue.ignore.pattern.IssuePattern

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.