All files in some projects are always analyzed for Pull Requests

Version: Developer Edition Version 9.4 (build 54424)

Environment
Azure Devops, Windows Agent

Problem

  • Our repo contains Multiple c# projects

  • Pull Request Analysis is done using Azure Devops Pipeline and SonarQube.

    SonarQube Settings:

          > sonar.scm.disabled=true
    
          > Node Code = Previous Version
    

    Event though the above settings are applied, some of the projects in subfolders are
    showing all flles as changed. When I look at the Code section of the Pull Request
    in SonarQube web page, it show all lines as new code.

    For other projects in the same solution, it shows only changed lines as new code.

    Could someone please let us know what causing this problem?

Hey there.

Without SCM data, SonarQube has a harder time deriving which code has changed. Why do you set sonar.scm.disabled=true?

1 Like

Hello @Colin

There is a reason why we are setting
sonar.scm.disabled=true

A brief history

Some reference projects in our solution were totally ignored by SonarQube when Pull Requests were analyzed. That means, those project folders were not even displaying in the Code section of the PR.

After searching some forums, I added the following param in the Azure pipeline,

sonar.scm.exclusions.disabled=true

Then at least folders started displaying. But then new code was showing as 0 for changed files in those folders.

SonarQube LOG

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

I confirmed that the sha1 is correct.

We were not able to find any resolution. So finally we had to set

sonar.scm.disabled=true

to get those files analyzed.

Please note that, this phenomenon is happening to only some projects in subdirectories. Root project and other reference projects are getting analyzed properly.