Debtmap Re-adds JavaScript and TypeScript Support
Source: Dev.to
Overview
Debtmap v0.15.0 adds JavaScript and TypeScript support using tree‑sitter.
Initially, Debtmap supported multiple languages, but JS/TS support was removed in v0.7.0 to focus on Rust. After stabilizing the Rust analyzer (entropy dampening, purity analysis, call‑graph integration), proper JS/TS support was re‑implemented in v0.14.0–v0.15.0.
Complexity Metrics
- Cyclomatic complexity
- Cognitive complexity – adds nesting penalties (e.g., a
forinside anifis harder to read than the same number of top‑level branches). - Nesting depth
Async Patterns
- Callback nesting depth
- Promise‑chain length
- Missing
.catch()handlers
These patterns create complexity that traditional metrics often miss.
TypeScript‑Specific Checks
- Excessive
anyusage (> 5per file) - Overuse of type assertions (
> 3per file) - Overuse of non‑null assertions (
!)
Functional Chains
Detects map/filter/reduce pipelines and flags side effects inside them (e.g., console.log, mutations, I/O).
Entropy‑Based Complexity Dampening (JS/TS)
v0.15.0 introduces entropy‑based dampening, which reduces false positives for repetitive code.
Example: Validation functions that repeat the same logic for multiple fields.
function validateConfig(config: Config): string[] {
const errors: string[] = [];
if (config.width !== undefined) {
if (typeof config.width !== 'number') errors.push('width must be number');
else if (config.width 10000) errors.push('width exceeds max');
}
if (config.height !== undefined) {
if (typeof config.height !== 'number') errors.push('height must be number');
else if (config.height 10000) errors.push('height exceeds max');
}
return errors;
}
Raw cyclomatic complexity: 10
Because the validation logic is repetitive with low token entropy, Debtmap dampens the score, avoiding a high‑priority debt flag. The recommended fix is to extract shared validation logic, but the tool should not treat every such function as critical debt.
Installation
cargo install debtmap
Usage
Analyze (interactive TUI)
debtmap analyze .
Analyze with coverage data and Git context
debtmap analyze . --lcov coverage/lcov.info --context
Export results (e.g., for CI or LLM consumption)
debtmap analyze . --format markdown --top 10 --lcov coverage/lcov.info --context
File Detection
JS/TS files are detected automatically by extension:
.js,.ts,.jsx,.tsx.mjs,.cjs,.mts,.cts
What Debtmap Does Not Do
- Replace ESLint/TSLint (style enforcement)
- Replace the TypeScript compiler (type checking)
- Generate coverage data (use Jest, Vitest, etc.)
- Provide automatic fixes (that’s up to you or your AI assistant)
Resources
- Repository
- Documentation
- Changelog
Open‑Source Projects
- Debtmap – Technical debt analyzer
- Prodigy – AI workflow orchestration