SCM reported changed lines for 0 files in the branch

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube Server / Community Build, Scanner, Plugin, and any relevant extension) - Enterprise Edition v2025.1.1 (104738)
  • how is SonarQube deployed: zip, Docker, Helm: Not Sure, managed by a central team
  • what are you trying to achieve: Get Sonar Analysis for GitHub Pull Requests working for a Java-based project which is built with Bazel
  • what have you tried so far to achieve this
    – There is a periodic build of the project’s main branch which posts coverage and issues to the SonarQube Server. It uses the bazel_sonarqube tooling for that
    – SonarQube Server is integrated with GitHub Enterprise, i.e. the communication between the two works fine
    – Reporting Pull Requests analysis results is working in general, but at first, the attempts were providing wrong results as sonar.scm.disabled was set to true. This was due to the error: Not inside a Git work tree: /home/runner/_work/.cache/bazel/_bazel_root/ad10abeb5f49fe86dd21f7b9748d3dd8/execroot/_main/bazel-out/k8-fastbuild/bin/sonarqube.runfiles/_main, but this got resolved once I started providing to the bazel run //:sonarqube command the parameter --output_base set to a folder inside the cloned git repo.
    – All the pull requests parameters sonar.pullrequest.key/branch/base are provided and correct
    – The repository is cloned with fetch-depth: 0 so it is not shallow.

The problem that I face and cannot get working is that Pull Request analysis always results in 0 issues and no coverage figures:

From the logs I can see the following:

18:36:35.947 INFO: SCM collecting changed files in the branch
18:36:36.158 INFO: Merge base sha1: 10fa6df482b0443aa6fbac5c9e6949d68db7fb4e
18:36:36.181 INFO: SCM collecting changed files in the branch (done) | time=234ms
18:36:36.181 DEBUG: SCM reported 8 files changed in the branch

and this is correct. Then later I see this:

18:36:51.037 INFO: SCM revision ID '5d63bc03b9cde11434bf867aff5d872609bf7627'
18:36:51.171 INFO: SCM writing changed lines
18:36:51.269 INFO: Merge base sha1: 10fa6df482b0443aa6fbac5c9e6949d68db7fb4e
18:36:51.273 DEBUG: SCM reported changed lines for 0 files in the branch

I have two java files changed in order to test the PR analysis:

  • vcf-fleet-lcm/sddclcm/build/sddc-build-service/src/main/java/com/broadcom/vcf/lcm/sddc/build/Application.java
  • vcf-fleet-lcm/sddclcm/build/sddc-build-service/src/main/java/com/broadcom/vcf/lcm/sddc/build/action/StartComponentAction.java

Both files are included in the sonar.sources list in the sonar-project.properties file that is generated by bazel_sonarqube. Both files appear in the log with the correct paths above, but still at the end the analysis says SCM reported changed lines for 0 files in the branch.

Many suggestions from the Internet and AI agents were pointing at setting sonar.projectBaseDir to the root of the repo so file paths get resolved correctly, but when I do this, either via CLI parameter or via adding it to the sonar-project.properties, it results in the sonar scanner overwriting the modules’ project keys with their relative path and failing because then the project key contains ‘/’ (this is has to be a bug IMHO)

Uploading the log from the bazel build for the coverage and the sonar analysis.
generate_sonar_report.log (26.7 KB)

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!
generate_sonar_report.log (1.1 MB)

Refer to the later and bigger attachment, as the first one was partial only

Hi,

Welcome to the community and thanks for this report!

Thanks also for leading with a debug analysis log! :star_struck:

Nothing jumps out at me here. I’m going to flag this for the team. Unfortunately, it may be a while before they show up.

 
Ann