refactor: replace blanket clippy::restriction with a curated workspace lint policy - #88
Merged
Merged
Conversation
…e lint policy Phase 1 of issue #1. Nearly every crate opened with `#![warn(clippy::restriction, clippy::pedantic)]` plus a long, drifted `#![allow(...)]` list — clippy's own docs say `restriction` isn't meant to be enabled wholesale, and three of the "commonly allowed" lints turned out to be default-on via `clippy::all` (match_ref_pats, needless_borrowed_reference, blanket_clippy_restriction_lints), meaning they were suppressing mainstream clippy output, not opting out of a restriction-tier lint. - Centralize the policy in root Cargo.toml's new [workspace.lints.clippy] table: pedantic stays fully on, each restriction-tier lint was reviewed individually and either enabled (ref_patterns, map_err_ignore, allow_attributes_without_reason) or explicitly allowed with a documented reason (implicit_return, question_mark_used, shadow_reuse/unrelated/same, single_call_fn, absolute_paths, mod_module_files, min_ident_chars, separated_literal_suffix, std_instead_of_core/alloc, arbitrary_source_item_ordering, doc_paragraphs_missing_punctuation). too_many_lines/match_ref_pats/needless_borrowed_reference are explicitly re-enabled since they were being suppressed despite not being restriction-tier. - Every hand-written crate (14 that had the old block, plus auth/oauth_flow and prototypes/workflow_engine which never opted into any lint policy) now just does `[lints] workspace = true`. - Removed service_loader's three `#[cfg(test)] mod test { #![allow(clippy::restriction, clippy::pedantic)] }` blocks, now meaningless since the crate root no longer blanket-enables either group. - Fixed the small, mechanical anti-patterns the old suppressions were hiding: `extern crate alloc; use alloc::sync::Arc` (etc.) in 13 ordinary std crates (zero crates in this workspace are #![no_std]) replaced with plain std paths; 4 `.map_err(|_| ...)` sites that discarded the original error now capture it in the resulting message. The ~86-site ref-pattern/match_ref_pats/needless_borrowed_reference rewrite this now surfaces as warnings, the too_many_lines fallout, and the api_caller numeric-safety audit (as_conversions/cast_possible_truncation, kept allowed here with a documented reason) are tracked as follow-ups in #85, #86, #87 rather than folded into this policy change. Fixes #1 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VzKriyNnMHmqQ6UxPhsv2
This was referenced Aug 26, 2026
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.
Summary
Phase 1 of #1 (scoped in detail in that issue's discussion). Nearly every crate opened with
#[warn(clippy::restriction, clippy::pedantic)]plus a long, drifted#[allow(...)]list. Clippy's own docs sayrestrictionisn't meant to be enabled wholesale — and research turned up something sharper than that: three of the "commonly allowed" lints (match_ref_pats,needless_borrowed_reference,blanket_clippy_restriction_lints) are actually default-on viaclippy::all, so allowing them wasn't opting out of a restriction lint at all — it was suppressing mainstream, warn-by-default clippy output.Cargo.toml's new[workspace.lints.clippy]table.pedanticstays fully on. Every restriction-tier lint was reviewed individually:ref_patterns,map_err_ignore,allow_attributes_without_reason.too_many_lines,match_ref_pats,needless_borrowed_reference.implicit_return,question_mark_used,shadow_reuse/shadow_unrelated/shadow_same,single_call_fn,absolute_paths,mod_module_files/self_named_module_files,min_ident_chars,separated_literal_suffix,std_instead_of_core/std_instead_of_alloc(this workspace has zero#[no_std]crates),arbitrary_source_item_ordering(would force alphabetical ordering over the codebase's logical grouping for no readability gain),doc_paragraphs_missing_punctuation.[lints]\nworkspace = true— the 14 that had the old per-crate block, plusauth/oauth_flowandprototypes/workflow_engine, which never opted into any lint policy at all before this.service_loader's three#[cfg(test)] mod test { #[allow(clippy::restriction, clippy::pedantic)] }blocks — meaningless now that the crate root doesn't blanket-enable either group.extern crate alloc; use alloc::sync::Arc(etc.) in 13 files across 9 ordinarystdcrates → plainstd::paths (zero crates here are#[no_std])..map_err(|_| ...)sites that silently discarded the original error → now captured in the resulting error message.Explicitly out of scope (tracked as follow-ups)
The policy change surfaces real fallout that's deliberately not fixed in this PR, to keep it reviewable:
ref-pattern rewrite this now flags as warnings (ref_patterns/match_ref_pats/needless_borrowed_reference), split into 3 stacked PRs by area.too_many_linesfallout once it's genuinely warn-on workspace-wide (overlaps with apicli: engine.rs is an oversized file mixing gRPC client logic, a JSON-Schema model, and merge/schemaify algorithms #12'sapicli/engine.rssplit).as-casts #87 — numeric-safety audit ofapi_caller'sas-casts (kept allowed here with a documented reason pointing at this issue, not rushed into a lint-hygiene sweep).Fixes #1
Test plan
cargo build --workspace --all-features— clean.cargo clippy --workspace --all-features— zero errors; 193 warnings, all expected fallout (the ~86 ref-pattern sites plus scattered pedantic nits in the two newly-included crates), zero from any lint we deliberately allowed.cargo test --workspace --all-features— every suite passes, zero failures.cargo fmt --all -- --check— clean.Generated by Claude Code