- I am using SonarScanner 4.7.0.2747
- I am trying to run sonar scanner on angular application and push output to Sonarqube.
I created a sample angular application via the Angular CLI and configured karma for coverage report. When I run the ng test command, test are run as expected and coverage folder is created.
Now I try to run sonar scanner to analyze the source code and push the output to Sonrqube. I run the below command to do it.
sonar-scanner -Dsonar.projectKey=TestXpsSpaSonar -Dsonar.projectVersion=1.0.0 -Dsonar.host.url=http://sonarqub:8081 -Dsonar.login=**************** -Dsonar.projectBaseDir=.\src -Dsonar.javascript.lcov.reportPaths=C:\Users\narayanasamys\Workspace\Angular\xpssonar\coverage\lcov.info -Dsonar.typescript.tsconfigPath=C:\Users\narayanasamys\Workspace\Angular\xpssonar\tsconfig.json
The source files are getting analyzed based on passed in tsconfig.json but the analysis of lcov.info fails resulting in zero coverage in Sonarqube for the project.
INFO: Analysing [C:\Users\narayanasamys\Workspace\Angular\xpssonar\coverage\lcov.info]
WARN: Could not resolve 3 file paths in [C:\Users\narayanasamys\Workspace\Angular\xpssonar\coverage\lcov.info]
WARN: First unresolved path: src\polyfills.ts (Run in DEBUG mode to get full list of unresolved paths)
The lcov.info file content looks as below.
TN:
SF:src\polyfills.ts
FNF:0
FNH:0
LF:0
LH:0
BRF:0
BRH:0
end_of_record
TN:
SF:src\test.ts
FNF:0
FNH:0
DA:18,1
DA:25,1
DA:27,1
LF:3
LH:3
BRF:0
BRH:0
end_of_record
TN:
SF:src\app\app.component.ts
FNF:0
FNH:0
DA:8,1
DA:9,3
LF:2
LH:2
BRF:0
BRH:0
end_of_record
Can anyone please let me know why the coverage data is missing ?
Is it because of -Dsonar.projectBaseDir being set to “.\src” ?
Thank you,
S N.