SonarQube vs SonarCloud code coverage mismatch

Hello,

We are migrating our PHP application to use Sonarcloud now. (previously using Sonarqube) and we have noticed that SonarCloud does not show the correct coverage percentage. We are using the same steps for both and we can also see the same output from the sonar-scanner cli, however the percentages are out of whack.

SonarQube:
Screen Shot 2022-05-13 at 1.41.00 pm

SonarCloud:

Screen Shot 2022-05-13 at 1.49.53 pm

Could you please throw some light on what we might be missing here?

Thank you.

  • ALM used (GitHub, Bitbucket Cloud, Azure DevOps)
    Github
  • CI system used (Bitbucket Cloud, Azure DevOps, Travis CI, Circle CI
    Github Actions
  • Scanner command used when applicable (private details masked)
- name: Analyze with SonarCloud
      uses: sonarsource/sonarcloud-github-action@master
      if: ${{ inputs.coverage_file == '' }}
      with:
        args: >
          -Dsonar.organization=${{ env.CI_REPOSITORY_OWNER_SLUG }}
          -Dsonar.projectKey=${{ env.CI_REPOSITORY_OWNER_SLUG }}_${{ env.CI_REPOSITORY_NAME_SLUG }}
          -Dsonar.projectVersion=${{ env.CI_SHA_SHORT }}
          -Dsonar.links.scm=${{ env.GITHUB_SERVER_URL }}/${{ env.GITHUB_REPOSITORY }}
          -Dsonar.links.ci=${{ env.GITHUB_SERVER_URL }}/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}
          -Dsonar.sources=.
  • Languages of the repository
    PHP
  • Only if the SonarCloud project is public, the URL
    • And if you need help with pull request decoration, then the URL to the PR too
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
    Code coverage is not being reported correctly
  • Steps to reproduce
  • Potential workaround

Hey there.

Is the same Code showing up under the Code tab of your projects (on SQ and SonarCloud respectively) and files for which coverage is being reported? Digging in there is probably your best bet to understand configuration differences.