Skip to content

chore(lint): enable clippy::map_unwrap_or#27

Open
tupe12334 wants to merge 2 commits into
mainfrom
lint/enable-map-unwrap-or
Open

chore(lint): enable clippy::map_unwrap_or#27
tupe12334 wants to merge 2 commits into
mainfrom
lint/enable-map-unwrap-or

Conversation

@tupe12334

Copy link
Copy Markdown
Member

Summary

Enables the clippy::map_unwrap_or lint workspace-wide and fixes the two call sites it surfaces.

The lint flags opt.map(f).unwrap_or(g) / .unwrap_or_else(g) and suggests the single combinator map_or / map_or_else — clearer intent, one operation instead of a two-step chain, and harder to misread which closure is the fallback.

Changes

  • Cargo.toml — add map_unwrap_or = "deny" to [workspace.lints.clippy] (kept all at deny, set its priority = -1 so the specific lint composes cleanly).
  • core/src/tools.rs (normalize_tool) and core/src/events.rs (normalize_event) — rewrite canonical.map(|s| s.to_owned()).unwrap_or_else(|| vendor.to_owned()) to canonical.map_or_else(|| vendor.to_owned(), |s| s.to_owned()). Behavior unchanged.

Verification (local)

  • cargo fmt --all -- --check — clean
  • cargo clippy --workspace --all-targets — passes (exit 0), no map_unwrap_or violations remain
  • cargo test -p polyhook-core — 203 passed, 0 failed

Single rule, focused diff. Does not touch the default branch or other rules.

Closes #26


This pull request was opened by the "Add lint rule → issue + PR (owned repos + my orgs) → Slack" routine of moadim. cc @tupe12334

tupe12334 and others added 2 commits June 18, 2026 21:08
Enable the clippy::map_unwrap_or lint workspace-wide and rewrite the two
call sites it surfaces (normalize_tool, normalize_event) from
map(..).unwrap_or_else(..) to map_or_else(..). Behavior unchanged.

Closes #26

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…config conflict

Resolved by the "Resolve conflicts on code-quality PRs (non-guiddeco)" routine of moadim.
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.

Enable clippy::map_unwrap_or lint

1 participant