use of org.sonar.api.scan.issue.filter.FilterableIssue in project sonarqube by SonarSource.
the class NoSonarFilterTest method should_accept_issues_on_no_sonar_rules.
@Test
public void should_accept_issues_on_no_sonar_rules() {
// The "No Sonar" rule logs violations on the lines that are flagged with "NOSONAR" !!
FilterableIssue issue = mock(FilterableIssue.class);
when(issue.componentKey()).thenReturn("struts:org.apache.Action");
when(issue.ruleKey()).thenReturn(RuleKey.of("squid", "NoSonarCheck"));
Set<Integer> noSonarLines = ImmutableSet.of(31, 55);
filter.addComponent("struts:org.apache.Action", noSonarLines);
when(issue.line()).thenReturn(31);
assertThat(filter.accept(issue, chain)).isTrue();
when(issue.line()).thenReturn(222);
assertThat(filter.accept(issue, chain)).isTrue();
verify(chain, times(2)).accept(issue);
}
use of org.sonar.api.scan.issue.filter.FilterableIssue in project sonarqube by SonarSource.
the class NoSonarFilterTest method should_ignore_lines_commented_with_nosonar.
@Test
public void should_ignore_lines_commented_with_nosonar() {
FilterableIssue issue = mock(FilterableIssue.class);
when(issue.componentKey()).thenReturn("struts:org.apache.Action");
when(issue.ruleKey()).thenReturn(RuleKey.of("squid", "AvoidCycles"));
Set<Integer> noSonarLines = ImmutableSet.of(31, 55);
filter.addComponent("struts:org.apache.Action", noSonarLines);
// issue on file
when(issue.line()).thenReturn(null);
assertThat(filter.accept(issue, chain)).isTrue();
// issue on lines
when(issue.line()).thenReturn(31);
assertThat(filter.accept(issue, chain)).isFalse();
when(issue.line()).thenReturn(222);
assertThat(filter.accept(issue, chain)).isTrue();
verify(chain, times(2)).accept(issue);
}
use of org.sonar.api.scan.issue.filter.FilterableIssue in project sonarqube by SonarSource.
the class IssueFilters method accept.
public boolean accept(String componentKey, ScannerReport.Issue rawIssue) {
IssueFilterChain filterChain = new DefaultIssueFilterChain(filters);
FilterableIssue fIssue = new DefaultFilterableIssue(module, projectAnalysisInfo, rawIssue, componentKey);
if (filterChain.accept(fIssue)) {
return acceptDeprecated(componentKey, rawIssue);
}
return false;
}
use of org.sonar.api.scan.issue.filter.FilterableIssue in project sonarqube by SonarSource.
the class PatternMatcherTest method create.
private FilterableIssue create(Rule rule, String component, Integer line) {
FilterableIssue mockIssue = mock(FilterableIssue.class);
RuleKey ruleKey = null;
if (rule != null) {
ruleKey = rule.ruleKey();
}
when(mockIssue.ruleKey()).thenReturn(ruleKey);
when(mockIssue.componentKey()).thenReturn(component);
when(mockIssue.line()).thenReturn(line);
return mockIssue;
}
use of org.sonar.api.scan.issue.filter.FilterableIssue in project sonarqube by SonarSource.
the class IssuePatternTest method create.
private FilterableIssue create(Rule rule, String component, Integer line) {
FilterableIssue mockIssue = mock(FilterableIssue.class);
RuleKey ruleKey = null;
if (rule != null) {
ruleKey = rule.ruleKey();
}
when(mockIssue.ruleKey()).thenReturn(ruleKey);
when(mockIssue.componentKey()).thenReturn(component);
when(mockIssue.line()).thenReturn(line);
return mockIssue;
}
Aggregations