New code on branch OK, but once merged Not OK


I’m on SonarQube 10.3 Community Edition.

I modified my Java source code and refactor one method (a few lines) : in this method refactoring, I deleted the unique usage of a static variable declared on top of my Java class.
When I commited on my branch, all was OK for SonarQube on this branch : no issue and coverage 100%.
The problem occured when I merged this branch to master branch : a major issue occured on this top static variable that is not used anymore.

I look into Sonarqube configuration after reading the “new code” documentation here
But for me, the problem is that the branch code is analyzed only on “new code” without checking impacts on the whole class.

What can I do to resolve this kind of problem ?
Thank you.



Unfortunately, this is a known issue, and one that’s been on our radar for a while with no easy solution.


Hi @ganncamp,
thank you for answer.


hi @ganncamp,

I have a new use case for this problem.
I modified a private mothod to delete an usage of a specific class (present on import list at top of the file).
I created a PR on this modification and my pipeline was ok (no raised issues).

Next, I merged this branch and a new major issue was raised saying to me that I have an unsued import.



Yes, this is essentially the same case as the previous one (modification causes new issue in old code).


1 Like


thank you @ganncamp !

have a good day.