Add mutation and CRAP quality indicators#64
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a266231a23
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if "{" in line: | ||
| seen_body = True | ||
| depth -= line.count("}") | ||
| if seen_body and depth <= 0: | ||
| break |
There was a problem hiding this comment.
Ignore bodyless
fn declarations in CRAP parsing
parse_functions treats every fn match as a concrete function body and keeps scanning until it sees a {/} balance, which misparses trait/prototype declarations like fn strategy(&self) -> &'static str; (e.g., in rust/src/daemon.rs). In that case it creates a synthetic metric spanning unrelated lines and skips subsequent declarations, so hotspot ordering and coverage attribution become inaccurate for files containing trait method signatures.
Useful? React with 👍 / 👎.
…n-crap # Conflicts: # scripts/ci/run-fast-checks.sh
Extract the bodyless function declaration predicate and extend the self-test with a multiline generic trait method so CRAP metrics do not attribute declarations as concrete Rust function bodies.
Use an explicit helper for closed function bodies so declaration skipping remains separate from concrete Rust body parsing.
Move function body scanning into a dedicated helper that returns whether a concrete body was found, keeping bodyless declarations from participating in metric generation.
Summary
Adds a lightweight quality gate for mutation testing and CRAP-style hotspot reporting.
Refs #55.
Changes
scripts/ci/run-quality-indicators.sh.scripts/quality/crap_indicator.py, a dependency-free Rust function hotspot reporter that uses the CRAP formula and optional LCOV coverage.async fn,const fn,unsafe fn, andextern "C" fn.cargo-mutantsand coverage-backed CRAP reporting withcargo-llvm-covindocs/QUALITY_GATES.md.scripts/ci/run-fast-checks.shso the new tooling is covered by the existing cheap PR gate.Verification
python3 scripts/quality/crap_indicator.py --self-test- passed./scripts/test-quality-indicators.sh- passedbash scripts/ci/run-quality-indicators.sh- passed and produced a conservative 0%-coverage CRAP hotspot reportbash scripts/ci/run-fast-checks.sh- passedgit diff --check- passedNotes
Mutation testing is opt-in via
APW_RUN_MUTATION=1because it is intentionally slower than PR Fast CI and requirescargo-mutantson the runner. Coverage-backed CRAP scoring is opt-in viaAPW_RUN_COVERAGE=1and requirescargo-llvm-cov.