Sonarqube New Code Coverage Quality Gate on Low # of Testable Code

Must-share information:

  • Sonarqube Enterprise v8.8
  • Jacoco v8.6
  • Android, Kotlin, Java project

We have a project that is doing branch analysis on merge requests and has a quality gate on new code coverage that fails if the new code coverage is below 65% for any given branch analysis. There is a branch that has 30 lines of new code, but only 2 lines of testable code (the other 28 lines are a new test class that adds coverage for code that existed prior to the merge request).

Some questions we have are:

Hi,

First, your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

8.8 → 8.9.2 → 9.1 (last step optional)

Regarding your actual question, you’re interested in this ticket:

SONAR-11283 - Quality Gate should not fail when too few lines to cover

 
Ann

We are also running into a similar issue with the New Code and Lines to Cover being small. We added 25 lines of code, mostly tests and documentation. There’s only 1 actual line to cover, which the team feels would not make a useful test.

You mentioned SONAR-11283, but that feature request is three years old. Do you have any insight on when the issue will be prioritized or resolved?

Hi @chrism.

Welcome to the community!

In fact the request is even older, since it was originally raised in this earlier ticket which was eventually closed as a duplicate:

SONAR-10231 - Refine metric used by Quality Gate fudge factor for coverage

When will it be addressed? I wish I knew.

 
:woman_shrugging:
Ann

@ganncamp Thank you for the welcome and providing that update. Can I upvote the feature or do anything to try and help prioritize that feature?

Hi,

I believe you should be able to sign up for a Jira account & upvote the ticket.

 
Ann