Must-share information (formatted with Markdown):
- Sonarqube Community Edition v7.6; SonarScanner 4.6.2.2472
- Scan a monorepo project with multiple sub-projects and include their generated coverage
I have a monorepo project successfully being scanned for static analysis in SQ. Please note, all sub-projects live in the projects
folder, but not all have unit tests.
I also have unit tests being run before scan, and have successfully produced lcov.info
files. Note, these files are 1 per sub-project.
My sonar-project.properties file is as follows:
# Base setup
sonar.projectKey=(key)
sonar.projectName=(name)
sonar.sources=projects
sonar.javascript.lcov.reportPaths=projects/admin2/coverage/lcov.info
sonar.coverage.exclusions=**/karma.conf.js
sonar.log.level=TRACE
I can see in the debug trace for the scanner that file appears to be found (no error), but nothing further seems to happen:
....
11:29:36.107 INFO: Sensor SonarJS Coverage [javascript]
11:29:36.107 INFO: 30/30 source files have been analyzed
11:29:36.108 INFO: Analysing [/builds/zapinfo/frontend/projects/admin2/coverage/lcov.info]
11:29:36.113 INFO: Sensor SonarJS Coverage [javascript] (done) | time=6ms
11:29:36.113 INFO: Sensor Zero Coverage Sensor
11:29:36.290 INFO: Sensor Zero Coverage Sensor (done) | time=176ms
11:29:36.291 INFO: ------------- Run sensors on project
....
An example lcov.info file looks like this:
TN:
SF:projects/admin2/src/polyfills.ts
FNF:0
FNH:0
DA:62,1
DA:63,1
DA:64,1
DA:65,1
DA:71,1
LF:5
LH:5
BRF:0
BRH:0
end_of_record
TN:
SF:projects/admin2/src/test-common.ts
FNF:0
FNH:0
DA:9,1
DA:11,1
DA:20,1
LF:3
LH:3
BRF:0
BRH:0
end_of_record
...(more data)
I can confirm via the index.html generated by the tests that there is in fact coverage happening.
I can’t tell why the coverage is showing as 0%. There are no errors output.