You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Prefer keyword arguments over option-hash parameters in app code #3009
Adopt keyword arguments over default-valued positional parameters for new and touched methods, where the parameter is meant to be a set of named optional values.
Why
The kwargs form is what the latest review (PR #3003, release_seat) settled on; call sites read the same, and a misspelled key raises ActiveRecord::UnknownAttributeError instead of passing silently.
Where the old pattern remains
These are candidates, none urgent; convert opportunistically when each file is next touched:
app/queries/sponsors_search.rb:6 — def initialize(params = {}) with params.fetch inside. Call sites: SponsorsSearch.new(search_params) from admin/sponsors_controller.rb:9. Convertible to def initialize(name:, chapter:); search_params already builds exactly { name: ..., chapter: ... }.
lib/verifier.rb:6 — def initialize(hash) with hash.fetch. Call sites already use kwargs: Verifier.new(id: ...) (helpers), Verifier.new(token:) (controller). Ruby 3 separates kwargs from positional hashes, so a hash literal would raise ArgumentError — kwargs are already the de facto contract; the signature just does not say so.
app/controllers/admin/{meetings,events,workshops}_controller.rb — def grant_organiser_access(organiser_ids = []). The default is unused (all four call sites pass the argument), so this is about dropping the dead default rather than kwargs; a two-step refactor (drop default, then review whether the trio should be a shared concern).
Excluded (intentionally unchanged)
def number_to_currency(number, options = {}) in application_helper.rb — wraps a Rails stdlib method whose signature is a positional options hash; matching the stdlib shape is correct.
Activity
refactor(sponsors): SponsorsSearch takes keyword arguments
refactor(verifier): Verifier takes keyword arguments
refactor(admin): drop the unused default on grant_organiser_access
chore(rubocop): enable Style/OptionHash
fix(verifier): fail fast when constructed without id or token
refactor(verifier): Verifier takes keyword arguments
refactor(admin): drop the unused default on grant_organiser_access
chore(rubocop): enable Style/OptionHash