Version: Developer Edition Version 9.4 (build 54424)
Environment
We have a C# Based large solution, which contains multiple projects distributed among subdirectories.
We are using PR decoration using Azure Devops and SonarQube.
Trying to merge a PR. Feature Branch to Main Branch
Problem 1
Initially, the Pull Requests were ignoring files inside subdirectories. So I searched and found the following solution which I added in the build pipeline. sonar.scm.exclusions.disabled=true
Now the files are detected by SonarQube analyzer. But now we are facing another problem.
Problem 2
Since the files in subdirectories were detected properly, I tried to check whether PR comments are populated without any issues. So I added some Bad Code in order to generate issues. However, when I pushed the commit, SonarQube was showing 0 as New Code. The pipeline log showed following information
INFO: Merge base sha1: 95a80397d3fXXXXXXXXXXXXXXXXXXXXX
WARN: File ‘D:\a\1\s.…\XXXXXX.cs’ was detected as changed but without having changed lines
DEBUG: SCM reported changed lines for 0 files in the branch
After the issue is identified, I done an analyze on Main branch. Because in some forums it was suggested as solution. Then I reran the pipeline again after adding some more bad code. Still new code is detected as 0.
We are not using Node. So I think it is not applicable.
I should have been a bit clearer on this. We had been running sonar scans until one day they just started reporting 0 lines of code. The Sonar scanner had failed to locate some components that were required for it to scan our code properly but instead of failing the scanning task and the pipeline, it reported non-failing errors and continued on as if there were no problems, allowing the pipeline to be successful. Sonar has confirmed this is behavior they intend to have (crazy, right?). So what I should have said was enable diagnostics and debug output for the pipeline and look for any errors reported during any of the 3 Sonar tasks (assuming you are using AzDo pipelines), even if they didnt cause the pipeline to fail.
Have you tried running the sonar scanner locally and not on a remote server?
Does scanning the main branch produce the same 0 lines of code result?
Have you checked the other settings in the sonar properties file, like sonar.sources? (if you are using it, remove it and let the autodetection try. If you arent using it, try using it - maybe the auto detection isnt working)
I am also not sure, but would guess that some setting that the SCM Sensor depends on was either missing or incorrect, so it could not operate correctly and was preventing new code from being counted.