Skip to content

Commit 225ea37

Browse files
committed
Review 1
1 parent 7960096 commit 225ea37

File tree

7 files changed

+23
-20
lines changed

7 files changed

+23
-20
lines changed

sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/CoverageParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@
2424

2525
@FunctionalInterface
2626
public interface CoverageParser extends BiConsumer<File, Coverage> {
27+
public static final String VERIFY_SONARPROJECTPROPERTIES_MESSAGE = "Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.";
2728
}

sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/DotCoverReportParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void parse() {
7171
collectCoverage(fileCanonicalPath, contents);
7272
} else {
7373
LOG.debug("Skipping the import of dotCover code coverage for file '{}' because it is not indexed or"
74-
+ " does not have the supported language. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.",
74+
+ " does not have the supported language. " + VERIFY_SONARPROJECTPROPERTIES_MESSAGE,
7575
fileCanonicalPath);
7676
}
7777
}

sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/NCover3ReportParser.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ private void handleSegmentPointTag(XmlParserHelper xmlParserHelper) {
129129
coverage.addHits(path, line, vc);
130130
} else {
131131
LOG.debug("NCover3 doc '{}', line '{}', vc '{}' will be skipped because it has a path '{}'"
132-
+ " which is not indexed or does not have the supported language. "
133-
+ "Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.",
132+
+ " which is not indexed or does not have the supported language. " + VERIFY_SONARPROJECTPROPERTIES_MESSAGE,
134133
doc, line, vc, path);
135134
}
136135
} else if (!isExcludedLine(line)) {

sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/OpenCoverReportParser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ private void handleSequencePointTag(XmlParserHelper xmlParserHelper) {
128128
LOG.trace("OpenCover parser: add hits for file {}, line '{}', visitCount '{}'.",
129129
coveredFile, line, visitCount);
130130
} else {
131-
LOG.debug("Skipping the file {}, line '{}', visitCount '{}' because file is not indexed or does not have the supported language."
132-
+ " Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.",
131+
LOG.debug("Skipping the file {}, line '{}', visitCount '{}' because file is not indexed or does not have the supported language. "
132+
+ VERIFY_SONARPROJECTPROPERTIES_MESSAGE,
133133
coveredFile, line, visitCount);
134134
}
135135
} else {
@@ -165,7 +165,7 @@ private void handleBranchPointTag(XmlParserHelper xmlParserHelper) {
165165
coveredFile, line, offset, visitCount);
166166
} else {
167167
LOG.debug("OpenCover parser: Skipping branch hits for file {}, line '{}', offset '{}', visitCount '{}' because file" +
168-
" is not indexed or does not have the supported language.",
168+
" is not indexed or does not have the supported language. " + VERIFY_SONARPROJECTPROPERTIES_MESSAGE,
169169
coveredFile, line, offset, visitCount);
170170
}
171171
} else {

sonar-dotnet-shared-library/src/main/java/org/sonar/plugins/dotnet/tests/ScannerFileService.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,20 @@ public Optional<String> getAbsolutePath(String deterministicBuildPath) {
6666
String foundFile = foundFiles.get(0);
6767
LOG.trace("Found indexed file '{}' for '{}' (normalized to '{}').", foundFile, deterministicBuildPath, pathSuffix);
6868
return Optional.of(foundFile);
69+
} else if (foundFiles.size() == 0) {
70+
LOG.debug("The file '{}' is not indexed or does not have the supported language. Will skip this coverage entry. "
71+
+ CoverageParser.VERIFY_SONARPROJECTPROPERTIES_MESSAGE,
72+
deterministicBuildPath);
73+
return Optional.empty();
6974
} else {
70-
LOG.debug("Found {} indexed files for '{}' (normalized to '{}'). Will skip this coverage entry."
71-
+ " Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.",
75+
LOG.debug("Found {} indexed files for '{}' (normalized to '{}'). Will skip this coverage entry. "
76+
+ CoverageParser.VERIFY_SONARPROJECTPROPERTIES_MESSAGE,
7277
foundFiles.size(), deterministicBuildPath, pathSuffix);
7378
return Optional.empty();
7479
}
80+
} else {
81+
LOG.debug("The file '{}' does not have deterministic build path. Will skip this coverage entry.", deterministicBuildPath);
82+
return Optional.empty();
7583
}
76-
LOG.debug("The file '{}' is not indexed or does not have the supported language. Will skip this coverage entry. "
77-
+ "Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.",
78-
deterministicBuildPath);
79-
return Optional.empty();
8084
}
8185
}

sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/OpenCoverReportParserTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,10 @@ public void branchCoverage_codeFile_unsupportedFile() throws Exception {
326326
// these are not ordered
327327
"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.",
328328
"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.",
329-
"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.",
330-
"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.",
331-
"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.",
332-
"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.");
329+
"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.",
330+
"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.",
331+
"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.",
332+
"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.");
333333
}
334334

335335
@Test

sonar-dotnet-shared-library/src/test/java/org/sonar/plugins/dotnet/tests/ScannerFileServiceTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ public void getAbsolutePath_when_filesystem_returns_empty_returns_empty() {
159159

160160
// assert
161161
assertThat(result).isEmpty();
162-
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.");
162+
assertThat(logTester.logs(Level.DEBUG)).containsExactly("The file '/_/some/path/file.cs' is not indexed or does not have the "
163+
+ "supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.");
163164
}
164165

165166
@Test
@@ -199,9 +200,7 @@ public void getAbsolutePath_with_no_deterministic_path_in_windows_path_returns_e
199200
verify(fs, never()).predicates();
200201
assertThat(logTester.logs(Level.TRACE)).isEmpty();
201202
assertThat(logTester.logs(Level.DEBUG)).hasSize(1);
202-
assertThat(logTester.logs(Level.DEBUG).get(0)).isEqualTo(
203-
"The file 'C:\\_\\some\\path\\file.cs' is not indexed or does not have the supported language."
204-
+ " Will skip this coverage entry. Verify sonar.sources in .sonarqube\\out\\sonar-project.properties.");
203+
assertThat(logTester.logs(Level.DEBUG).get(0)).isEqualTo("The file 'C:\\_\\some\\path\\file.cs' does not have deterministic build path. Will skip this coverage entry.");
205204
}
206205

207206
@Test

0 commit comments

Comments
 (0)