diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2017-03-07 17:55:18 +0100 |
---|---|---|
committer | Julien HENRY <henryju@yahoo.fr> | 2017-03-08 10:41:56 +0100 |
commit | bf22538c7ee89054b194715ceaa1d33e62c0da4c (patch) | |
tree | 000e863f1b2df5953129e290bad468fa0de8a734 /sonar-scanner-engine | |
parent | 305edb8630e8797e6db4da981b5c578c64272b36 (diff) | |
download | sonarqube-bf22538c7ee89054b194715ceaa1d33e62c0da4c.tar.gz sonarqube-bf22538c7ee89054b194715ceaa1d33e62c0da4c.zip |
SONAR-8623 Index all source files, even the ones with no supported language
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r-- | sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MeasuresPublisher.java | 2 | ||||
-rw-r--r-- | sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java | 33 |
2 files changed, 23 insertions, 12 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MeasuresPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MeasuresPublisher.java index 238880b78af..535708283d2 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MeasuresPublisher.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MeasuresPublisher.java @@ -82,7 +82,7 @@ public class MeasuresPublisher implements ReportPublisherStep { public void publish(ScannerReportWriter writer) { final ScannerReport.Measure.Builder builder = ScannerReport.Measure.newBuilder(); - for (final InputComponent c : componentStore.all()) { + for (final InputComponent c : componentStore.allFilesToPublish()) { DefaultInputComponent component = (DefaultInputComponent) c; // Recompute all coverage measures from line data to take into account the possible merge of several reports updateCoverageFromLineData(component); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java index 96e8df3f64d..a5670e4aeeb 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java @@ -20,6 +20,8 @@ package org.sonar.scanner.mediumtest.fs; import com.google.common.collect.ImmutableMap; + +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -215,6 +217,7 @@ public class FileSystemMediumTest { assertThat(logs.getAllAsString()).contains("2 files indexed"); assertThat(logs.getAllAsString()).contains("'src/sample.xoo' generated metadata"); assertThat(logs.getAllAsString()).doesNotContain("'src/sample.java' generated metadata"); + } @Test @@ -246,25 +249,33 @@ public class FileSystemMediumTest { public void dontPublishFilesWithoutDetectedLanguage() throws IOException { builder = createBuilder(); - File srcDir = new File(baseDir, "src"); - srcDir.mkdir(); + Path mainDir = baseDir.toPath().resolve("src").resolve("main"); + Files.createDirectories(mainDir); - File xooFile = new File(srcDir, "sample.xoo"); - FileUtils.write(xooFile, "Sample xoo\ncontent"); + Path testDir = baseDir.toPath().resolve("src").resolve("test"); + Files.createDirectories(testDir); + + Path testXooFile = testDir.resolve("sample.java"); + Files.write(testXooFile, "Sample xoo\ncontent".getBytes(StandardCharsets.UTF_8)); + + Path xooFile = mainDir.resolve("sample.xoo"); + Files.write(xooFile, "Sample xoo\ncontent".getBytes(StandardCharsets.UTF_8)); - File javaFile = new File(srcDir, "sample.java"); - FileUtils.write(javaFile, "Sample xoo\ncontent"); + Path javaFile = mainDir.resolve("sample.java"); + Files.write(javaFile, "Sample xoo\ncontent".getBytes(StandardCharsets.UTF_8)); TaskResult result = tester.newTask() .properties(builder - .put("sonar.sources", "src") + .put("sonar.sources", "src/main") + .put("sonar.tests", "src/test") .build()) .start(); - assertThat(logs.getAllAsString()).contains("2 files indexed"); - assertThat(logs.getAllAsString()).contains("'src/sample.xoo' generated metadata"); - assertThat(logs.getAllAsString()).doesNotContain("'src/sample.java' generated metadata"); - DefaultInputFile javaInputFile = (DefaultInputFile) result.inputFile("src/sample.java"); + assertThat(logs.getAllAsString()).contains("3 files indexed"); + assertThat(logs.getAllAsString()).contains("'src/main/sample.xoo' generated metadata"); + assertThat(logs.getAllAsString()).doesNotContain("'src/main/sample.java' generated metadata"); + assertThat(logs.getAllAsString()).doesNotContain("'src/test/sample.java' generated metadata"); + DefaultInputFile javaInputFile = (DefaultInputFile) result.inputFile("src/main/sample.java"); assertThat(result.getReportComponent(javaInputFile.key())).isNull(); } |