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?
To exclude test code from the code coverage results and only include application code, add the ExcludeFromCodeCoverageAttribute attribute to your test class.
Exclusions and inclusions can be set either in the UI or by key. In the UI the settings are under: Your Organization > Your Project > Administration > General Settings > Analysis Scope > Files.
You can have SonarQube ignore issues on certain components and against certain coding rules. Go to Administration > General Settings > Analysis Scope > Issues. Note that the properties below can only be set through the web interface because they are multi-valued.
In Java, we can exclude Sonar checks using the built-in @SuppressWarnings annotation. This works exactly the same way as suppressing compiler warnings. All we have to do is specify the rule identifier, in this case java:S106.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With