From 13fef425d2533955f8aea7318b2428a7b63ab3de Mon Sep 17 00:00:00 2001 From: tupe12334 Date: Sun, 21 Jun 2026 18:09:39 +0300 Subject: [PATCH] chore(lint): enable clippy::allow_attributes_without_reason Deny clippy::allow_attributes_without_reason in lib/Cargo.toml and add a reason = "..." to every existing #[allow(...)] site (test modules opting out of the panic-safety lints, plus the retained dead_code tag field). No production logic changes. Closes #11 Co-Authored-By: Claude Opus 4.8 (1M context) --- lib/Cargo.toml | 3 +++ lib/src/daemon.rs | 7 ++++++- lib/src/download.rs | 3 ++- lib/src/extract.rs | 7 ++++++- lib/src/github.rs | 8 ++++++-- lib/src/install.rs | 7 ++++++- lib/src/lib.rs | 7 ++++++- lib/src/platform.rs | 7 ++++++- lib/tests/e2e_install.rs | 7 ++++++- 9 files changed, 47 insertions(+), 9 deletions(-) diff --git a/lib/Cargo.toml b/lib/Cargo.toml index dda2fbf..eefa0c8 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -37,6 +37,9 @@ unwrap_used = "deny" expect_used = "deny" panic = "deny" unreachable = "deny" +# Require every `#[allow(...)]` to record a `reason = "..."`, so each opt-out of +# the panic-safety set above is self-documenting and auditable in review. +allow_attributes_without_reason = "deny" # Forbid direct indexing/slicing (`a[i]`, `a[i..j]`) which panics out of bounds. # Completes the no-panic family above by closing the remaining common panic # source; prefer `.get(i)` / `.get(i..j)` so malformed input is handled, not fatal. diff --git a/lib/src/daemon.rs b/lib/src/daemon.rs index b858fb6..690ac08 100644 --- a/lib/src/daemon.rs +++ b/lib/src/daemon.rs @@ -197,7 +197,12 @@ pub fn restart_if_running(binary_path: &Path) -> Result { } #[cfg(test)] -#[allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] +#[allow( + clippy::unwrap_used, + clippy::expect_used, + clippy::panic, + reason = "tests deliberately unwrap/panic to fail fast on broken fixtures" +)] mod tests { use super::*; diff --git a/lib/src/download.rs b/lib/src/download.rs index d242d15..b170f00 100644 --- a/lib/src/download.rs +++ b/lib/src/download.rs @@ -48,7 +48,8 @@ pub fn download_and_verify(client: &Client, info: &ReleaseInfo) -> Result Result, String> { } #[cfg(test)] -#[allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] +#[allow( + clippy::unwrap_used, + clippy::expect_used, + clippy::panic, + reason = "tests deliberately unwrap/panic to fail fast on broken fixtures" +)] mod tests { use super::*; use std::io::Write; diff --git a/lib/src/github.rs b/lib/src/github.rs index 90d9087..ca43d85 100644 --- a/lib/src/github.rs +++ b/lib/src/github.rs @@ -12,7 +12,10 @@ pub struct VersionInfo { pub struct ReleaseInfo { /// Retained for consumers that need the resolved tag (e.g. for display/logging). - #[allow(dead_code)] + #[allow( + dead_code, + reason = "retained for consumers that need the resolved tag (e.g. for display/logging)" + )] pub tag: String, pub asset_url: String, pub checksums_url: String, @@ -179,7 +182,8 @@ pub fn parse_checksum(checksums_text: &str, asset_name: &str) -> Result Result Result { } #[cfg(test)] -#[allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] +#[allow( + clippy::unwrap_used, + clippy::expect_used, + clippy::panic, + reason = "tests deliberately unwrap/panic to fail fast on broken fixtures" +)] mod tests { use super::*; diff --git a/lib/tests/e2e_install.rs b/lib/tests/e2e_install.rs index d35ab28..a9c1aaf 100644 --- a/lib/tests/e2e_install.rs +++ b/lib/tests/e2e_install.rs @@ -5,7 +5,12 @@ //! //! Run with: `cargo test --test e2e_install -- --test-threads=1` -#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] +#![allow( + clippy::unwrap_used, + clippy::expect_used, + clippy::panic, + reason = "end-to-end tests deliberately unwrap/panic to fail fast on broken fixtures" +)] use std::fs; use std::path::PathBuf;