Skip to content

fix: the cleanup stats count unwraps and expects in production code only - #595

Merged
PiquelChips merged 2 commits into
mainfrom
refactor/544-tooling-stats
Nov 21, 2026
Merged

PiquelChips merged 2 commits into
mainfrom
refactor/544-tooling-stats

Conversation

@PiquelChips

@PiquelChips PiquelChips commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Part of #544

The cleanup audit reported 9 .expect( and 2 .unwrap() outside tests, though none can panic in production. It counted them in doc examples (/// .expect("a key")) and in code compiled only for tests through the test-util feature, such as Telemetry::capture and InsertUser::named.

stats.py now:

  • counts unwrap, expect, unsafe, #[allow and #[expect on production code lines only, leaving out doc examples. TODO, FIXME and XXX are still counted in comments.
  • treats items and modules behind exactly #[cfg(test)], #[cfg(all(test, …))] and #[cfg(any(test, feature = "test-util"))] as test code, whitespace and line breaks inside the attribute included. Any other any(test, …), such as any(test, feature = "prod"), stays production.
  • ends a test-only field, enum variant or match arm at its ,, or just before the } closing its parent. Before, the next brace was its parent's }, so the range ran on to the following {. That bug predates this PR, which made it show by counting test-util variants.

test-util code now counts as test code in the line counts too.

Testing

Ran it on main. .unwrap() went from 2 to 0, .expect( from 9 to 0, and #[expect from 16 to 14 (the two dropped are the test-util helpers' own expect_used exceptions). Listed every match before and after to check each dropped one was a doc example or test-util code.

Test lines per file, against main's script:

  • 15 files gain the test-util and all(test, …) items they hold, e.g. crates/telemetry/src/capture.rs (0 → 111) and crates/database/src/repositories/audit/mod.rs (2 → 207).
  • apps/auth-service/src/deliveries/outbound.rs goes from 35 to 12: its #[cfg(test)] variant and match arm no longer take the code after them. I listed the 12 lines: fn local, the variant and the arm.
  • crates/database/src/exclusive/mod.rs goes from 2 to 10: the four LockKey test variants and mod tests;, no longer the enum's } or impl LockKey {.

No tests touched; no files outside the cleanup skill.

Note

Written by Claude Opus 5.5 in Claude Code (via T3 Code), reviewed by Claude Opus 5.5

@PiquelChips
PiquelChips marked this pull request as draft November 20, 2026 08:30
@github-project-automation github-project-automation Bot moved this to Needs Triage in sourceorigin.dev Nov 20, 2026
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 34 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6d073c14-04f6-4d21-9e85-94df442d494f
Commits

Reviewing files that changed from the base of the PR and between 467e813 and ecda0a2.

Files selected for processing: 1

  • .agents/skills/sourceorigin-cleanup/scripts/stats.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@PiquelChips PiquelChips added refactor No behviour changes ci-cd CI-CD labels Nov 20, 2026
@PiquelChips
PiquelChips marked this pull request as ready for review November 20, 2026 08:54
@PiquelChips
PiquelChips marked this pull request as draft November 21, 2026 14:00
@PiquelChips
PiquelChips marked this pull request as ready for review November 21, 2026 14:34
@PiquelChips
PiquelChips added this pull request to the merge queue Nov 21, 2026
Merged via the queue into main with commit f5ebb6d Nov 21, 2026
14 checks passed
@PiquelChips
PiquelChips deleted the refactor/544-tooling-stats branch November 21, 2026 15:49
@github-project-automation github-project-automation Bot moved this from Needs Triage to Done in sourceorigin.dev Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-cd CI-CD refactor No behviour changes

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant