use of org.sonar.api.batch.rule.internal.DefaultActiveRules in project sonarqube by SonarSource.
the class EnforceIssuesFilterTest method shouldRefuseIssueIfRuleMatchesAndNotFile.
@Test
public void shouldRefuseIssueIfRuleMatchesAndNotFile() throws IOException {
DefaultActiveRules activeRules = new DefaultActiveRules(ImmutableSet.of());
String path = "org/sonar/api/Issue.java";
RuleKey ruleKey = RuleKey.of("repo", "key");
when(issue.ruleKey()).thenReturn(ruleKey);
IssuePattern matching = new IssuePattern(path, ruleKey.toString());
when(exclusionPatternInitializer.getMulticriteriaPatterns()).thenReturn(ImmutableList.of(matching));
when(issue.getComponent()).thenReturn(TestInputFileBuilder.newDefaultInputProject("foo", tempFolder.newFolder()));
ignoreFilter = new EnforceIssuesFilter(exclusionPatternInitializer, analysisWarnings, activeRules);
assertThat(ignoreFilter.accept(issue, chain)).isFalse();
verifyNoInteractions(chain, analysisWarnings);
}
use of org.sonar.api.batch.rule.internal.DefaultActiveRules in project sonarqube by SonarSource.
the class EnforceIssuesFilterTest method shouldPassToChainIfNoConfiguredPatterns.
@Test
public void shouldPassToChainIfNoConfiguredPatterns() {
DefaultActiveRules activeRules = new DefaultActiveRules(ImmutableSet.of());
ignoreFilter = new EnforceIssuesFilter(exclusionPatternInitializer, analysisWarnings, activeRules);
assertThat(ignoreFilter.accept(issue, chain)).isTrue();
verify(chain).accept(issue);
}
use of org.sonar.api.batch.rule.internal.DefaultActiveRules in project sonarqube by SonarSource.
the class EnforceIssuesFilterTest method shouldAcceptIssueIfMatchesDeprecatedRuleKey.
@Test
public void shouldAcceptIssueIfMatchesDeprecatedRuleKey() {
RuleKey ruleKey = RuleKey.of("repo", "rule");
DefaultActiveRules activeRules = new DefaultActiveRules(ImmutableSet.of(new NewActiveRule.Builder().setRuleKey(ruleKey).setDeprecatedKeys(singleton(RuleKey.of("repo2", "deprecated"))).build()));
String path = "org/sonar/api/Issue.java";
when(issue.ruleKey()).thenReturn(ruleKey);
IssuePattern matching = new IssuePattern("org/**", "repo2:deprecated");
when(exclusionPatternInitializer.getMulticriteriaPatterns()).thenReturn(ImmutableList.of(matching));
when(issue.getComponent()).thenReturn(createComponentWithPath(path));
ignoreFilter = new EnforceIssuesFilter(exclusionPatternInitializer, analysisWarnings, activeRules);
assertThat(ignoreFilter.accept(issue, chain)).isTrue();
verify(analysisWarnings).addUnique("A multicriteria issue enforce uses the rule key 'repo2:deprecated' that has been changed. The pattern should be updated to 'repo:rule'");
verifyNoInteractions(chain);
}
Aggregations