From 0379da3050e2327e22430eb9e6c82055a250d288 Mon Sep 17 00:00:00 2001 From: Morgan Roderick Date: Mon, 12 Oct 2026 16:19:32 +0200 Subject: [PATCH 1/4] refactor(sponsors): SponsorsSearch takes keyword arguments 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 #3009. --- app/controllers/admin/sponsors_controller.rb | 2 +- app/queries/sponsors_search.rb | 6 +++--- spec/queries/sponsors_search_spec.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/admin/sponsors_controller.rb b/app/controllers/admin/sponsors_controller.rb index 2581af8bc..fa16493da 100644 --- a/app/controllers/admin/sponsors_controller.rb +++ b/app/controllers/admin/sponsors_controller.rb @@ -6,7 +6,7 @@ def index @chapters = Chapter.all - @sponsors_search = SponsorsSearch.new(search_params) + @sponsors_search = SponsorsSearch.new(**search_params) sponsors = @sponsors_search.call @pagy, paginated_sponsors = pagy(sponsors) diff --git a/app/queries/sponsors_search.rb b/app/queries/sponsors_search.rb index 01dfdd289..7d01875b7 100644 --- a/app/queries/sponsors_search.rb +++ b/app/queries/sponsors_search.rb @@ -3,9 +3,9 @@ class SponsorsSearch attr_accessor :name, :chapter - def initialize(params = {}) - @name = params.fetch(:name) - @chapter = params.fetch(:chapter) + def initialize(name:, chapter:) + @name = name + @chapter = chapter end def call diff --git a/spec/queries/sponsors_search_spec.rb b/spec/queries/sponsors_search_spec.rb index c5c6d44f0..967505631 100644 --- a/spec/queries/sponsors_search_spec.rb +++ b/spec/queries/sponsors_search_spec.rb @@ -2,7 +2,7 @@ RSpec.describe SponsorsSearch do describe 'initialization' do - it 'configures its properties from the param hash' do + it 'configures its properties from keyword arguments' do search = described_class.new(name: 'Acme', chapter: 'London') expect(search.name).to eq('Acme') From 801c2ae4fdb6864831df99a86f35fb1cf639bf1e Mon Sep 17 00:00:00 2001 From: Morgan Roderick Date: Mon, 12 Oct 2026 16:19:32 +0200 Subject: [PATCH 2/4] refactor(verifier): Verifier takes keyword arguments 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 #3009. --- lib/verifier.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/verifier.rb b/lib/verifier.rb index 949d48435..6898556da 100644 --- a/lib/verifier.rb +++ b/lib/verifier.rb @@ -3,9 +3,11 @@ class Verifier attr_reader :id, :token - def initialize(hash) - @id = hash.fetch(:id) { nil } - @token = hash.fetch(:token) { nil } + def initialize(id: nil, token: nil) + raise ArgumentError, 'id or token is required' if id.nil? && token.nil? + + @id = id + @token = token end def access_token From 04c31f07cf821677abe55232c769cc18f9267c39 Mon Sep 17 00:00:00 2001 From: Morgan Roderick Date: Mon, 12 Oct 2026 16:19:32 +0200 Subject: [PATCH 3/4] refactor(admin): drop the unused default on grant_organiser_access All four call sites pass the argument. Issue #3009. --- app/controllers/admin/events_controller.rb | 2 +- app/controllers/admin/meetings_controller.rb | 2 +- app/controllers/admin/workshops_controller.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/events_controller.rb b/app/controllers/admin/events_controller.rb index 918558c6f..1ac14dc93 100644 --- a/app/controllers/admin/events_controller.rb +++ b/app/controllers/admin/events_controller.rb @@ -90,7 +90,7 @@ def organiser_ids params[:event][:organisers] end - def grant_organiser_access(organiser_ids = []) + def grant_organiser_access(organiser_ids) organiser_ids.each { |id| Member.find(id).add_role(:organiser, @event) } end diff --git a/app/controllers/admin/meetings_controller.rb b/app/controllers/admin/meetings_controller.rb index 111faf9b2..4f4e16def 100644 --- a/app/controllers/admin/meetings_controller.rb +++ b/app/controllers/admin/meetings_controller.rb @@ -76,7 +76,7 @@ def chapter_ids params[:meeting][:chapters] end - def grant_organiser_access(organiser_ids = []) + def grant_organiser_access(organiser_ids) organiser_ids.each { |id| Member.find(id).add_role(:organiser, @meeting) } end diff --git a/app/controllers/admin/workshops_controller.rb b/app/controllers/admin/workshops_controller.rb index a18e53635..004ea2e4f 100644 --- a/app/controllers/admin/workshops_controller.rb +++ b/app/controllers/admin/workshops_controller.rb @@ -248,7 +248,7 @@ def organiser_ids params[:workshop][:organisers] end - def grant_organiser_access(organiser_ids = []) + def grant_organiser_access(organiser_ids) organiser_ids.each { |id| Member.find(id).add_role(:organiser, @workshop) } end From a65e0c9771b6339b81a7c6f75c9acee5587a9734 Mon Sep 17 00:00:00 2001 From: Morgan Roderick Date: Mon, 12 Oct 2026 16:19:32 +0200 Subject: [PATCH 4/4] chore(rubocop): enable Style/OptionHash Encodes the keyword-arguments-over-option-hashes preference from the PR #3003 review for code written from now on. Issue #3009. --- .rubocop.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 29a94adb1..803c680c4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -55,6 +55,9 @@ Style/ClassAndModuleChildren: Style/OptionalBooleanParameter: Enabled: false +Style/OptionHash: + Enabled: true + Rails/Date: Enabled: true