What is a quality gate in SonarQube?
Short answer
A quality gate is a set of pass/fail conditions on a project's analysis — for example "no new bugs or vulnerabilities, coverage on new code ≥ 80%, duplication on new code ≤ 3%". If any condition fails, the gate fails, and the pipeline can stop the code from being merged or deployed.
The default "Sonar way" gate (on new code)
| Metric | Condition |
|---|---|
| New issues | 0 |
| Security hotspots reviewed | 100% |
| Coverage on new code | ≥ 80% |
| Duplicated lines on new code | ≤ 3% |
Why "on new code"
Legacy projects can't fix thousands of old issues overnight. Gating new code ("Clean as You Code") ensures quality improves with every change without blocking all work.
Custom gate example
Create gate "Backend Strict": new code coverage ≥ 85%, Security Rating on new code = A, Reliability Rating = A — and assign it to critical projects.
What to say in the interview
"A quality gate is the pass/fail policy on an analysis. We gate new code — zero new vulnerabilities and bugs, reviewed hotspots, 80% coverage, low duplication — and the pipeline waits for the gate result to decide whether to continue."