DebtLens is a maintainability scanner with optional rule packs. A good rule should make maintainers say, "yes, I would want to review that before merging."
Read docs/rule-packs.md for how core rules, framework
packs, and reporting/CI fit together before proposing new detectors.
npm install
npm run typecheck # type-check src
npm run typecheck:tests # type-check the test sources too
npm test # run the node:test suite (via tsx)
npm run test:all # all of the above
npm run build
node dist/cli/index.js scan examples/react --min-severity infoFor a guided first contribution, start with
docs/contributing-first-pr.md.
- Pick a layer and issue from
docs/rule-packs.mdanddocs/good-first-issues.md, or the contributor roadmap project. - Comment before starting medium, large, or RFC-style work so maintainers can help shape the approach.
- Keep the PR focused on one issue or one tightly related batch.
- Add or update tests for behavior changes.
- Update docs when CLI flags, config, reporters, rules, packs, or Action behavior changes.
- Before opening the PR, run:
npm run typecheck
npm run typecheck:tests
npm test
npm run buildMaintainers should be able to review a detector without guessing its policy. A rule PR should include:
- one true-positive fixture,
- one near-miss or false-positive fixture that must stay quiet,
- documented default thresholds and severity,
- confidence scoring rationale,
- reviewable evidence and a concrete suggestion,
- docs in
docs/rules.mdanddocs/rule-packs.md, - schema/template updates when new config keys are added,
- calibration fixture updates when existing showcase or quality bounds change.
For language or framework packs that need a new parser, start with an RFC-style doc before
adding runtime dependencies. See docs/language-pack-rfc.md
for the Python and Vue parser evaluation pattern.
- Decide whether the rule belongs in the core pack or a framework pack (see
docs/rule-packs.md). - State the false-positive bar before coding: what common pattern should not fire?
- Add a detector in
src/detectors/<ruleName>.ts. - Export it from
src/detectors/index.ts. - Add default thresholds in
src/config/defaults.tsif needed. - Document the rule in
docs/rules.mdand note its pack indocs/rule-packs.mdwhen adding a new id. - Add a test in
tests/detectors/<ruleName>.test.tsusing therunDetectorhelper — include a true positive and a near-miss that must not fire. - Add or update a calibration fixture when the rule changes cross-rule finding volume.
- Explain the confidence score and include reviewable evidence/suggestions.
- Check whether the rule affects baselines, SARIF, JSON schema examples, or showcase docs.
- If the rule will ship through a plugin or organization policy package, document the
package install and CI path (see
docs/policy-packages.md).
A detector must return issues with:
- clear message
- severity
- confidence (0–1; see
docs/rules.mdfor how scores are interpreted and assigned per rule) - file and line
- evidence
- suggestion
Avoid rules that claim to detect whether code was generated by AI. DebtLens focuses on maintainability outcomes, not authorship.
Reporters should render from the stable ScanResult object. If you add a reporter or
change public output:
- Add focused reporter tests.
- Update CLI format parsing if there is a new
--formatvalue. - Update README and Action docs when the format is user-facing.
- Keep existing reporter output stable unless the issue explicitly calls for a change.