SonarQube Technical Debt
Every shortcut in code works like a loan. The program runs today, and the team repays the loan later with extra effort. SonarQube measures that hidden loan so teams can see it, discuss it, and pay it down on purpose.
The Loan Picture
Quick fix today Interest grows Slow future work ┌────────────────┐ ┌──────────────────┐ ┌──────────────────┐ │ Copy-paste │ ──► │ Every change │ ──────► │ Features take │ │ Skip cleanup │ │ touches 3 places │ │ twice as long │ └────────────────┘ └──────────────────┘ └──────────────────┘
A small loan stays cheap to repay. A neglected loan makes every later change slower and riskier.
What SonarQube Calls Debt
SonarQube assigns a fix-time estimate to each maintainability issue. The sum of those estimates forms the technical debt of the project. The dashboard shows the value in days, hours, and minutes, for example 3d 4h.
Remediation Effort per Issue
Each rule carries an effort value. Removing an unused variable takes a few minutes. Splitting a very complex function takes much longer. Opening an issue shows the exact effort next to its description.
The Debt Ratio
Raw time says little without context, because a large project naturally holds more debt. The debt ratio solves this problem.
Debt Ratio = Remediation Cost ÷ Development Cost
Development cost is an estimate of the time needed to write the code from scratch. SonarQube uses a fixed cost per line of code, which you can adjust in the settings.
Example
- A project holds 10,000 lines of code.
- Estimated development cost reaches 5,000 hours.
- Technical debt reaches 250 hours.
- Debt ratio equals 250 ÷ 5,000, which is 5%.
Maintainability Rating
The rating converts the ratio into a letter.
| Debt Ratio | Rating |
|---|---|
| 0% to 5% | A |
| 6% to 10% | B |
| 11% to 20% | C |
| 21% to 50% | D |
| Above 50% | E |
The example project above earns an A.
Where to Find Debt in the Interface
- Open a project from the Projects page.
- Read the Maintainability card on the Overview tab.
- Click the debt value to list the issues behind it.
- Sort by effort to find the biggest items.
Types of Debt
Deliberate Debt
A team ships a rough version to meet a deadline and plans cleanup afterward. Deliberate debt works when the repayment plan is real.
Accidental Debt
A developer lacks context and writes code that grows hard to maintain. Code reviews and static analysis catch this kind early.
Aging Debt
Libraries and patterns that were fine five years ago become outdated. The code did not change, but the world did.
Paying Debt Down
Fix While You Work
Clean the file you already edit. Small, steady repayments cost less than a big cleanup project.
Protect New Code
A quality gate on New Code stops fresh debt from entering. The total stops growing, and old debt shrinks as files get touched.
Schedule Cleanup Time
Reserve a slice of each sprint for the top items in the issue list. Pick items with high impact and low effort first.
Cautions
- Debt estimates are averages, so treat them as guides, not promises.
- Zero debt is not a goal. A stable rating of A or B suits most teams.
- Never hide debt by marking real issues as false positives.
Quick Recap
Technical debt turns messy code into a number the whole team understands. Track the ratio, protect new code, and repay the loan in small steps.
