Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable code coverage in sonarqube since 6.2

Since we updated to SonarQube 6.2 it seems code coverage plugin got merged in the core. It shows red flags everywhere and I can’t find how to turn it off, we do not use code coverage.

like image 731
Côme Chilliet Avatar asked Feb 22 '17 10:02

Côme Chilliet


People also ask

Does SonarQube give code coverage?

SonarQube measures code quality based on different metrics. The most important metric is the code coverage metric. In this case, no tests have been written, which means you have no code coverage. The cool thing about SonarQube is that it indicates the number of lines that aren't covered by tests.

What is SonarQube coverage percentage?

Test coverage reports describe the percentage of your code that has been tested by your test suite during a build. This differs from test execution reports, which describe which tests within your test suite have been run during a build.


1 Answers

You don't specify what language(s) you're analyzing. I'll assume Java and/or JavaScript. Starting from 6.2, SonarQube supports "force coverage to 0", which marks as uncovered executable lines in files that don't show up in any coverage reports. (That's assuming the underlying code analyzers support the feature, and Java and JavaScript already do.) The purpose is to have a more accurate picture of what's missing when you actually are using unit tests. Without this feature, it's impossible to tell whether a file that's omitted from coverage reports is missing because it has no executable code or because there are no tests on it - even when there should be.

Since you're not using unit tests (really?) you can exclude all the source files in your project from coverage calculations via the UI: Administration > Analysis Scope > Coverage Exclusions. A pattern value of **/*.* ought to do it for you.

like image 77
G. Ann - SonarSource Team Avatar answered Sep 28 '22 10:09

G. Ann - SonarSource Team