Skip to content

refactor: convert option-hash parameters to keyword arguments - #3012

Merged
mroderick merged 4 commits into
codebar:masterfrom
mroderick:style/kwargs-over-option-hashes
Oct 12, 2026
Merged

mroderick merged 4 commits into
codebar:masterfrom
mroderick:style/kwargs-over-option-hashes

Conversation

@mroderick

@mroderick mroderick commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Converts the signatures listed in #3009 to keyword arguments and enables the RuboCop cop that enforces the preference from now on.

  • SponsorsSearch takes name: and chapter: keywords instead of an options hash. The admin sponsors controller splats its existing { name:, chapter: } hash into the new signature.
  • Verifier takes id: and token: keywords and rejects construction with neither. Both call sites already called it that way; the signature now says so, and a misspelled key raises ArgumentError instead of passing silently.
  • grant_organiser_access in the meetings, events, and workshops controllers drops its unused = [] default.
  • Style/OptionHash is enabled in .rubocop.yml. It matches option-hash parameters by name and has no autocorrect.

Closes #3009

Review notes

Resolved: Verifier#initialize now raises ArgumentError when constructed with neither id nor token, restoring the old constructor's fail-fast behaviour while keeping both call sites (Verifier.new(token:), Verifier.new(id:)) working.

Also risky: the **search_params splat is the only call-site change (it assumes the hash carries exactly name and chapter).

Deliberately not done: no shared concern for the three grant_organiser_access copies (the issue lists that as a review step), and the excluded wrappers (number_to_currency, title, avatar, sponsors?) stay as they are.

Call sites already pass name: and chapter:. The signature now says so, and a misspelled key raises ArgumentError instead of passing silently through an options hash. Issue codebar#3009.
@mroderick
mroderick force-pushed the style/kwargs-over-option-hashes branch from 8b2841f to 0d5562e Compare October 12, 2026 14:59
mroderick added a commit to mroderick/codebar-planner that referenced this pull request Oct 12, 2026
The keyword conversion made both constructor arguments optional, so Verifier.new() succeeded where the old required positional hash raised ArgumentError. The guard restores failure at construction and keeps both call sites (Verifier.new(token:) in members_controller, Verifier.new(id:) in application_helper) working. Review finding on PR codebar#3012. Issue codebar#3009.
Call sites already pass id: and token: as keywords, so the signature now states the real contract. A positional options hash now raises ArgumentError. Construction with neither id nor token also raises, keeping the fail-fast guarantee the old required positional hash gave. Issue codebar#3009.
Encodes the keyword-arguments-over-option-hashes preference from the PR codebar#3003 review for code written from now on. Issue codebar#3009.
@mroderick
mroderick force-pushed the style/kwargs-over-option-hashes branch from 64954a1 to a65e0c9 Compare October 12, 2026 16:22
@mroderick
mroderick marked this pull request as ready for review October 12, 2026 16:22
@mroderick
mroderick force-pushed the style/kwargs-over-option-hashes branch from 64954a1 to a65e0c9 Compare October 12, 2026 16:22
@mroderick
mroderick merged commit c522630 into codebar:master Oct 12, 2026
10 checks passed
@mroderick
mroderick deleted the style/kwargs-over-option-hashes branch October 12, 2026 16:41
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.

Prefer keyword arguments over option-hash parameters in app code

1 participant