use of org.sonar.scanner.issue.DefaultFilterableIssue in project sonarqube by SonarSource.
the class DefaultFilterableIssueTest method testRoundTrip.
@Test
public void testRoundTrip() {
rawIssue = createIssue();
issue = new DefaultFilterableIssue(mockedProject, projectAnalysisInfo, rawIssue, componentKey);
when(projectAnalysisInfo.analysisDate()).thenReturn(new Date(10_000));
when(mockedProject.key()).thenReturn("projectKey");
assertThat(issue.componentKey()).isEqualTo(componentKey);
assertThat(issue.creationDate()).isEqualTo(new Date(10_000));
assertThat(issue.line()).isEqualTo(30);
assertThat(issue.projectKey()).isEqualTo("projectKey");
assertThat(issue.effortToFix()).isEqualTo(3.0);
assertThat(issue.severity()).isEqualTo("MAJOR");
}
use of org.sonar.scanner.issue.DefaultFilterableIssue in project sonarqube by SonarSource.
the class DefaultFilterableIssueTest method nullValues.
@Test
public void nullValues() {
rawIssue = createIssueWithoutFields();
issue = new DefaultFilterableIssue(mockedProject, projectAnalysisInfo, rawIssue, componentKey);
assertThat(issue.line()).isNull();
assertThat(issue.effortToFix()).isNull();
}
use of org.sonar.scanner.issue.DefaultFilterableIssue in project sonarqube by SonarSource.
the class EnforceIssuesFilter method accept.
@Override
public boolean accept(FilterableIssue issue, IssueFilterChain chain) {
boolean atLeastOneRuleMatched = false;
boolean atLeastOnePatternFullyMatched = false;
IssuePattern matchingPattern = null;
for (IssuePattern pattern : multicriteriaPatterns) {
if (ruleMatches(pattern, issue.ruleKey())) {
atLeastOneRuleMatched = true;
InputComponent component = ((DefaultFilterableIssue) issue).getComponent();
if (component.isFile()) {
DefaultInputFile file = (DefaultInputFile) component;
if (pattern.matchFile(file.getProjectRelativePath())) {
atLeastOnePatternFullyMatched = true;
matchingPattern = pattern;
} else if (pattern.matchFile(file.getModuleRelativePath())) {
warnOnceDeprecatedIssuePattern("Specifying module-relative paths at project level in property '" + IssueInclusionPatternInitializer.CONFIG_KEY + "' is deprecated. " + "To continue matching files like '" + file.getProjectRelativePath() + "', update this property so that patterns refer to project-relative paths.");
atLeastOnePatternFullyMatched = true;
matchingPattern = pattern;
}
}
}
}
if (atLeastOneRuleMatched) {
if (atLeastOnePatternFullyMatched) {
LOG.debug("Issue '{}' enforced by pattern '{}'", issue, matchingPattern);
}
return atLeastOnePatternFullyMatched;
} else {
return chain.accept(issue);
}
}
Aggregations