Skip to content

lint: enforce no-panic in production code (capstone)#609

Merged
nolik merged 1 commit into
mainfrom
iter8/no-panic-lint
Jul 18, 2026
Merged

lint: enforce no-panic in production code (capstone)#609
nolik merged 1 commit into
mainfrom
iter8/no-panic-lint

Conversation

@nolik

@nolik nolik commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Iteration 8/8 — the capstone that locks in the error-handling work from iterations 2–5.

  • Adds crate-level #![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.
  • Test code is exempt: #![cfg_attr(test, allow(...))] for the lib's unit tests, and the integration-test crates are separate (untouched).
  • The handful of sanctioned panic sites are collapsed behind two narrowly #[allow(clippy::expect_used)]-annotated helpers:
    • boot::compile_regex — compile-time-constant mention/profile regexes (shared by boot.rs + chat_gpt_handler.rs);
    • chat_repository::to_redis_json — infallible serde for the ToRedisArgs impls, 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 inline to_string().expect(..). Local gate green: fmt, clippy --all-targets -D warnings, 11 unit + 4 pure tests, all tests compile.

🤖 Generated with Claude Code

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>
@nolik
nolik merged commit 55c5d6c into main Jul 18, 2026
7 checks passed
@nolik
nolik deleted the iter8/no-panic-lint branch July 18, 2026 14:25
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