Search in sources :

Example 11 with Issue

use of org.sonar.scanner.protocol.output.ScannerReport.Issue in project sonarqube by SonarSource.

the class MultilineIssuesMediumTest method testFlowWithSingleLocation.

@Test
public void testFlowWithSingleLocation() throws Exception {
    List<Issue> issues = result.issuesFor(result.inputFile("xources/hello/Multiple.xoo"));
    assertThat(issues).hasSize(1);
    Issue issue = issues.get(0);
    assertThat(issue.getMsg()).isEqualTo("Primary location");
    assertThat(issue.getTextRange().getStartLine()).isEqualTo(6);
    assertThat(issue.getTextRange().getStartOffset()).isEqualTo(23);
    assertThat(issue.getTextRange().getEndLine()).isEqualTo(6);
    assertThat(issue.getTextRange().getEndOffset()).isEqualTo(50);
    assertThat(issue.getFlowList()).hasSize(1);
    Flow flow = issue.getFlow(0);
    assertThat(flow.getLocationList()).hasSize(1);
    IssueLocation additionalLocation = flow.getLocation(0);
    assertThat(additionalLocation.getMsg()).isEqualTo("Flow step #1");
    assertThat(additionalLocation.getTextRange().getStartLine()).isEqualTo(7);
    assertThat(additionalLocation.getTextRange().getStartOffset()).isEqualTo(26);
    assertThat(additionalLocation.getTextRange().getEndLine()).isEqualTo(7);
    assertThat(additionalLocation.getTextRange().getEndOffset()).isEqualTo(53);
}
Also used : Issue(org.sonar.scanner.protocol.output.ScannerReport.Issue) IssueLocation(org.sonar.scanner.protocol.output.ScannerReport.IssueLocation) Flow(org.sonar.scanner.protocol.output.ScannerReport.Flow) Test(org.junit.Test)

Example 12 with Issue

use of org.sonar.scanner.protocol.output.ScannerReport.Issue in project sonarqube by SonarSource.

the class ScannerReportViewerApp method updateIssues.

private void updateIssues(Component component) {
    issuesEditor.setText("");
    try (CloseableIterator<Issue> it = reader.readComponentIssues(component.getRef())) {
        while (it.hasNext()) {
            Issue issue = it.next();
            int offset = issuesEditor.getDocument().getEndPosition().getOffset();
            issuesEditor.getDocument().insertString(offset, issue.toString(), null);
        }
    } catch (Exception e) {
        throw new IllegalStateException("Can't read issues for " + getNodeName(component), e);
    }
}
Also used : Issue(org.sonar.scanner.protocol.output.ScannerReport.Issue) IOException(java.io.IOException)

Aggregations

Issue (org.sonar.scanner.protocol.output.ScannerReport.Issue)12 Test (org.junit.Test)11 File (java.io.File)7 TaskResult (org.sonar.scanner.mediumtest.TaskResult)7 Flow (org.sonar.scanner.protocol.output.ScannerReport.Flow)2 IOException (java.io.IOException)1 IssueLocation (org.sonar.scanner.protocol.output.ScannerReport.IssueLocation)1