pkaramol
pkaramol

Reputation: 19312

Ignore files during coverage report

I want to provide a coverage report for a ui project.

The project mainly consists of .ts files which are under version control.

The gulp command used to check coverage, generates .js files which are then checked for coverage (and a coverage report that reports only on those files).

The .js files are not under version control and, when produced are intermingled with the .ts files (i.e., wherever there is a .ts file, a .js file will be generated next to it).

This creates the following issue:

When sonarqube generates coverage report, to my report above (pointed to by sonar.javascript.lcov.reportPaths), the .ts files are added (which of course have 0.0% coverage) and this breaks the actual coverage value.

Is there a way / pattern to instruct sonarqube to:

  1. perform code analysis on .ts files

  2. ignore all .ts files when generating coverage report?

Upvotes: 5

Views: 15904

Answers (1)

pkaramol
pkaramol

Reputation: 19312

Just found out in the project's documentation.

Ignore Code Coverage

You can prevent some files from being taken into account for code coverage by unit tests.

To do so, go to Administration > General Settings > Analysis Scope > Code Coverage and set the Coverage Exclusions property

There is also the following directive that can be used in the sonar-project.properties file:

sonar.coverage.exclusions

Upvotes: 20

Related Questions