From 8b2c8cdb817b7b1b98fec8bb4feca032d968ae8d Mon Sep 17 00:00:00 2001 From: Sachin Iyer Date: Fri, 8 May 2026 21:17:49 -0700 Subject: [PATCH 1/2] chore(lint): allow restriction/pedantic lints in test cfg only All clippy violations from these lints lived inside `#[cfg(test)]` modules (and the `tests/` integration crate); none were in production code. Scope the restriction lints (`unwrap_used`, `expect_used`, `panic`, `as_conversions`, `cast_sign_loss`, `cast_possible_wrap`) and a few pedantic ones that only fired on test code (`needless_collect`, `absolute_paths`, `if_then_some_else_none`, `doc_markdown`, `semicolon_outside_block`, plus the integration-test-only `redundant_closure_for_method_calls` and `tests_outside_test_module`) to test cfg via `#![cfg_attr(test, allow(...))]`. Production code is still held to the same bar. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/lib.rs | 17 +++++++++++++++++ src/main.rs | 18 ++++++++++++++++++ tests/integration.rs | 20 ++++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 73cb9fa..c608976 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,21 @@ #![deny(clippy::print_stdout, clippy::print_stderr, clippy::absolute_paths)] +#![cfg_attr( + test, + allow( + clippy::unwrap_used, + clippy::expect_used, + clippy::panic, + clippy::as_conversions, + clippy::cast_sign_loss, + clippy::cast_possible_wrap, + clippy::needless_collect, + clippy::absolute_paths, + clippy::if_then_some_else_none, + clippy::doc_markdown, + clippy::semicolon_outside_block, + reason = "restriction/pedantic lints relaxed in test cfg — unwrap/expect/panic/casts and minor stylistic lints are idiomatic in tests" + ) +)] use anyhow::{Context, Result}; use clap::{Parser, Subcommand}; diff --git a/src/main.rs b/src/main.rs index b1e4bf1..c434ac9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,21 @@ +#![cfg_attr( + test, + allow( + clippy::unwrap_used, + clippy::expect_used, + clippy::panic, + clippy::as_conversions, + clippy::cast_sign_loss, + clippy::cast_possible_wrap, + clippy::needless_collect, + clippy::absolute_paths, + clippy::if_then_some_else_none, + clippy::doc_markdown, + clippy::semicolon_outside_block, + reason = "restriction/pedantic lints relaxed in test cfg — unwrap/expect/panic/casts and minor stylistic lints are idiomatic in tests" + ) +)] + use clap::{CommandFactory, Parser}; use clap_complete::CompleteEnv; use console::Term; diff --git a/tests/integration.rs b/tests/integration.rs index 5e8fffc..0ff58e6 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -4,6 +4,26 @@ //! Set `DETAIL_API_KEY` in the environment to enable them; when absent the //! tests are silently skipped. +#![cfg_attr( + test, + allow( + clippy::unwrap_used, + clippy::expect_used, + clippy::panic, + clippy::as_conversions, + clippy::cast_sign_loss, + clippy::cast_possible_wrap, + clippy::needless_collect, + clippy::absolute_paths, + clippy::if_then_some_else_none, + clippy::doc_markdown, + clippy::semicolon_outside_block, + clippy::redundant_closure_for_method_calls, + clippy::tests_outside_test_module, + reason = "restriction/pedantic lints relaxed in test cfg — unwrap/expect/panic/casts and minor stylistic lints are idiomatic in tests" + ) +)] + use std::path::PathBuf; use std::process::Command; From db2328a844ee9cbb2f0d7d211dc8811372b483a9 Mon Sep 17 00:00:00 2001 From: Sachin Iyer Date: Fri, 8 May 2026 21:49:24 -0700 Subject: [PATCH 2/2] chore(lint): drop unused cfg_attr block from main.rs The binary crate has no tests, so the test-cfg allow block had no effect. lib.rs already covers all `#[cfg(test)] mod tests` in src/ since they compile as part of the lib crate; tests/integration.rs keeps its own block because it's a separate crate. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/main.rs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/main.rs b/src/main.rs index c434ac9..b1e4bf1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,21 +1,3 @@ -#![cfg_attr( - test, - allow( - clippy::unwrap_used, - clippy::expect_used, - clippy::panic, - clippy::as_conversions, - clippy::cast_sign_loss, - clippy::cast_possible_wrap, - clippy::needless_collect, - clippy::absolute_paths, - clippy::if_then_some_else_none, - clippy::doc_markdown, - clippy::semicolon_outside_block, - reason = "restriction/pedantic lints relaxed in test cfg — unwrap/expect/panic/casts and minor stylistic lints are idiomatic in tests" - ) -)] - use clap::{CommandFactory, Parser}; use clap_complete::CompleteEnv; use console::Term;