Is deleted code line, new code?


I would like to report a false-negative:

  • when a sonar scan is executed only on new code lines and,
  • when the file change consists only of deleted lines.

It seems that sonar does not check any rules on the file in this context. But it can happen, for specific rules, that the file should not pass the quality gate.

A concrete example, with the rule java:S1451-Track lack of copyright and license headers. If the change consists to remove the copyright of a java class, then Sonar will not complain at all and the quality gate will be passed but should not.


  • the quality gate will fail if the scan is configured to scan all the lines and not only the changed lines code.
  • the same issue occures if the file is new and doesn’t have copyright.

I think the case is easy to reproduce.

Thank you in advance for your help,


  • Sonar Version 8.9 (build 43852)
  • Scan done on linux system


You’re looking at the confluence of 2 known issues with our current approach:

  • Only issues raised on new/changed lines are reported in PRs
  • Deleted lines can’t show up in PR analysis because there’s no line

I’m flagging your post for inclusion/consideration the next time there’s internal discussion around this.