New Code Detection Issue – Unchanged Files Being Flagged as New Code

We’ve encountered an issue where SonarQube is detecting unchanged files and code as new code during analysis. These files have not been modified since the last scan, yet they are being flagged as new, which is impacting our quality gate metrics and creating noise in our reports.

This behavior is observed across several projects and environments. We’ve confirmed that the files in question have not been altered, and their timestamps remain unchanged. We are using the SonarQube version 9.9.1

Steps to Reproduce:

  1. Run a scan on a project with a baseline established.
  2. Check the results for files flagged as new code.
  3. Compare the flagged files to the previous version, noting no changes were made.

Expected Behavior: Only files with actual modifications should be detected as new code.

Actual Behavior: Unchanged files and code are incorrectly flagged as new.

Additional Context: We’ve tried clearing the cache, restarting the analysis process, and reviewing the documentation, but the issue persists. Could this be a misconfiguration, or is there a known issue in this version of SonarQube?

Any assistance or guidance to resolve this would be greatly appreciated.

Thank you

Hi,

This is about the SCM metadata available to analysis. SonarQube uses SCM data to understand what’s new, and if that data is incomplete or unavailable, the detection of new code can be wrong.

You didn’t mention whether this is a branch or PR context, but the PR prerequisites can be helpful in both scenarios.

 
HTH,
Ann

If the data gathered by the SCM is incorrect, how can we resolve it? This is within the branch context—I’m scanning my master branch, and it’s detecting new code that hasn’t changed for the last seven commits.

Hi,

Did you check the docs link I sent in my last post?

 
Ann