New code coverage quality check passes after rerun?


(Kumar Gaurav) #1

Must-share information:

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension): 7.1
  • what are you trying to achieve: I want New code coverage quality check to fail even after rerun.
  • what have you tried so far to achieve this:
    Dear all,
    I have a project that has zero code coverage and is configured to have a quality gate with new code coverage > 80%. Now I run sonar analysis and it fails because new code coverage is 0. But when I rerun it with no change, it passes (because there is no new code?).
    How do we handle this loop hole?

Thanks a lot
Kumar


(Nicolas Bontoux) #2

Hi Kumar,

Dont call it a loop hole yet :wink: The key information missing at this stage is: what is the value of the Leak Period for this project ? (project setting in SonarQube) The Leak Period will represent from which point on is code considered New.


(Kumar Gaurav) #3

Thanks Nicolas. By loophole I meant loophole in our process because some people could run analysis twice to pass quality checks. :slight_smile:. The leak period (sonar.leak.period) I see is previous_version. I guess its the default one. What is the recommended leak period? And what leak period should we use to avoid the original issue.

Thanks again,
Kumar


(Colin Mueller) #4

Kumar,

What’s the style of the versions you pass to SonarQube?

If, for example, on every build you’re setting a new version that’s being passed to SonarQube…

Build 1: 1.1.0.0
Build 2: 1.1.0.1

your leak period will be between those two builds (since the leak is set to previous_version), and you’ll end up in the circumstance you’re in.

If you pass just the major/minor version, you might have a more usable leak period.

Colin


(Kumar Gaurav) #5

Thanks Colin. Our project is maven based and pom file has version 1.0-SNAPSHOT, we are not setting a new version on every build. So
Build 1: 1.0-SNAPSHOT
Build 2: 1.0-SNAPSHOT

Shouldn’t previous_version work in this case? Also I am bit confused about different leak periods, is there an elaborate explanation somewhere?

Thanks and Regards,
Kumar


(Colin Mueller) #6

Kumar,

Can you check the “Activity” tab of your project? Is it showing a new version entry for every analysis? Let us know if there’s anything interesting in there.

The details in the General settings of a project’s administration tab for sonar.leak.period is the best documentation I know for valid leak period settings.

Colin


(Kumar Gaurav) #7

Thanks Colin. Sorry for delay, was on holidays.

I am including screenshot of activity tab.

This project has zero coverage. The transition from Red to Green that we see in screenshot was purely a rerun.

Any way to avoid that?

Thanks a lot


(G Ann Campbell) #8

Hi Kumar,

Is a coverage report actually submitted to the report? Also, what language are we talking about?

Ann


(Kumar Gaurav) #9

Hi Ann,

I am now trying to reproduce my issue now and can’t. Not sure what happened few days back, before my holidays. History logs in CI are also gone so don’t have much information. May be I should go for holidays more often :smile:
I am using Java. I will come up with more information if I see the issue again.

Thanks a lot,
Kumar