We are trying to make a SonarQube code coverage report for our angular application. We have used Karma to generate a code coverage report and import it into SonarQube analyzer.
The SonarQube already has C# coverage for our project, now we want to add JavaScript code coverage as well.
Teamcity calls, Karma and it creates a code coverage and put the lcov file and report files into srcPlanning.SpaCoverage
eport
folder.
LCOV File
TN:
SF:E:/a03/work/bb52cb33e083fc9/src/Planning.Spa/Offer/app/app.component.js
FN:5,(anonymous_1)
FN:6,AppComponent
FN:8,(anonymous_3)
FN:9,(anonymous_4)
Teamcity has the following MSBuild parameters configured to generate a C# code coverage and JavaScript coverage.
SonarQube MSBuild Configuration
$sonar=%system.MSBUILD_SONARQUBE_RUNNER%MSBuild.SonarQube.Runner.exe
begin /k:"com.test:Test" /n:"MyProject" /v:"%build.number%"
/d:sonar.cs.dotcover.reportsPaths="$coverageReport"
/d:sonar.cs.nunit.reportsPaths="$testResults"
/d:sonar.javascript.lcov.reportPaths="coverage
eportlcov.info"
While running SonarQube analysis we get the following error
[14:35:56][Step 13/13] 14:35:56.243 WARN: Could not resolve 114 file paths in
[E:a03workb52cb33e083fc9srcPlanning.Spacoverage
eportlcov.info],
first unresolved path: E:/a03/work/bb52cb33e083fc9/src/Planning.Spa/Offer/app/app.component.js
We don't find any example for running both C# and JavaScript using MSBuild runner. Also could not find any answer related to this Could not resolve file paths
We are trying to make it work for last 2 weeks and could not find any useful example or answer. Similar questions were unanswered here and here
Update Sonar Analysis with more info
[14:35:43][Step 13/13] 14:35:43.751 INFO: Base dir: E:a03workb52cb33e083fc9srcPlanning.Spa
[14:35:43][Step 13/13] 14:35:43.751 INFO: Working dir: E:a03workb52cb33e083fc9.sonarqubeout.sonarcom.Planning_com.Planning_6CC487F0-8283-4351-9B65-F1698B1B804E
[14:35:43][Step 13/13] 14:35:43.755 INFO: Source paths: Offer/App/app.component.js, Offer/App/app.component.js.map, Offer/App/Common/order-by.pipe.js
[14:35:43][Step 13/13] 14:35:43.755 INFO: Source encoding: UTF-8, default locale: en_US
[14:35:43][Step 13/13] 14:35:43.755 INFO: Index files
[14:35:43][Step 13/13] 14:35:43.756 INFO: Excluded sources:
[14:35:43][Step 13/13] 14:35:43.756 INFO: Offer/Scripts/**
[14:35:43][Step 13/13] 14:35:43.756 INFO: Offer/libs/**
[14:35:43][Step 13/13] 14:35:43.757 INFO: Analyzer working directory contains 5 .pb file(s)
[14:35:43][Step 13/13] 14:35:43.898 DEBUG: 'Offer/App/app.component.js' indexed with language 'js'
[14:35:43][Step 13/13] 14:35:43.898 DEBUG: 'Offer/App/app.component.js.map' indexed with language 'null'
[14:35:43][Step 13/13] 14:35:43.953 INFO: 1010 files indexed
[14:35:43][Step 13/13] 14:35:43.953 INFO: 111 files ignored because of inclusion/exclusion patterns
[14:35:43][Step 13/13] 14:35:43.953 INFO: Quality profile for cs: Sonar C# Planning SIM
[14:35:43][Step 13/13] 14:35:43.953 INFO: Quality profile for js: Sonar way
[14:35:43][Step 13/13] 14:35:43.979 DEBUG: 'JavaSquidSensor' skipped because there is no related file in current project
[14:35:43][Step 13/13] 14:35:43.980 DEBUG: Sensors : CSS Analyzer Sensor -> Embedded CSS Analyzer Sensor -> JavaScript Squid Sensor -> C# -> SonarJavaXmlFileSensor -> Web -> XML Sensor
[14:35:43][Step 13/13] 14:35:43.980 INFO: Sensor CSS Analyzer Sensor [css]
[14:35:51][Step 13/13] 14:35:51.314 INFO: Sensor JavaScript Squid Sensor [javascript]
[14:35:51][Step 13/13] 14:35:51.316 INFO: 57/57 source files have been analyzed
[14:35:51][Step 13/13] 14:35:51.344 INFO: 153 source files to be analyzed
[14:35:55][Step 13/13] 14:35:55.145 DEBUG: 'Offer/App/app.component.js' generated metadata with charset 'UTF-8'
[14:35:56][Step 13/13] 14:35:56.243 WARN: Could not resolve 114 file paths in [E:a03workb52cb33e083fc9srcPlanning.Spacoverage
eportlcov.info], first unresolved path: E:/a03/work/bb52cb33e083fc9/src/Planning.Spa/Offer/app/app.component.js
[14:35:56][Step 13/13] 14:35:56.237 INFO: Test Coverage Sensor is started
[14:35:56][Step 13/13] 14:35:56.239 INFO: Analysing [E:a03workb52cb33e083fc9srcPlanning.Spacoverage
eportlcov.info]
[14:35:56][Step 13/13] 14:35:56.243 INFO: Sensor JavaScript Squid Sensor [javascript] (done) | time=4929ms
[14:35:56][Step 13/13] 14:35:56.243 INFO: Sensor C# [csharp]
Update SonarJS actual java code
https://github.com/SonarSource/SonarJS/blob/3.2.0.5506/sonar-javascript-plugin/src/main/java/org/sonar/plugins/javascript/lcov/LCOVParser.java#L146
Somehow sonarqube ignores my absolute path from its file system and sets inputFile as null
InputFile inputFile = context.fileSystem().inputFile(context.fileSystem().predicates().hasPath(filePath));
I have tried with Gulp to modify absolute to relative and changed
with /
. But nothing works.
SonarQube Version 6.5.0.27846
SonarJs Version 3.2.0.5506
See Question&Answers more detail:
os