Old issues are shown as a part of PR decoration

  • ALM used: Azure DevOps
  • CI system used: Azure Pipelines
  • Scanner command used when applicable (private details masked): mvn org.sonarsource.scanner.maven:sonar-maven-plugin:RELEASE:sonar --fail-fast
  • Languages of the repository: Java
  • Only if the SonarCloud project is public, the URL: N/A, as the Project is private
    • And if you need help with pull request decoration, then the URL to the PR too
  • Error observed: Old issues are getting detected as a part of PR decoration
  • Steps to reproduce: Use the RELEASE (3.10.0.2594) version of Sonar scanner > Sonar Scanner is detected as a part of PR > Old issues detected and PR gets decorated with old issues.
  • Potential workaround: When using 1 old version of Sonar Scanner i.e. 3.9.1.2184 scans the code and gets the PR decorated in a correct/expected way.

We would like to know if the latest version of Sonar Scanner (3.10.0.2594) is having issues while decorating PRs.

Hi,

Welcome to the community!

The current version of SonarScanner is 5.0.1. The SonarCloud docs are a bit behind, but you can find it in the SonarQube docs.

Regarding old issues in new code, when you click in the margin to the left of one of these issues, is the SCM ‘blame’ date shown for the issue recent (in the New Code period) or old?

 
Ann

Thanks for the reply!

The blame data as well as the issues detected within the SonarCloud says that the issues detected are old. Apart from that we’ve seen some instances where the issues detected are false positives.

Below are the version information for Sonar Scanner for Maven:

Please let me know if anything else is needed for the same.

Hi,

So you’re saying that with the latest version of the SonarScanner for Maven, you get old issues in PRs, but when you revert to version 3.9 you don’t?

Could you provide the analysis log from the 3.10 run?

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.

 
Thx,
Ann

Yes, the 3.9.x version of SonarScanner for Maven is working as expected, but not the 3.10.x version (Latest version).

Below attached are the analysis logs which is using the 3.10.x version of Sonar Scanner for Maven.
Logs-for-Maven-Project-Scan-Using-3.10.SonarScanner-Plugin-7-Nov2023.txt (23.7 KB)

Please let me know if anything else is needed for the same.

Hi,

Thanks for the log. I see from it that this is a branch analysis. Was the 3.9.x analysis also in a branch? This same branch?

I’m trying to eliminate variables to make sure that the only difference is the version of the scanner.

Also, since nothing really stands out in this log, could you enable debug logging (-X on the command line) and post that log?

 
Thx,
Ann

Thanks for your response, Ann :slight_smile:

I’m not sure why the logs says that it is branch analysis, but the pipeline from which the above logs are extracted is doing the PR decoration. And yes, we’re doing same thing while using the 3.10.x and 3.9.x version of Sonar Scanner for Maven.

I can assure you that only the Sonar Scanner’s version is getting changed in the Sonar Scanning command which we’re using to scan the Maven’s Project code against SonarCloud.

The command which is having issues (Pulling up the old issues as well as part of PR decoration):
mvn org.sonarsource.scanner.maven:sonar-maven-plugin:RELEASE:sonar --fail-fast

The command which is working fine:
mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar --fail-fast

So the only difference you’ll see here is the version of the Sonar Scanner for Maven.

One more thing I would like to mention here is - There was an instance we gone through the PR decoration for 1 of our Pull Request using the Sonar Scanner for Maven’s 3.10.x version, so it detected the old issues (which is not expected within PR decoration) and it dumped all the old issues it detected into the PR, then we just downgrade the version of Sonar Scanner for Maven to 1 step back (to version 3.9.1.2184) and re-ran the PR decoration pipeline and then we found that the issues reported previously (by latest version of Sonar Scanner for Maven) have gone! This all happened within the same PR.

Please let me know if anything else is needed for the same.

Hi,

Could I have that debug log I asked for?

 
Thx,
Ann

Okay.

Below attached are the debug logs (with -X on the command line):
Logs-for-Maven-Project-Scan-Using-3.10.SonarScanner-Plugin-10-Nov2023.txt (221.8 KB)

Please let me know if anything else is needed for the same.

Hi,

Thanks for the log. I’m going to flag this for more expert eyes.

 
Ann

Thanks for escalating the issue, Ann :slight_smile:

Hi @nayan-chhabhaiya8349,

In the Release 3.10.0.2594, the default sources option is updated from src/main/java to src/main. This means that the scanner may now include files that were previously ignored.
Can you please check this?

All the best,

Irina

Hello @irina.batinic,

Thanks for response!

Please provide me a way to check the sources option which the latest version of Sonar Scanner is including and also let me know if there is a way to override it.

@nayan-chhabhaiya8349,

Sure, everything is explained here.
Please let me know if you have more questions.

All the best,

Irina