I am using SonarQube MSBuild runner to analyze C# code and so far its good. Now we have decided to cover JavaScript code coverage in the same solution.
LCOV
TN:
SF:D:\build2018\cc52cb33e083fc9\src\Web.Spa\EmpApp\app\app.component.js
FN:12,(anonymous_1)
FN:13,AppComponent
FNF:2
FNH:0
FNDA:0,(anonymous_1)
FNDA:0,AppComponent
DA:2,0
DA:3,0
DA:4,0
DA:5,0
DA:6,0
DA:7,0
DA:8,0
DA:9,0
DA:10,0
DA:11,0
DA:12,0
DA:13,1
DA:15,0
DA:17,0
DA:24,0
LF:15
LH:1
BRF:0
BRH:0
end_of_record
We have created JavaScript test coverage report using Karma coverage plugin and generated lcov format.
When I tried to upload the lcov report we are getting an error
Could not resolve 114 file paths in
[D:\build2018\cc52cb33e083fc9\src\Web.Spa\coverage\report\lcov.info], first unresolved path: D:\build2018\cc52cb33e083fc9\src\Web.Spa\EmpApp\app\app.component.js
Here is the analysis
[09:33:43][Step 13/13] INFO: 10/10 source files have been analyzed
[09:33:43][Step 13/13] INFO: Sensor Embedded CSS Analyzer Sensor [css]
[09:33:43][Step 13/13] INFO: 58 source files to be analyzed
[09:33:43][Step 13/13] INFO: Sensor Embedded CSS Analyzer Sensor [css] (done) | time=84ms
[09:33:43][Step 13/13] INFO: 58/58 source files have been analyzed
[09:33:43][Step 13/13] INFO: Sensor JavaScript Squid Sensor [javascript]
[09:33:43][Step 13/13] INFO: 256 source files to be analyzed
[09:33:53][Step 13/13] INFO: 234/256 files analyzed, current file: D:\build2018\cc52cb33e083fc9\src\Web.Spa\Scripts\jquery-1.9.1.js
[09:33:59][Step 13/13] INFO: 256/256 source files have been analyzed
[09:33:59][Step 13/13] INFO: Test Coverage Sensor is started
[09:33:59][Step 13/13] INFO: Analysing [D:\build2018\cc52cb33e083fc9\src\Web.Spa\coverage\report\lcov.info]
[09:33:59][Step 13/13] WARN: Could not resolve 114 file paths in
[D:\build2018\cc52cb33e083fc9\src\Web.Spa\coverage\report\lcov.info], first unresolved path: D:\build2018\cc52cb33e083fc9\src\Web.Spa\EmpApp\app\app.component.js
[09:33:59][Step 13/13] INFO: Sensor JavaScript Squid Sensor [javascript] (done) | time=16012ms
I have asked same Question in Stackoverflow but no answer
I am using MSBuild Runner and here is the command I pass to import test coverage
$sonar=%system.MSBUILD_SONARQUBE_RUNNER%\MSBuild.SonarQube.Runner.exe begin /k:"com.mycomp:MyApp" /n:"ProjectName" /v:"%build.number%" /d:sonar.cs.dotcover.reportsPaths="$coverageReport" /d:sonar.cs.nunit.reportsPaths="$testResults" /d:sonar.exclusions="EmpApp/Scripts/**, EmpApp/libs/**" /d:sonar.javascript.lcov.reportPaths="coverage/report/lcov.info" --debug
Update 1
I have ignored them with exclusions and here is some more information with debug. It seems it can index but unable to find using backward slash?
[11:29:11][Step 13/13] 11:29:11.598 DEBUG: 'EmpApp/App/app.component.js' indexed with language 'js'
[11:29:28][Step 13/13] 11:29:28.173 DEBUG: 'EmpApp/App/app.component.js' generated metadata with charset 'UTF-8'
[11:29:28][Step 13/13] 11:29:29.038 WARN: Could not resolve 114 file paths in [E:\a03\work\bb52cb33e083fc9\src\Web.Spa\coverage\report\lcov.info], first unresolved path: E:\a03\work\bb52cb33e083fc9\src\Web.Spa\EmpApp\app\app.component.js
Update 2: Does not work with / as well
Now I am getting same WARN: Could not resolve 114 file paths in [E:\a04\work\bb52cb33e083fc9\src\Web.Spa\coverage\report\lcov.info], first unresolved path: E:/a04/work/bb52cb33e083fc9/src/Web.Spa/EmpApp/app/app.component.js
Update 3:
After verifying the sonarjs source code, the below function pushes to unresolved.
@CheckForNull
private FileData loadCurrentFileData(final Map<InputFile, FileData> files, String line) {
// SF:<absolute path to the source file>
String filePath = line.substring(SF.length());
FileData fileData = null;
// some tools (like Istanbul, Karma) provide relative paths, so let's consider them relative to project directory
InputFile inputFile = context.fileSystem().inputFile(context.fileSystem().predicates().hasPath(filePath));
if (inputFile != null) {
fileData = files.get(inputFile);
if (fileData == null) {
fileData = new FileData(inputFile);
files.put(inputFile, fileData);
}
} else {
unresolvedPaths.add(filePath);
}
return fileData;
}