Edit on GitHub

Technical Debt

File Metric  |  Derived

An estimate of remediation effort, derived from the Maintainability Index and Halstead Volume. Unlike effort-based models, this score is dimensionless — use it for relative comparison across files.

Formula

debt_f(MI, HV) = max(0, 1 − MI/100) × √(HV + 1)
total_debt = Σ debt_f over all functions in the file
debt_per_100_sloc = total_debt / sloc × 100

A function with a perfect MI score (100) contributes zero debt. As MI drops toward 0 and HV grows, debt rises sharply.

Interpretation

debt_per_100_slocInterpretation
0 – 5Excellent — high maintainability, simple code
5 – 20Acceptable — some complexity, watch trending files
20 – 50Concerning — schedule refactoring soon
> 50Critical — difficult to maintain, high bug risk

TypeScript Example

// Simple arrow function
const double = (x: number) => x * 2;
// MI ≈ 95, HV ≈ 12 → debt_f ≈ (1-0.95) × √13 ≈ 0.18

// Complex function with nested conditions
function parseConfig(raw: string): Config {
  // 80 LOC, CC=12, HV=520
}
// MI ≈ 42, HV ≈ 520 → debt_f ≈ (1-0.42) × √521 ≈ 13.2

Notes

Related metrics

Maintainability Index · Halstead Volume · Cyclomatic Complexity