use of org.sonar.scanner.issue.tracking.TrackedIssue in project sonarqube by SonarSource.
the class ConsoleReportTest method createIssue.
private TrackedIssue createIssue(boolean isNew, @Nullable String severity) {
TrackedIssue issue = new TrackedIssue();
issue.setNew(isNew);
issue.setSeverity(severity);
return issue;
}
use of org.sonar.scanner.issue.tracking.TrackedIssue in project sonarqube by SonarSource.
the class JSONReportTest method should_exclude_resolved_issues.
@Test
public void should_exclude_resolved_issues() throws Exception {
RuleKey ruleKey = RuleKey.of("squid", "AvoidCycles");
TrackedIssue issue = new TrackedIssue();
issue.setKey("200");
issue.setComponentKey("struts:src/main/java/org/apache/struts/Action.java");
issue.setRuleKey(ruleKey);
issue.setStatus(Issue.STATUS_CLOSED);
issue.setResolution(Issue.RESOLUTION_FIXED);
issue.setCreationDate(SIMPLE_DATE_FORMAT.parse("2013-04-24"));
issue.setNew(false);
when(issueCache.all()).thenReturn(Collections.singleton(issue));
StringWriter writer = new StringWriter();
jsonReport.writeJson(writer);
assertThatJson(writer.toString()).isEqualTo(IOUtils.toString(this.getClass().getResource(this.getClass().getSimpleName() + "/report-without-resolved-issues.json")));
}
use of org.sonar.scanner.issue.tracking.TrackedIssue in project sonarqube by SonarSource.
the class JSONReportTest method should_write_json.
@Test
public void should_write_json() throws Exception {
TrackedIssue issue = new TrackedIssue();
issue.setKey("200");
issue.setComponentKey("struts:src/main/java/org/apache/struts/Action.java");
issue.setRuleKey(RuleKey.of("squid", "AvoidCycles"));
issue.setMessage("There are 2 cycles");
issue.setSeverity("MINOR");
issue.setStatus(Issue.STATUS_OPEN);
issue.setResolution(null);
issue.setStartLine(1);
issue.setEndLine(2);
issue.setStartLineOffset(3);
issue.setEndLineOffset(4);
issue.setGap(3.14);
issue.setAssignee("simon");
issue.setCreationDate(SIMPLE_DATE_FORMAT.parse("2013-04-24"));
issue.setNew(false);
when(issueCache.all()).thenReturn(Collections.singleton(issue));
ScannerInput.User user = ScannerInput.User.newBuilder().setLogin("simon").setName("Simon").build();
when(userRepository.load(Collections.singleton("simon"))).thenReturn(Collections.singleton(user));
StringWriter writer = new StringWriter();
jsonReport.writeJson(writer);
assertThatJson(writer.toString()).isEqualTo(IOUtils.toString(this.getClass().getResource(this.getClass().getSimpleName() + "/report.json")));
}
use of org.sonar.scanner.issue.tracking.TrackedIssue in project sonarqube by SonarSource.
the class TaskResult method scanTaskCompleted.
@Override
public void scanTaskCompleted(ProjectScanContainer container) {
LOG.info("Store analysis results in memory for later assertions in medium test");
for (TrackedIssue issue : container.getComponentByType(IssueCache.class).all()) {
issues.add(issue);
}
ReportPublisher reportPublisher = container.getComponentByType(ReportPublisher.class);
reader = new ScannerReportReader(reportPublisher.getReportDir());
if (!container.getComponentByType(AnalysisMode.class).isIssues()) {
Metadata readMetadata = getReportReader().readMetadata();
int rootComponentRef = readMetadata.getRootComponentRef();
storeReportComponents(rootComponentRef, null, readMetadata.getBranch());
}
storeFs(container);
}
use of org.sonar.scanner.issue.tracking.TrackedIssue in project sonarqube by SonarSource.
the class IssuesReportBuilder method processIssues.
private void processIssues(IssuesReport issuesReport, Iterable<TrackedIssue> issues) {
for (TrackedIssue issue : issues) {
Rule rule = findRule(issue);
RulePriority severity = RulePriority.valueOf(issue.severity());
InputComponent resource = inputComponentStore.getByKey(issue.componentKey());
if (!validate(issue, rule, resource)) {
continue;
}
if (issue.resolution() != null) {
issuesReport.addResolvedIssueOnResource(resource, rule, severity);
} else {
issuesReport.addIssueOnResource(resource, issue, rule, severity);
}
}
}
Aggregations