How to Gate on the Technical Debt Ratio
The technical debt ratio is remediation cost divided by development cost; a gate condition caps it on new code.
Sonar derives the maintainability rating from the debt ratio. Add a condition on "Technical debt ratio on new code" (SQALE), or equivalently require rating A, so debt-heavy diffs fail.
How the rating maps
| Debt ratio | Maintainability rating |
|---|---|
| 0 to 5% | A |
| 6 to 10% | B |
| 11 to 20% | C |
| over 50% | E |
sonar-project.properties
sonar-project.properties
sonar.projectKey=my-org_my-repo
sonar.sources=src
# Gate condition (new code): Technical Debt Ratio > 5.0 fails
sonar.qualitygate.wait=trueGotchas
- Debt time estimates come from rule remediation costs; custom rules need a remediation function set.
- The ratio is relative to lines changed, so a tiny risky diff can spike it more than a large clean one.
Related guides
How to Gate on Code Smells in a Quality ScanFail a build when new code smells appear by adding a maintainability issue condition to a SonarQube quality g…
How to Ratchet Quality From a Baseline in CIPrevent quality regressions on a legacy codebase by baselining current issues and failing CI only when new vi…