Sonar analysis detects new issue on master after merging PR with false positive resolved

Hello,
Could you please help us with the following problem?

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Sonarqube version 9.6.1 (build 59531)
    Scanner version 4.7.0.2747
    CFamily plugin version: 6.36.0.52033
    New Code policy for Project: master is the Reference branch for all new branches and PRs. Main branch master itself is set to compare with the Previous version of branch.
    Executing sonar-scanner with option -Dsonar.branch.name
  • what are you trying to achieve
    Run analysis on master after merging PR with issue marked as false positive with no new issues detected on master
  • steps to reproduce
  1. create a branch from master
  2. do any change in a new branch that will lead to an issue that sonarcube can detect
  3. let sonarcube find this issue in a new branch
  4. resolve the issue sonarcube found in a new branch as a false positive issue
  5. merge the changes from a new branch to the master (using PR)
  6. run sonarqube on master
  • expected behavior
    In this case, we expect that the Quality Gate will not fail on master with new issue in code exception on the issue we marked as a false positive before.

Hey there.

This kind of issue tracking will only work with pull request analysis, while branches exist completely independently from each other besides finding the fork point where the New Code Period should start (the use of the “Reference Branch”)