From 79600964b52d3aaf53b564111bb7aa9af56770be Mon Sep 17 00:00:00 2001 From: Tim Pohlmann Date: Tue, 30 Jul 2024 12:29:11 +0200 Subject: [PATCH 1/3] Align coverage log messages --- .../plugins/dotnet/tests/DotCoverReportParser.java | 5 +++-- .../plugins/dotnet/tests/NCover3ReportParser.java | 5 +++-- .../plugins/dotnet/tests/OpenCoverReportParser.java | 3 ++- .../sonar/plugins/dotnet/tests/ScannerFileService.java | 7 +++++-- .../plugins/dotnet/tests/DotCoverReportParserTest.java | 3 ++- .../plugins/dotnet/tests/NCover3ReportParserTest.java | 6 ++++-- .../dotnet/tests/OpenCoverReportParserTest.java | 10 +++++----- .../plugins/dotnet/tests/ScannerFileServiceTest.java | 5 +++-- 8 files changed, 27 insertions(+), 17 deletions(-) diff --git a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/DotCoverReportParser.java b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/DotCoverReportParser.java index 4545d52df7d..955649cb4f6 100644 --- a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/DotCoverReportParser.java +++ b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/DotCoverReportParser.java @@ -70,8 +70,9 @@ public void parse() { if (fileCanonicalPath != null && fileService.isSupportedAbsolute(fileCanonicalPath)) { collectCoverage(fileCanonicalPath, contents); } else { - LOG.debug("Skipping the import of dotCover code coverage for file '{}'" - + " because it is not indexed or does not have the supported language.", fileCanonicalPath); + LOG.debug("Skipping the import of dotCover code coverage for file '{}' because it is not indexed or" + + " does not have the supported language. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", + fileCanonicalPath); } } diff --git a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/NCover3ReportParser.java b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/NCover3ReportParser.java index 5c0590b3217..f6066196a1c 100644 --- a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/NCover3ReportParser.java +++ b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/NCover3ReportParser.java @@ -128,8 +128,9 @@ private void handleSegmentPointTag(XmlParserHelper xmlParserHelper) { coverage.addHits(path, line, vc); } else { - LOG.debug("NCover3 doc '{}', line '{}', vc '{}' will be skipped because it has a path '{}'" + - " which is not indexed or does not have the supported language.", + LOG.debug("NCover3 doc '{}', line '{}', vc '{}' will be skipped because it has a path '{}'" + + " which is not indexed or does not have the supported language. " + + "Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", doc, line, vc, path); } } else if (!isExcludedLine(line)) { diff --git a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/OpenCoverReportParser.java b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/OpenCoverReportParser.java index e443254862a..80bb8305288 100644 --- a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/OpenCoverReportParser.java +++ b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/OpenCoverReportParser.java @@ -128,7 +128,8 @@ private void handleSequencePointTag(XmlParserHelper xmlParserHelper) { LOG.trace("OpenCover parser: add hits for file {}, line '{}', visitCount '{}'.", coveredFile, line, visitCount); } else { - LOG.debug("Skipping the file {}, line '{}', visitCount '{}' because file is not indexed or does not have the supported language.", + LOG.debug("Skipping the file {}, line '{}', visitCount '{}' because file is not indexed or does not have the supported language." + + " Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", coveredFile, line, visitCount); } } else { diff --git a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/ScannerFileService.java b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/ScannerFileService.java index d0f1ad7c7b9..61810691da3 100644 --- a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/ScannerFileService.java +++ b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/ScannerFileService.java @@ -67,12 +67,15 @@ public Optional getAbsolutePath(String deterministicBuildPath) { LOG.trace("Found indexed file '{}' for '{}' (normalized to '{}').", foundFile, deterministicBuildPath, pathSuffix); return Optional.of(foundFile); } else { - LOG.debug("Found {} indexed files for '{}' (normalized to '{}'). Will skip this coverage entry. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", + LOG.debug("Found {} indexed files for '{}' (normalized to '{}'). Will skip this coverage entry." + + " Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", foundFiles.size(), deterministicBuildPath, pathSuffix); return Optional.empty(); } } - LOG.debug("Did not find deterministic source path in '{}'. Will skip this coverage entry. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", deterministicBuildPath); + LOG.debug("The file '{}' is not indexed or does not have the supported language. Will skip this coverage entry. " + + "Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", + deterministicBuildPath); return Optional.empty(); } } diff --git a/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/DotCoverReportParserTest.java b/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/DotCoverReportParserTest.java index 3db5d29f732..c87da243a6c 100644 --- a/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/DotCoverReportParserTest.java +++ b/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/DotCoverReportParserTest.java @@ -201,7 +201,8 @@ public void predicate_false() { assertThat(logTester.logs(Level.INFO).get(0)).startsWith("Parsing the dotCover report "); assertThat(logTester.logs(Level.DEBUG).get(0)) .startsWith("Skipping the import of dotCover code coverage for file '") - .endsWith("' because it is not indexed or does not have the supported language."); + .endsWith("' because it is not indexed or does not have the supported language. " + + "Verify sonar.sources in .sonarqube\\out\\sonar-project.properties."); } @Test diff --git a/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/NCover3ReportParserTest.java b/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/NCover3ReportParserTest.java index 448682728e9..a2a17d971d4 100644 --- a/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/NCover3ReportParserTest.java +++ b/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/NCover3ReportParserTest.java @@ -140,10 +140,12 @@ public void log_unsupported_file_extension() throws Exception { assertThat(debugLogs.get(0)).startsWith("The current user dir is '"); assertThat(debugLogs.get(1)) .startsWith("NCover3 doc '1', line '31', vc '4' will be skipped because it has a path '") - .endsWith("\\MyLibrary\\Adder.cs' which is not indexed or does not have the supported language."); + .endsWith("\\MyLibrary\\Adder.cs' which is not indexed or does not have the supported language. " + + "Verify sonar.sources in .sonarqube\\out\\sonar-project.properties."); assertThat(debugLogs.get(2)) .startsWith("NCover3 doc '1', line '32', vc '4' will be skipped because it has a path '") - .endsWith("\\MyLibrary\\Adder.cs' which is not indexed or does not have the supported language."); + .endsWith("\\MyLibrary\\Adder.cs' which is not indexed or does not have the supported language. " + + "Verify sonar.sources in .sonarqube\\out\\sonar-project.properties."); List traceLogs = logTester.logs(Level.TRACE); assertThat(traceLogs.get(0)).isEqualTo("Analyzing the doc tag with NCover3 ID '1' and url 'MyLibrary\\Adder.cs'."); assertThat(traceLogs.get(1)) diff --git a/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/OpenCoverReportParserTest.java b/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/OpenCoverReportParserTest.java index 4144090413f..e93d680dce4 100644 --- a/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/OpenCoverReportParserTest.java +++ b/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/OpenCoverReportParserTest.java @@ -324,8 +324,8 @@ public void branchCoverage_codeFile_unsupportedFile() throws Exception { // The other logs contain system-dependants paths (e.g. "The current user dir is ...", "CoveredFile created: ...") .contains( // these are not ordered - "Skipping the file (ID '1', path 'BranchCoverage3296\\Code\\ValueProvider.cs', NO INDEXED PATH), line '5', visitCount '1' because file is not indexed or does not have the supported language.", - "Skipping the file (ID '2', path 'BranchCoverage3296\\Code\\ValueProvider.cs', NO INDEXED PATH), line '5', visitCount '1' because file is not indexed or does not have the supported language.", + "Skipping the file (ID '1', path 'BranchCoverage3296\\Code\\ValueProvider.cs', NO INDEXED PATH), line '5', visitCount '1' because file is not indexed or does not have the supported language. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", + "Skipping the file (ID '2', path 'BranchCoverage3296\\Code\\ValueProvider.cs', NO INDEXED PATH), line '5', visitCount '1' because file is not indexed or does not have the supported language. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", "OpenCover parser: Skipping branch hits for file (ID '2', path 'BranchCoverage3296\\Code\\ValueProvider.cs', NO INDEXED PATH), line '5', offset '1', visitCount '1' because file is not indexed or does not have the supported language.", "OpenCover parser: Skipping branch hits for file (ID '2', path 'BranchCoverage3296\\Code\\ValueProvider.cs', NO INDEXED PATH), line '5', offset '1', visitCount '0' because file is not indexed or does not have the supported language.", "OpenCover parser: Skipping branch hits for file (ID '1', path 'BranchCoverage3296\\Code\\ValueProvider.cs', NO INDEXED PATH), line '5', offset '1', visitCount '0' because file is not indexed or does not have the supported language.", @@ -402,9 +402,9 @@ public void log_unsupported_file_extension() { assertThat(debugLogs.stream().skip(1)) .containsExactlyInAnyOrder( "CoveredFile created: (ID '1', path 'MyLibraryNUnitTest\\AdderNUnitTest.cs', NO INDEXED PATH).", - "Skipping the file (ID '1', path 'MyLibraryNUnitTest\\AdderNUnitTest.cs', NO INDEXED PATH), line '16', visitCount '1' because file is not indexed or does not have the supported language.", - "Skipping the file (ID '1', path 'MyLibraryNUnitTest\\AdderNUnitTest.cs', NO INDEXED PATH), line '17', visitCount '1' because file is not indexed or does not have the supported language.", - "Skipping the file (ID '1', path 'MyLibraryNUnitTest\\AdderNUnitTest.cs', NO INDEXED PATH), line '18', visitCount '1' because file is not indexed or does not have the supported language." + "Skipping the file (ID '1', path 'MyLibraryNUnitTest\\AdderNUnitTest.cs', NO INDEXED PATH), line '16', visitCount '1' because file is not indexed or does not have the supported language. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", + "Skipping the file (ID '1', path 'MyLibraryNUnitTest\\AdderNUnitTest.cs', NO INDEXED PATH), line '17', visitCount '1' because file is not indexed or does not have the supported language. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", + "Skipping the file (ID '1', path 'MyLibraryNUnitTest\\AdderNUnitTest.cs', NO INDEXED PATH), line '18', visitCount '1' because file is not indexed or does not have the supported language. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties." ); } diff --git a/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/ScannerFileServiceTest.java b/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/ScannerFileServiceTest.java index 2dbef70fa7d..6fb3652a9e4 100644 --- a/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/ScannerFileServiceTest.java +++ b/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/ScannerFileServiceTest.java @@ -199,8 +199,9 @@ public void getAbsolutePath_with_no_deterministic_path_in_windows_path_returns_e verify(fs, never()).predicates(); assertThat(logTester.logs(Level.TRACE)).isEmpty(); assertThat(logTester.logs(Level.DEBUG)).hasSize(1); - assertThat(logTester.logs(Level.DEBUG).get(0)).isEqualTo("Did not find deterministic source path in 'C:\\_\\some\\path\\file.cs'." + - " Will skip this coverage entry. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties."); + assertThat(logTester.logs(Level.DEBUG).get(0)).isEqualTo( + "The file 'C:\\_\\some\\path\\file.cs' is not indexed or does not have the supported language." + + " Will skip this coverage entry. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties."); } @Test From 60d57743b54702dab9001a42fb6b26207aa0dca1 Mon Sep 17 00:00:00 2001 From: Tim Pohlmann Date: Thu, 1 Aug 2024 12:12:50 +0200 Subject: [PATCH 2/3] Review 1 --- .../plugins/dotnet/tests/CoverageParser.java | 1 + .../dotnet/tests/DotCoverReportParser.java | 2 +- .../dotnet/tests/NCover3ReportParser.java | 3 +-- .../dotnet/tests/OpenCoverReportParser.java | 6 +++--- .../dotnet/tests/ScannerFileService.java | 18 ++++++++++++------ .../tests/OpenCoverReportParserTest.java | 8 ++++---- .../dotnet/tests/ScannerFileServiceTest.java | 9 +++++---- 7 files changed, 27 insertions(+), 20 deletions(-) diff --git a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/CoverageParser.java b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/CoverageParser.java index dcd0d91fd34..d19ee83c908 100644 --- a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/CoverageParser.java +++ b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/CoverageParser.java @@ -24,4 +24,5 @@ @FunctionalInterface public interface CoverageParser extends BiConsumer { + String VERIFY_SONARPROJECTPROPERTIES_MESSAGE = "Verify sonar.sources in .sonarqube\\out\\sonar-project.properties."; } diff --git a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/DotCoverReportParser.java b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/DotCoverReportParser.java index 955649cb4f6..3361b9f82b5 100644 --- a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/DotCoverReportParser.java +++ b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/DotCoverReportParser.java @@ -71,7 +71,7 @@ public void parse() { collectCoverage(fileCanonicalPath, contents); } else { LOG.debug("Skipping the import of dotCover code coverage for file '{}' because it is not indexed or" - + " does not have the supported language. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", + + " does not have the supported language. " + VERIFY_SONARPROJECTPROPERTIES_MESSAGE, fileCanonicalPath); } } diff --git a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/NCover3ReportParser.java b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/NCover3ReportParser.java index f6066196a1c..1fda868da14 100644 --- a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/NCover3ReportParser.java +++ b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/NCover3ReportParser.java @@ -129,8 +129,7 @@ private void handleSegmentPointTag(XmlParserHelper xmlParserHelper) { coverage.addHits(path, line, vc); } else { LOG.debug("NCover3 doc '{}', line '{}', vc '{}' will be skipped because it has a path '{}'" - + " which is not indexed or does not have the supported language. " - + "Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", + + " which is not indexed or does not have the supported language. " + VERIFY_SONARPROJECTPROPERTIES_MESSAGE, doc, line, vc, path); } } else if (!isExcludedLine(line)) { diff --git a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/OpenCoverReportParser.java b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/OpenCoverReportParser.java index 80bb8305288..9364ea3c8db 100644 --- a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/OpenCoverReportParser.java +++ b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/OpenCoverReportParser.java @@ -128,8 +128,8 @@ private void handleSequencePointTag(XmlParserHelper xmlParserHelper) { LOG.trace("OpenCover parser: add hits for file {}, line '{}', visitCount '{}'.", coveredFile, line, visitCount); } else { - LOG.debug("Skipping the file {}, line '{}', visitCount '{}' because file is not indexed or does not have the supported language." - + " Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", + LOG.debug("Skipping the file {}, line '{}', visitCount '{}' because file is not indexed or does not have the supported language. " + + VERIFY_SONARPROJECTPROPERTIES_MESSAGE, coveredFile, line, visitCount); } } else { @@ -165,7 +165,7 @@ private void handleBranchPointTag(XmlParserHelper xmlParserHelper) { coveredFile, line, offset, visitCount); } else { LOG.debug("OpenCover parser: Skipping branch hits for file {}, line '{}', offset '{}', visitCount '{}' because file" + - " is not indexed or does not have the supported language.", + " is not indexed or does not have the supported language. " + VERIFY_SONARPROJECTPROPERTIES_MESSAGE, coveredFile, line, offset, visitCount); } } else { diff --git a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/ScannerFileService.java b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/ScannerFileService.java index 61810691da3..8f65e0c1316 100644 --- a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/ScannerFileService.java +++ b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/ScannerFileService.java @@ -66,16 +66,22 @@ public Optional getAbsolutePath(String deterministicBuildPath) { String foundFile = foundFiles.get(0); LOG.trace("Found indexed file '{}' for '{}' (normalized to '{}').", foundFile, deterministicBuildPath, pathSuffix); return Optional.of(foundFile); + } else if (foundFiles.isEmpty()) { + LOG.debug("The file '{}' is not indexed or does not have the supported language. Will skip this coverage entry. " + + CoverageParser.VERIFY_SONARPROJECTPROPERTIES_MESSAGE, + deterministicBuildPath); + return Optional.empty(); } else { - LOG.debug("Found {} indexed files for '{}' (normalized to '{}'). Will skip this coverage entry." - + " Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", + LOG.debug("Found {} indexed files for '{}' (normalized to '{}'). Will skip this coverage entry. " + + CoverageParser.VERIFY_SONARPROJECTPROPERTIES_MESSAGE, foundFiles.size(), deterministicBuildPath, pathSuffix); return Optional.empty(); } + } else { + LOG.debug("The file '{}' is not indexed or does not have the supported language and does not have deterministic build path. " + + "Will skip this coverage entry. " + CoverageParser.VERIFY_SONARPROJECTPROPERTIES_MESSAGE, + deterministicBuildPath); + return Optional.empty(); } - LOG.debug("The file '{}' is not indexed or does not have the supported language. Will skip this coverage entry. " - + "Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", - deterministicBuildPath); - return Optional.empty(); } } diff --git a/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/OpenCoverReportParserTest.java b/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/OpenCoverReportParserTest.java index e93d680dce4..461bedb5edf 100644 --- a/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/OpenCoverReportParserTest.java +++ b/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/OpenCoverReportParserTest.java @@ -326,10 +326,10 @@ public void branchCoverage_codeFile_unsupportedFile() throws Exception { // these are not ordered "Skipping the file (ID '1', path 'BranchCoverage3296\\Code\\ValueProvider.cs', NO INDEXED PATH), line '5', visitCount '1' because file is not indexed or does not have the supported language. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", "Skipping the file (ID '2', path 'BranchCoverage3296\\Code\\ValueProvider.cs', NO INDEXED PATH), line '5', visitCount '1' because file is not indexed or does not have the supported language. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", - "OpenCover parser: Skipping branch hits for file (ID '2', path 'BranchCoverage3296\\Code\\ValueProvider.cs', NO INDEXED PATH), line '5', offset '1', visitCount '1' because file is not indexed or does not have the supported language.", - "OpenCover parser: Skipping branch hits for file (ID '2', path 'BranchCoverage3296\\Code\\ValueProvider.cs', NO INDEXED PATH), line '5', offset '1', visitCount '0' because file is not indexed or does not have the supported language.", - "OpenCover parser: Skipping branch hits for file (ID '1', path 'BranchCoverage3296\\Code\\ValueProvider.cs', NO INDEXED PATH), line '5', offset '1', visitCount '0' because file is not indexed or does not have the supported language.", - "OpenCover parser: Skipping branch hits for file (ID '1', path 'BranchCoverage3296\\Code\\ValueProvider.cs', NO INDEXED PATH), line '5', offset '1', visitCount '1' because file is not indexed or does not have the supported language."); + "OpenCover parser: Skipping branch hits for file (ID '2', path 'BranchCoverage3296\\Code\\ValueProvider.cs', NO INDEXED PATH), line '5', offset '1', visitCount '1' because file is not indexed or does not have the supported language. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", + "OpenCover parser: Skipping branch hits for file (ID '2', path 'BranchCoverage3296\\Code\\ValueProvider.cs', NO INDEXED PATH), line '5', offset '1', visitCount '0' because file is not indexed or does not have the supported language. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", + "OpenCover parser: Skipping branch hits for file (ID '1', path 'BranchCoverage3296\\Code\\ValueProvider.cs', NO INDEXED PATH), line '5', offset '1', visitCount '0' because file is not indexed or does not have the supported language. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.", + "OpenCover parser: Skipping branch hits for file (ID '1', path 'BranchCoverage3296\\Code\\ValueProvider.cs', NO INDEXED PATH), line '5', offset '1', visitCount '1' because file is not indexed or does not have the supported language. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties."); } @Test diff --git a/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/ScannerFileServiceTest.java b/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/ScannerFileServiceTest.java index 6fb3652a9e4..acb2459dc90 100644 --- a/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/ScannerFileServiceTest.java +++ b/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/ScannerFileServiceTest.java @@ -159,7 +159,8 @@ public void getAbsolutePath_when_filesystem_returns_empty_returns_empty() { // assert assertThat(result).isEmpty(); - assertThat(logTester.logs(Level.DEBUG)).containsExactly("Found 0 indexed files for '/_/some/path/file.cs' (normalized to 'some/path/file.cs'). Will skip this coverage entry. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties."); + assertThat(logTester.logs(Level.DEBUG)).containsExactly("The file '/_/some/path/file.cs' is not indexed or does not have the " + + "supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties."); } @Test @@ -199,9 +200,9 @@ public void getAbsolutePath_with_no_deterministic_path_in_windows_path_returns_e verify(fs, never()).predicates(); assertThat(logTester.logs(Level.TRACE)).isEmpty(); assertThat(logTester.logs(Level.DEBUG)).hasSize(1); - assertThat(logTester.logs(Level.DEBUG).get(0)).isEqualTo( - "The file 'C:\\_\\some\\path\\file.cs' is not indexed or does not have the supported language." - + " Will skip this coverage entry. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties."); + assertThat(logTester.logs(Level.DEBUG).get(0)).isEqualTo("The file 'C:\\_\\some\\path\\file.cs' is not indexed or " + + "does not have the supported language and does not have deterministic build path. " + + "Will skip this coverage entry. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties."); } @Test From 70cf878f6cd3a92257be08f5242cc77b50140b05 Mon Sep 17 00:00:00 2001 From: Tim Pohlmann Date: Fri, 2 Aug 2024 17:38:33 +0200 Subject: [PATCH 3/3] Review 2 --- .../org/sonar/plugins/dotnet/tests/ScannerFileService.java | 2 +- .../sonar/plugins/dotnet/tests/ScannerFileServiceTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/ScannerFileService.java b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/ScannerFileService.java index 8f65e0c1316..271f7d1d40d 100644 --- a/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/ScannerFileService.java +++ b/sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/ScannerFileService.java @@ -78,7 +78,7 @@ public Optional getAbsolutePath(String deterministicBuildPath) { return Optional.empty(); } } else { - LOG.debug("The file '{}' is not indexed or does not have the supported language and does not have deterministic build path. " + LOG.debug("The file '{}' does not have a deterministic build path and is either not indexed or does not have a supported language. " + "Will skip this coverage entry. " + CoverageParser.VERIFY_SONARPROJECTPROPERTIES_MESSAGE, deterministicBuildPath); return Optional.empty(); diff --git a/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/ScannerFileServiceTest.java b/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/ScannerFileServiceTest.java index acb2459dc90..9995ab2c63e 100644 --- a/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/ScannerFileServiceTest.java +++ b/sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/ScannerFileServiceTest.java @@ -200,8 +200,8 @@ public void getAbsolutePath_with_no_deterministic_path_in_windows_path_returns_e verify(fs, never()).predicates(); assertThat(logTester.logs(Level.TRACE)).isEmpty(); assertThat(logTester.logs(Level.DEBUG)).hasSize(1); - assertThat(logTester.logs(Level.DEBUG).get(0)).isEqualTo("The file 'C:\\_\\some\\path\\file.cs' is not indexed or " - + "does not have the supported language and does not have deterministic build path. " + assertThat(logTester.logs(Level.DEBUG).get(0)).isEqualTo("The file 'C:\\_\\some\\path\\file.cs' " + + "does not have a deterministic build path and is either not indexed or does not have a supported language. " + "Will skip this coverage entry. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties."); }