From: Duarte Meneses Date: Wed, 4 Mar 2020 13:59:35 +0000 (-0600) Subject: SONAR-13158 Scanner logs files indexed with language 'null' X-Git-Tag: 8.3.0.34182~139 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ee7b162dd1226cdcf8426864d212bc3c547ab824;p=sonarqube.git SONAR-13158 Scanner logs files indexed with language 'null' --- diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java index 74dbe5bec00..21435f623ad 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java @@ -44,6 +44,8 @@ import org.sonar.scanner.issue.ignore.scanner.IssueExclusionsLoader; import org.sonar.scanner.scan.ScanProperties; import org.sonar.scanner.util.ProgressReport; +import static java.lang.String.format; + /** * Index input files into {@link InputComponentStore}. */ @@ -141,7 +143,8 @@ public class FileIndexer { checkIfAlreadyIndexed(inputFile); componentStore.put(module.key(), inputFile); issueExclusionsLoader.addMulticriteriaPatterns(inputFile); - LOG.debug("'{}' indexed {}with language '{}'", projectRelativePath, type == Type.TEST ? "as test " : "", inputFile.language()); + String langStr = inputFile.language() != null ? format("with language '%s'", inputFile.language()) : "with no language"; + LOG.debug("'{}' indexed {}{}", projectRelativePath, type == Type.TEST ? "as test " : "", langStr); evaluateCoverageExclusions(moduleCoverageAndDuplicationExclusions, inputFile); evaluateDuplicationExclusions(moduleCoverageAndDuplicationExclusions, inputFile); if (properties.preloadFileMetadata()) { 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 7d2bb6cc9fb..0cc41665dea 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 @@ -222,6 +222,7 @@ public class FileSystemMediumTest { .build()) .execute(); + assertThat(logTester.logs()).contains("'src/main/sample.java' indexed with no language"); assertThat(logTester.logs()).contains("3 files indexed"); assertThat(logTester.logs()).contains("'src/main/sample.xoo' generated metadata with charset 'UTF-8'"); assertThat(String.join("\n", logTester.logs())).doesNotContain("'src/main/sample.java' generated metadata");