use of org.sonar.scanner.protocol.output.ScannerReport.ExternalIssue in project sonarqube by SonarSource.
the class ExternalIssuesMediumTest method testLoadIssuesFromJsonReport.
@Test
public void testLoadIssuesFromJsonReport() throws URISyntaxException, IOException {
File projectDir = new File("test-resources/mediumtest/xoo/sample");
File tmpDir = temp.newFolder();
FileUtils.copyDirectory(projectDir, tmpDir);
AnalysisResult result = tester.newAnalysis(new File(tmpDir, "sonar-project.properties")).property("sonar.externalIssuesReportPaths", "externalIssues.json").execute();
List<Issue> issues = result.issuesFor(result.inputFile("xources/hello/HelloJava.xoo"));
assertThat(issues).isEmpty();
List<ExternalIssue> externalIssues = result.externalIssuesFor(result.inputFile("xources/hello/HelloJava.xoo"));
assertThat(externalIssues).hasSize(2);
// precise issue location
ExternalIssue issue = externalIssues.get(0);
assertPreciseIssueLocation(issue);
// location on a line
issue = externalIssues.get(1);
assertIssueLocationLine(issue);
// One file-level issue in helloscala, with secondary location
List<ExternalIssue> externalIssues2 = result.externalIssuesFor(result.inputFile("xources/hello/helloscala.xoo"));
assertThat(externalIssues2).hasSize(1);
issue = externalIssues2.iterator().next();
assertSecondaryLocation(issue);
// one issue is located in a non-existing file
assertThat(logs.logs()).contains("External issues ignored for 1 unknown files, including: invalidFile");
}
use of org.sonar.scanner.protocol.output.ScannerReport.ExternalIssue in project sonarqube by SonarSource.
the class ExternalIssuesMediumTest method testOneIssuePerLine.
@Test
public void testOneIssuePerLine() throws Exception {
File projectDir = new File("test-resources/mediumtest/xoo/sample");
File tmpDir = temp.newFolder();
FileUtils.copyDirectory(projectDir, tmpDir);
AnalysisResult result = tester.newAnalysis(new File(tmpDir, "sonar-project.properties")).property(OneExternalIssuePerLineSensor.ACTIVATE, "true").execute();
List<Issue> issues = result.issuesFor(result.inputFile("xources/hello/HelloJava.xoo"));
assertThat(issues).isEmpty();
List<ExternalIssue> externalIssues = result.externalIssuesFor(result.inputFile("xources/hello/HelloJava.xoo"));
assertThat(externalIssues).hasSize(8);
ExternalIssue issue = externalIssues.get(0);
assertThat(issue.getTextRange().getStartLine()).isEqualTo(issue.getTextRange().getStartLine());
assertThat(result.adHocRules()).isEmpty();
}
use of org.sonar.scanner.protocol.output.ScannerReport.ExternalIssue in project sonarqube by SonarSource.
the class IssuesMediumTest method testOneIssuePerLine.
@Test
public void testOneIssuePerLine() throws Exception {
File projectDir = new File("test-resources/mediumtest/xoo/sample");
File tmpDir = temp.newFolder();
FileUtils.copyDirectory(projectDir, tmpDir);
AnalysisResult result = tester.newAnalysis(new File(tmpDir, "sonar-project.properties")).execute();
List<Issue> issues = result.issuesFor(result.inputFile("xources/hello/HelloJava.xoo"));
assertThat(issues).hasSize(8);
List<ExternalIssue> externalIssues = result.externalIssuesFor(result.inputFile("xources/hello/HelloJava.xoo"));
assertThat(externalIssues).isEmpty();
}
use of org.sonar.scanner.protocol.output.ScannerReport.ExternalIssue in project sonarqube by SonarSource.
the class IssuesMediumTest method testOneExternalIssueOnProject.
@Test
public void testOneExternalIssueOnProject() throws Exception {
File projectDir = new File("test-resources/mediumtest/xoo/sample");
File tmpDir = temp.newFolder();
FileUtils.copyDirectory(projectDir, tmpDir);
AnalysisResult result = tester.newAnalysis(new File(tmpDir, "sonar-project.properties")).property(OneExternalIssueOnProjectSensor.ACTIVATE, "true").execute();
List<ExternalIssue> externalIssues = result.externalIssuesFor(result.project());
assertThat(externalIssues).hasSize(1);
}
use of org.sonar.scanner.protocol.output.ScannerReport.ExternalIssue in project sonarqube by SonarSource.
the class IssuesMediumTest method testOneExternalIssuePerLine.
@Test
public void testOneExternalIssuePerLine() throws Exception {
File projectDir = new File("test-resources/mediumtest/xoo/sample");
File tmpDir = temp.newFolder();
FileUtils.copyDirectory(projectDir, tmpDir);
AnalysisResult result = tester.newAnalysis(new File(tmpDir, "sonar-project.properties")).property(OneExternalIssuePerLineSensor.ACTIVATE, "true").execute();
List<ExternalIssue> externalIssues = result.externalIssuesFor(result.inputFile("xources/hello/HelloJava.xoo"));
assertThat(externalIssues).hasSize(8);
}
Aggregations