What is "Clean as You Code" and new code in SonarQube?

IntermediateConceptSonarQube
Answer

Short answer

Clean as You Code means you only require new or changed code to meet the quality bar, instead of fixing all legacy issues first. SonarQube compares against a new code definition — e.g. changes since the previous version, the last N days, or relative to a reference branch — and the quality gate checks only that.

New code definitions

Option Meaning
Previous version Code changed since the last sonar.projectVersion change
Number of days Changes in the last N days
Reference branch Changes compared to main (great for feature branches)
Specific analysis Changes since a chosen baseline analysis

Why it works

  • Teams aren't blocked by 5,000 old issues.
  • Every PR leaves the code a little cleaner.
  • Over time, the old code gets touched and fixed too.

What to say in the interview

"Clean as You Code gates only new code against a new-code baseline such as the reference branch, so legacy debt doesn't block delivery while every change meets the standard, and overall quality steadily improves."

All Security Tools questions Roadmap: SonarQube — code quality & SAST

More on SonarQube