lint: enforce no-panic in production code (capstone)#609
Merged
Conversation
Adds crate-level `#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic)]` to the lib and binary, making the CI clippy gate reject any new panic-on-unexpected in production code. Test code is exempt via `#![cfg_attr(test, allow(...))]` (lib) and the separate integration-test crates. The handful of sanctioned panic sites are collapsed behind two narrowly `#[allow(clippy::expect_used)]`-annotated helpers: - `boot::compile_regex` — compiles the compile-time-constant mention and profile regexes (used by boot.rs and chat_gpt_handler.rs). - `chat_repository::to_redis_json` — infallible serde serialization for the ToRedisArgs impls, which have no channel to report an error. This locks in the error-handling work from iterations 2-5: every runtime failure is now modelled as a Result/AppError, and the lint prevents regressions. Verified: a probe `.unwrap()` in production fails clippy; local gate green (fmt, clippy --all-targets -D warnings, 11 unit + 4 pure tests, all tests compile). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Iteration 8/8 — the capstone that locks in the error-handling work from iterations 2–5.
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic)]to the lib and the binary, so the CI clippy gate now rejects any new panic-on-unexpected in production code.#![cfg_attr(test, allow(...))]for the lib's unit tests, and the integration-test crates are separate (untouched).#[allow(clippy::expect_used)]-annotated helpers:boot::compile_regex— compile-time-constant mention/profile regexes (shared byboot.rs+chat_gpt_handler.rs);chat_repository::to_redis_json— infallible serde for theToRedisArgsimpls, which have no channel to report an error.Chose crate attributes over the
[lints]table so the deny stays scoped to production code without sprinkling allows across every integration-test file.Verified the lint actually enforces: a probe
.unwrap()in production fails clippy citing the crate-level deny; removed after the check. Pure refactor otherwise —compile_regex(P)≡Regex::new(P).expect(..),to_redis_json(x)≡ the old inlineto_string().expect(..). Local gate green: fmt, clippy--all-targets -D warnings, 11 unit + 4 pure tests, all tests compile.🤖 Generated with Claude Code