From ee7b162dd1226cdcf8426864d212bc3c547ab824 Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Wed, 4 Mar 2020 07:59:35 -0600 Subject: [PATCH] SONAR-13158 Scanner logs files indexed with language 'null' --- .../java/org/sonar/scanner/scan/filesystem/FileIndexer.java | 5 ++++- .../sonar/scanner/mediumtest/fs/FileSystemMediumTest.java | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) 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"); -- 2.39.5