Coverage for imported libraries is getting included in lcov file

We have implemented microfrontend in our angular project that results in ‘Projects’ folder getting created parallel to ‘src’ folder.
src component uses libraries, components from ‘projects’ folder to implement some features.
we have saperate tests and respected lcov files for all modules in ‘projects’ folder plus ‘src’ folder that we are providing in ‘sonar.typescript.lcov.reportPaths’.
Problem is while running the scan for ‘src’ folder, inside lcov file we get entries for ‘projects’ libraries as well, which we need to avoid.
below are the version details for -
SonarQube : 7.9
sonar-scanner: 3.1.0
node: 14.15.0
karma-coverage: 2.0.3
Angular: 12
typescript 4.2.4 (added as dev dependency)

Below is the sonar-project.properties files -

sonar.projectKey=com.myproject
sonar.projectName=MyProject
sonar.projectVersion=1.0

sonar.sourceEncoding=UTF-8

sonar.host.url=http://localhost:9000/
sonar.login=***
sonar.analysis.mode=publish
sonar.issuesReport.console.enable=true
sonar.sources=src,projects
sonar.typescript.lcov.reportPaths=projects/global/coverage/lcov.info,projects/shared/coverage/lcov.info, coverage/lcov.info
sonar.exclusions=**/*.spec.ts,**/*.stub.ts,**/coverage/**
sonar.java.binaries=**/target/classes
sonar.java.libraries=**/target/*.jar
sonar.coverage.exclusions=few-regEx-to-exclude-targetted-files

Folder structure -

Coverage folder for src looks like below -

Any help would be appreciated.

Hi,

First, your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

7.9 → 8.9.3 → 9.1 (last step optional)

You may find the Upgrade Guide and the LTS-to-LTS Upgrade Notes helpful. If you have questions about upgrading, feel free to open a new thread for that here.

Beyond that, it seems that you’ve got a number of extraneous parameters in your sonar-project.properties file:

sonar.analysis.mode=publish - this is long since dropped
sonar.issuesReport.console.enable=true - similarly, long since remove
sonar.java.binaries=**/target/classes - if your project is pure TypeScript, you certainly don’t need this
sonar.java.libraries=**/target/*.jar - you don’t need this either for a TypeScript project

Regarding your actual question, you seem to be complaining that your LCOV report contains the wrong data. SonarQube only reflects the data that shows up in your reports. If the reports have the wrong data, then you’ll need to fix that before it gets to SonarQube.

 
HTH,
Ann