How to prevent SonarQube from treating moved classes as new code?

SonarQube Version: Enterprise Edition v2025.1 (102418) ACTIVE MQR Mode

Deployed by: Helm

Language: Java


Hello community,

In our main branch scan, we use the default new code mode.

The problem we are facing is, if someone moves/renames a package, sonar treats it as new code and raises old issues as new. Is there a way to prevent this?

To give you more information about our settings, we have not enabled `DevOps Platform Integration` because we have our own MR decorator.

And the SCM config looks like this.

Am I missing some config, or is it not supported for some reason?

Btw, I haven’t noticed this on Merge Request scans though. (But I’m not 100% sure.) Maybe it’s already covered by SONAR-13579.

Thanks,

Bhathiya

Hi,

The ticket you’ve found is about detecting file move in PRs, but you’ve mentioned your main branch. Is the file move not being detected in the branch, or in PRs on the branch?

If the latter, this is going to be about the SCM data available to analysis. Could you provide your analysis log?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Ann

Hi Ann,

Thanks for the reply. The problem is on the main branch. What I wanted to say about PRs was that I haven’t noticed this issue on PRs, probably because it’s fixed by SONAR-13579.

Regarding the scanner logs, rather than sending the entire log, could you let me know which parts or lines you’re interested in? I can search for them and share those with you.

Thanks,

Bhathiya

Hi Bhathiya,

Detecting file move outside of PRs was fixed so long ago that I can’t find the ticket. That’s why I suspect your SCM data.

Feel free to redact your analysis log as necessary.

 
Thx,
Ann