Repository navigation
fix: the cleanup stats count unwraps and expects in production code only - #595
Merged
Merged
Conversation
|
Warning Review limit reachedYou'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. View limit details
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. |
… and match test-util cfgs exactly
PiquelChips
marked this pull request as ready for review
November 20, 2026 08:54
PiquelChips
marked this pull request as draft
November 21, 2026 14:00
PiquelChips
marked this pull request as ready for review
November 21, 2026 14:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 thetest-utilfeature, such asTelemetry::captureandInsertUser::named.stats.pynow:unwrap,expect,unsafe,#[allowand#[expecton production code lines only, leaving out doc examples.TODO,FIXMEandXXXare still counted in comments.#[cfg(test)],#[cfg(all(test, …))]and#[cfg(any(test, feature = "test-util"))]as test code, whitespace and line breaks inside the attribute included. Any otherany(test, …), such asany(test, feature = "prod"), stays production.,, 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 countingtest-utilvariants.test-utilcode 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#[expectfrom 16 to 14 (the two dropped are the test-util helpers' ownexpect_usedexceptions). 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:test-utilandall(test, …)items they hold, e.g.crates/telemetry/src/capture.rs(0 → 111) andcrates/database/src/repositories/audit/mod.rs(2 → 207).apps/auth-service/src/deliveries/outbound.rsgoes 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.rsgoes from 2 to 10: the fourLockKeytest variants andmod tests;, no longer the enum's}orimpl 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