Skip to content

refactor: replace blanket clippy::restriction with a curated workspace lint policy - #88

Merged
jhamill34 merged 1 commit into
mainfrom
claude/issue-1-clippy-lint-policy
Aug 26, 2026
Merged

refactor: replace blanket clippy::restriction with a curated workspace lint policy#88
jhamill34 merged 1 commit into
mainfrom
claude/issue-1-clippy-lint-policy

Conversation

@jhamill34

Copy link
Copy Markdown
Owner

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 say restriction isn'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 via clippy::all, so allowing them wasn't opting out of a restriction lint at all — it was suppressing mainstream, warn-by-default clippy output.

  • Centralized the policy in root Cargo.toml's new [workspace.lints.clippy] table. pedantic stays fully on. Every restriction-tier lint was reviewed individually:
    • Kept on: ref_patterns, map_err_ignore, allow_attributes_without_reason.
    • Re-enabled despite not being restriction-tier (were being suppressed anyway): too_many_lines, match_ref_pats, needless_borrowed_reference.
    • Explicitly allowed, each with a documented reason: 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.
  • Every hand-written crate now just does [lints]\nworkspace = true — the 14 that had the old per-crate block, plus auth/oauth_flow and prototypes/workflow_engine, which never opted into any lint policy at all before this.
  • Removed 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.
  • Fixed the small, mechanical anti-patterns the old suppressions were hiding:
    • extern crate alloc; use alloc::sync::Arc (etc.) in 13 files across 9 ordinary std crates → plain std:: paths (zero crates here are #[no_std]).
    • 4 .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:

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

…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
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.

Blanket clippy::restriction forces anti-idiomatic workarounds workspace-wide

2 participants