Quality gate in PR bot is not showing coverage and duplications for few PRs

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    9.2

  • what are you trying to achieve
    I am expecting to receive all quality gate for all PR commits. But for few of the PRs it is showing “No duplication information” and “No coverage information”.
    But this is wrong, even if there are no duplications, the quality gate should show 0.0% duplications, like it is showing for few of the PRs. The same PR checker is run for all PRs, why it is behaving differently for them?

  • what have you tried so far to achieve this
    Sonarqube support said below is the difference in git fetch.

git fetch --tags --progress – git@github.com:acquia/is-kubernetes.git +refs/heads/:refs/remotes/origin/ # timeout=10
#This is working

vs

git fetch --no-tags --progress – git@github.com:acquia/is-kubernetes.git +refs/pull/541/head:refs/remotes/origin/PR-541 # timeout=10
This is not working.

But I still don’t understand why this is happening, we have same jenkinsfile for all PRs. Please help if you know about the issue.

Hi,

Welcome to the community!

How many changed lines do the PRs in question have? Below 20 changed lines, coverage and duplications are ignored by default. The thinking is that with such small change sets, it can sometimes require far more effort than it’s worth to achieve a coverage threshold. (TBH, I don’t remember why Duplications is included in this.)

We introduced the ability to toggle that feature off in 8.9. You’ll find it at Administration → General → Quality Gate

 
HTH,
Ann

Hi Ann,

We have more than 20 lines of changes in these affected PRs. So it is not related to number of code changes.

Best Regards,
Sanjipta Behera

Hi,

Would you mind sharing some screenshots of the Quality Gate in question, of your PR homepage, and of your PR code page?

 
Ann

Hi Ann,

Please find below PR screenshots, both working and not working. PR code page I cannot share unfortunately because they are private git repos of my organisation.

Thanks and Regards,
Sanjipta Behera


Hi,

I was hoping to see the conditions in your Quality Gate. But okay. Returning to your OP:

For these projects/PRs, does your build/analysis include a coverage report? IIRC, you get “-” (versus “0.0%”) when you don’t provide any coverage reports.

 
Ann

Hey Ann,

The “No coverage information” status looks reasonable as this repo mostly contains terraform code and we don’t upload any sort of coverage report for them. But the duplication report should ideally show the details.

Sanjipta Behera

Hi,

Looking at our internal test server, it looks like we just don’t compute duplications on Terraform.

Aaand… looking at a Terraform file, I can see that it’s mainly strings and punctuation. So it makes sense that we wouldn’t calculate duplications on Terraform, since our duplication detection algorithm ignores string values.

 
HTH,
Ann

HI Ann,

If that was the case, then none of the PRs should give duplication report. But if you check the screenshots attached, some of the PRs give the duplication report. Also as far as I remember, after sonarqube 9.2, terraform and cloudformation scan was added.

Regards,
Sanjipta Behera

Hi Sanjipta,

Do those other projects contain other languages in addition to Terraform?

 
Ann

Hi Ann,

These example(both working and not working) are from the same repo and same PR check job.

Thanks,
Sanjipta Behera

Hi Sanjipta,

Can you check the languages of the files in the PRs? I’m guessing the one without duplications has only changed Terraform files, and the one with has changed files of other languages.

 
Ann

Hi Ann,

I checked again, it looks like there is no such observations.
Duplication showing PR- Has both Terraform and yaml changes
Duplication not showing PR- Has yaml changes.

Thanks and Regards,
Sanjipta Behera

Hi Sanjipta,

It looks like we’ve been a bit inconsistent here. I wouldn’t expect duplications to be computed on YAML either, since it’s again basically strings and punctuation. However, I’m looking at an internal testing instance with 15 projects that include YAML. They all have 0.0% duplications at the project level. So it looks like we “calculate” 0% duplications for YAML, while for Terraform we don’t do a calculation at all.

As you’ve experienced, this inconsistency can be confusing, so I’m going to raise the point internally.

 
Ann

Yes Ann,

I understand. My point was even if it was 0.0. %, it should reflect that. But in “Not working” case it is showing “No duplication information”, which gives a bad glimpse as if something is broken at scanning side.

So do you know, what to do to get duplication information even if they are 0.0%?

Thanks and Regards,
Sanjipta Behera