Facing issues while executing sonarqube workflow for javascript/typescript

While executing sonarqube workflow for our JS/TS based application, the quality gates sometimes pass as expected but fails occasionally. We also observed that the code coverage also keeps on fluctuating.
When failing, the reliability quality gate seems to be including coverage folder which is otherwise excluded in sonar-project.properties file.

The attributes in sonar-project.properties is as follows:

sonar.exclusions=coverage/apps/ui/lcov-report/**/*, coverage/apps/ui/components/**/*
sonar.coverage.exclusions=coverage/apps/ui/*, **/*.spec.tsx

Version of SonarQube: 9.7.1

Expected Result: To exclude the coverage folder from getting included in bugs, code smells or duplications.
So far, we have been able to exclude it from code smells and duplications, but it is still getting included while analyzing bugs i.e., reliability. Also, not able to determine why there is a fluctuation in coverage (sometimes coverage gets included and sometimes not).


Welcome to the community!

What I noticed in your properties is that you haven’t specified sonar.sources, leaving it to default to ..

Also cpd and coverage exclusions are subsets of the exclusion functionality. Listing something in sonar.exclusions is enough to exclude it from coverage and duplication (cpd) detection.

Can you try specifying a tighter sonar.sources value and see if the problem persists?


Thank you for the quick response.

I’ll try specifying sonar.sources in sonar properties.

Also, if we include all the cpd and coverage exclusions in sonar.exclusions

sonar.exclusions=coverage/apps/ui/lcov-report/**/*, coverage/apps/ui/components/**/*, coverage/apps/ui/*, **/*.spec.tsx

it might exclude lcov.info file as well since the path for lcov file is coverage/apps/ui/lcov.info

Could you please suggest a workaround in this case.


Your lcov.info file is not a source file and is not expected to be in the source file set.


Hi Ann,
I was able to resolve the issue. Thank you for your suggestions.