Skip to content

[1/5] feat(risk): Report CRAP scores - #148

Open
thedrow wants to merge 3 commits into
iepathos:masterfrom
thedrow:feat/crap-metric
Open

thedrow wants to merge 3 commits into
iepathos:masterfrom
thedrow:feat/crap-metric

Conversation

@thedrow

@thedrow thedrow commented Oct 12, 2026 •

Copy link
Copy Markdown

Summary

  • Compute the CRAP score (complexity² × (1 − coverage)³ + complexity) per function.
  • Show it in JSON (metrics.crap), the terminal COVERAGE section, and LLM markdown.
  • Configure the coverage source with [crap].

This is PR 1 of 3. Next: LLM editability (#149, stacked on this PR).

Test plan

  • Unit and property tests for risk::crap
  • output_validation_test, library tests for output, formatters and config

Not yet done

  • Documentation: the book and README do not yet cover the [crap] section (coverage source) and the CRAP score in the output formats.

How to stack these

These pull requests target master. From a clone of iepathos/debtmap, link them bottom to top, then merge the stack:

gh stack link 148 149 150 151 152
gh stack merge

gh stack link records the stack on GitHub. gh stack merge merges that stack in one step. Pass a pull request number to stop at that pull request. Order: CRAP scores (#148), editability (#149), churn (#150), topics (#151), content reverts (#152).

CRAP (Change Risk Anti-Patterns) combines cyclomatic complexity with test
coverage: cc^2 * (1 - cov)^3 + cc. It is computed at output time from the
existing complexity and coverage data, so no analysis types change.

- JSON: metrics.crap is a number with coverage data and null without it,
  so consumers can parse the key unconditionally.
- Terminal and LLM markdown output show it next to coverage.
- [crap].coverage_source selects direct (default) or transitive coverage.
V3 schemas reject the new field. The terminal coverage line and
the LLM markdown section now show a score when one is present.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant