Code coverage failing in SonarQube Cloud even though it's less than 20 lines

Hello Sonar Community,

I’m having an issue in SonarQube Cloud with the code coverage for my PR.

I have created a PR with very few lines (11 to be exact), but the code coverage requirement is still being triggered and failing the quality gate:

If I check the Administration/Quality Gates section of my project I can see that the “Ignore duplication and coverage on small changes” is turned on.

I don’t want the code coverage requirement to be applied on PRs with less than 20 lines, and it looks to me that it shouldn’t be based on the configuration. Any clues on why the code coverage requirement is still being triggered?

Here is my SonarCloudPrepare task from my yaml PR pipeline in Azure DevOps:

    - task: SonarCloudPrepare@4

      inputs:

        SonarCloud: 'SonarCloud'

        organization: 'xxx'

        scannerMode: 'dotnet'

        configMode: 'manual'

        projectKey: 'xxx'

        projectName: 'xxx'

        sources: 'xxx'

        extraProperties: |

          sonar.sarifReportPaths=xxx

          sonar.qualitygate.wait=true

          sonar.projectBaseDir=xxx

          sonar.projectVersion=$(Build.BuildId)

          sonar.exclusions=xxx

          sonar.coverage.exclusions=xxx

          sonar.pullrequest.key=$(System.PullRequest.PullRequestId)

          sonar.pullrequest.branch=$(System.PullRequest.SourceBranch)

          sonar.pullrequest.base=$(System.PullRequest.TargetBranch)

          sonar.coverageReportPaths=xxx
  • ALM used:Azure DevOps
  • CI system used:Azure DevOps

Thank you in advance!

Best regards,
Anna Flodkvist

Hi Anna,

Welcome to the community!

Could you check with an org admin to see if this option has been turned back on at a higher level? I would expect your project-level config to override that, but things don’t always work like I expect them to.

 
Ann

Hi Ann,

Thank you for your quick response!

I am an org admin and this is what shows when I go to Administration → Quality gate settings:


So it is also set to ignore coverage when there are fewer than 20 lines.

Any other ideas on what might be causing this issue?

I don’t think this is relevant but the SonarCloudPrepare task used to have this extraProperty:

sonar.scm.use.blame.algorithm=GIT_FILES_BLAME

if that could cause any issue related to this.

Best regards,
Anna

Hi Anna,

Thanks for the screenshot.

That property you’ve mentioned shouldn’t be relevant here. It’s related to how CI-side analysis runs, and this is about the server-side processing of the analysis report.

And since this is server-side, I’m not even going to ask for your analysis logs. Instead, I’m going to flag this for the folks with access to back-end logs.

 
Ann

Our team has the “Ignore duplication and coverage on small changes” flag turned on in our projects.

However, it doesn’t seem to be observed in our Javascript project. Here’s a PR from today:

Am I misunderstanding something about this flag? I expected the “Coverage” metric to be ignored for this PR with only 3 new lines of code (actually on github it’s +5 and -7 lines). Thanks!

Hello all,

We have an issue with our golang project, where small changes are still considered in the new coverage calculations, although we have the following flag enabled.

Here is the branch where the gate is failing due to small change not covered.

As you can see there 2 lines changed, and the Gate fails because of 0 coverage. Can your team have a look at this?

Thanks in advance!

Hi all,

I’ve combined your threads because they’re all about the same thing.

I’ve declared an incident for this since it appears to be wider-spread than it initially seemed. However, it’s already the weekend for the relevant engineers, so they won’t pick this up until it’s Monday morning in Europe.

In the meantime, I can only apologize for the inconvenience.

 
Ann

Hi all,

We’ve deployed a fix for this, so you should be good now. Apologies for the trouble.

 
Ann

2 Likes