chore(lint): enable clippy::map_unwrap_or#27
Open
tupe12334 wants to merge 2 commits into
Open
Conversation
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.
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
Enables the
clippy::map_unwrap_orlint 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 combinatormap_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— addmap_unwrap_or = "deny"to[workspace.lints.clippy](keptallatdeny, set itspriority = -1so the specific lint composes cleanly).core/src/tools.rs(normalize_tool) andcore/src/events.rs(normalize_event) — rewritecanonical.map(|s| s.to_owned()).unwrap_or_else(|| vendor.to_owned())tocanonical.map_or_else(|| vendor.to_owned(), |s| s.to_owned()). Behavior unchanged.Verification (local)
cargo fmt --all -- --check— cleancargo clippy --workspace --all-targets— passes (exit 0), nomap_unwrap_orviolations remaincargo test -p polyhook-core— 203 passed, 0 failedSingle 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