问题
I want to provide a coverage report for a ui project.
The project mainly consists of .ts files which 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 cov value.
Is there a way / pattern to instruct sonarqube to:
a) perform code analysis on .ts files
b) ignore all .ts files when generating coverage report?
回答1:
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
来源:https://stackoverflow.com/questions/48378528/sonarqube-ignore-files-during-coverage-report