SonarScanner raises the issues on the code which is not related to changed files

Hello,

Currently, I use the Sonar Scanner for macOS and it raises a lot of issues on unchanged files. And there is no change on the exclusion config.


As the screenshot below, many issues have been committed 7 months ago.

And the issue is intermittent. I also tried to clear the cache at ~/.sonar and .scannerwork, but it doesn’t help. It will be green after several times rescan.

1 Like

Hey there.

Is there any information about the collection of changed files/lines if you turn on DEBUG logging (sonar-scanner -X)

You should look for logs around these places:

INFO: SCM collecting changed files in the branch
INFO: SCM writing changed lines

Hi @Colin ,

I have checked but there is a lot of info in the debug log (around 40k lines of logs).
I found some msg like this ... \DashboardViewModelImpl.swift' was detected as changed but without having changed lines
And SCM reported 2630 files changed in the branch, but actually, there are not greater than 100 changed files in the scanned branch.

Thanks.

Do you see any warnings like the following?

  • Shallow clone detected, no blame information will be provided. You can convert to non-shallow with 'git fetch --unshallow'

  • Missing blame information for the following files:

It might be useful to share the full analysis logs, or turn of DEBUG mode for one run to see if anything becomes obvious (I forgot that, for some reason, we have very extensive git logging in SonarCloud that we turned off in SonarQube).

I’d also like to double-check: are you running the scan locally? In a CI environment?

I can’t find any logs as you show.

I can’t upload the debug log here due to the large file (more than 8MB). Can I send it to you via DM?

I have tried in both env and it frequently happens in CI env and sometimes in local.

I’ve opened a private message with you.

I have just shared the debug log via the private msg