Rules trigger on a very old line

This line was added 11 months ago

This is the rules that it is referring to

As seen, this rules is 7 years old while this line is 11 months old. Why did it only get flagged in my recent scan?

Hi @WWJ,

Thanks for reaching out, and welcome to the Community!

The rule being 7 years old doesn’t mean it was active in your Quality Profile 11 months ago when the line was written. The most likely explanation is that the rule was added to your profile (or to Sonar Way) sometime after that commit, or that a recent SonarQube upgrade improved the rule’s detection logic.

When SonarQube detects a new issue caused by a rule change rather than a code change, it uses a mechanism called backdating: instead of stamping the issue with today’s date, it sets the creation date to the SCM blame date of the affected line. That’s why it appears anchored to 11 months ago, the issue is new in your analysis, but SonarQube is correctly attributing it to when the line was actually written.

To help narrow it down further, could you share:

  • The rule key shown in the issue details (e.g. java:S1234)
  • Your SonarQube version, and whether you’ve upgraded recently
  • Whether the issue appears under New Code or Overall Code in the UI
  • Whether your Quality Profile was recently changed, or a new version of Sonar Way was applied

With those details we can confirm which trigger caused the issue to surface now.

Best regards,

Stevan