lint rule: hand-rolled-fetch (key? ? h[k] : default pattern) #205
Labels
No labels
P0
P1
P2
P3
bug
create
delete
enhancement
filed-by/agent
filed-by/user
frozen
lint-rule
needs-info
needs-triage
next
plugin/cc-architect
plugin/os
plugin/os-adr
plugin/os-aidd-lint
plugin/os-backlog
plugin/os-context
plugin/os-doc-hygiene
plugin/os-sdlc
plugin/os-vault
project/cc-os
ready-for-agent
ready-for-human
recurring
review
update
waiting
wayfinder:grilling
wayfinder:map
wayfinder:map
wayfinder:research
wayfinder:task
wayfinder:task
wontfix
worklist/deviations
worklist/lint-rule
worklist/new-implement-build
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
jared/cc-os#205
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Migrated from jared/os-sdlc#31 (repo retired).
Problem
A hand-rolled default-lookup where Hash#fetch already does this. Note: rubocop's own Style/HashFetch is NOT in play here -- this repo's .rubocop.yml sets
AllCops: DisabledByDefault: true, so only explicitly-listed cops run, and Style/HashFetch is not among them.Detection
h.key?(k) ? h[k] : d(ternary guarded by #key? on the same receiver/key, else-branch a constant/literal), autocorrecting toh.fetch(k, d).Correction
Use Hash#fetch with a default:
h.fetch(k, default).Pass/fail examples
h.key?(k) ? h[k] : defaultpattern.h.fetch(k, default).Provenance
Fable finding. Run 18 (ticket #18, decision-dice sandbox, now retired), dual review, 2026-07-21.
Implementation plan
Candidate custom cop for plugins/os-sdlc/lib/os_sdlc/cops/ (Sdlc/Structural or Sdlc/Dry namespace); autocorrect-capable like rubocop's own Style cops.
Implemented Sdlc/Dry/HandRolledFetch cop (lib/os_sdlc/cops/hand_rolled_fetch.rb, tests/cops/hand_rolled_fetch_test.rb, 7 tests incl. autocorrect). Registered in .rubocop.yml. Commit
c54593f.