diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 475404b87..a8125c26f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit` -# on 2026-07-28 07:23:34 UTC using RuboCop version 1.88.2. +# on 2026-07-28 07:56:09 UTC using RuboCop version 1.88.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -18,48 +18,30 @@ Capybara/RSpec/VisibilityMatcher: Exclude: - 'spec/components/chapters_sidebar_component_spec.rb' -# Offense count: 2 +# Offense count: 3 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: with_first_argument, with_fixed_indentation Layout/ArgumentAlignment: Exclude: + - 'app/controllers/admin/invitations_controller.rb' - 'spec/features/member_portal_spec.rb' -# Offense count: 14 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: with_first_element, with_fixed_indentation -Layout/ArrayAlignment: - Exclude: - - 'app/controllers/admin/events_controller.rb' - - 'app/controllers/admin/workshops_controller.rb' - - 'app/controllers/concerns/member_concerns.rb' - -# Offense count: 9 +# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, no_empty_lines -Layout/EmptyLinesAroundBlockBody: +Layout/BlockEndNewline: Exclude: - - 'spec/components/event_card_component_spec.rb' - - 'spec/controllers/member/details_controller_spec.rb' - - 'spec/controllers/payments_controller_spec.rb' - - 'spec/features/admin/member_search_spec.rb' - - 'spec/features/manage_contact_preferences_spec.rb' - - 'spec/features/viewing_pages_spec.rb' - - 'spec/helpers/email_header_helper_spec.rb' - - 'spec/models/eligibility_inquiry_spec.rb' - - 'spec/models/feedback_request_spec.rb' + - 'app/models/workshop_invitation.rb' -# Offense count: 2 +# Offense count: 6 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. -Layout/ExtraSpacing: +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces +Layout/FirstHashElementIndentation: Exclude: - - 'spec/support/capybara.rb' + - 'lib/omniauth/strategies/codebar.rb' -# Offense count: 16 +# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. # SupportedHashRocketStyles: key, separator, table @@ -67,29 +49,22 @@ Layout/ExtraSpacing: # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit Layout/HashAlignment: Exclude: - - 'lib/omniauth/strategies/codebar.rb' - - 'spec/lib/services/mailing_list_spec.rb' - -# Offense count: 9 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings. -# URISchemes: http, https -Layout/LineLength: - Exclude: - - 'Gemfile' - 'app/controllers/admin/invitations_controller.rb' - - 'app/controllers/concerns/member_concerns.rb' - - 'app/controllers/dashboard_controller.rb' - - 'app/models/workshop_invitation.rb' - - 'lib/tasks/setup.rake' -# Offense count: 2 +# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented, indented_relative_to_receiver Layout/MultilineMethodCallIndentation: Exclude: - - 'spec/support/shared_examples/behaves_like_sending_workshop_emails.rb' + - 'app/controllers/dashboard_controller.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowInHeredoc. +Layout/TrailingWhitespace: + Exclude: + - 'app/controllers/admin/invitations_controller.rb' # Offense count: 10 # This cop supports safe autocorrection (--autocorrect). @@ -979,6 +954,14 @@ Style/InverseMethods: Exclude: - 'app/controllers/admin/chapters_controller.rb' +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: line_count_dependent, lambda, literal +Style/Lambda: + Exclude: + - 'app/models/workshop_invitation.rb' + # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Style/LineEndConcatenation: diff --git a/Gemfile b/Gemfile index 59cb18f2d..e9fa80ba9 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,9 @@ ruby file: '.ruby-version' gem 'rails', '~> 8.1.2' # LOCKED: It is Rails. # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] gem 'sprockets-rails' -gem 'coffee-script' # LOCKED: Added because Sprockets autoloads it when seeing .coffee files in the asset pipeline. Can be removed when that does not happen. +# LOCKED: Added because Sprockets autoloads it when seeing .coffee files in the +# asset pipeline. Can be removed when that does not happen. +gem 'coffee-script' gem 'amazing_print' # colourful output (suggested by rails_semantic_logger) gem 'rails_semantic_logger' # condense log lines: https://github.com/codebar/planner/issues/2339 @@ -14,7 +16,9 @@ gem 'benchmark' # LOCKED: Added because of activesupport 7.0 gem 'bigdecimal' # LOCKED: Added because of activesupport 7.0 gem 'carrierwave' gem 'cocoon' -gem 'csv' # LOCKED: csv was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0. Due to config/application.rb +# LOCKED: csv was loaded from the standard library, but is not part of the default +# gems starting from Ruby 3.4.0. Due to config/application.rb +gem 'csv' gem 'delayed_job' gem 'delayed_job_active_record' gem 'drb' # LOCKED: Added because of pry-remote @@ -40,7 +44,9 @@ gem 'premailer-rails' gem 'pundit' gem 'reline' # LOCKED: Added because of readline is not part of Ruby 3.5.0 -gem 'readline' # LOCKED: readline was loaded from the standard library, but is not part of the default gems starting from Ruby 4.0.0. +# LOCKED: readline was loaded from the standard library, but is not part of the +# default gems starting from Ruby 4.0.0. +gem 'readline' gem 'rolify' # Use Sass to process CSS gem 'sassc-rails' diff --git a/app/controllers/admin/events_controller.rb b/app/controllers/admin/events_controller.rb index a108100d3..1a0cfd573 100644 --- a/app/controllers/admin/events_controller.rb +++ b/app/controllers/admin/events_controller.rb @@ -74,14 +74,15 @@ def set_event def event_params params.expect(event: [ :virtual, :name, :slug, :date_and_time, :local_date, :local_time, :local_end_time, :description, - :info, :schedule, :venue_id, :external_url, :coach_spaces, :student_spaces, :email, :announce_only, - :tito_url, :invitable, :time_zone, :student_questionnaire, :confirmation_required, :surveys_required, - :audience, :coach_questionnaire, :show_faq, :display_coaches, :display_students, - { bronze_sponsor_ids: [] }, - { silver_sponsor_ids: [] }, - { gold_sponsor_ids: [] }, - { sponsor_ids: [] }, - { chapter_ids: [] } + :info, :schedule, :venue_id, :external_url, :coach_spaces, :student_spaces, :email, :announce_only, + :tito_url, :invitable, :time_zone, :student_questionnaire, + :confirmation_required, :surveys_required, + :audience, :coach_questionnaire, :show_faq, :display_coaches, :display_students, + { bronze_sponsor_ids: [] }, + { silver_sponsor_ids: [] }, + { gold_sponsor_ids: [] }, + { sponsor_ids: [] }, + { chapter_ids: [] } ]) end diff --git a/app/controllers/admin/invitations_controller.rb b/app/controllers/admin/invitations_controller.rb index c65d06924..90678ec7d 100644 --- a/app/controllers/admin/invitations_controller.rb +++ b/app/controllers/admin/invitations_controller.rb @@ -10,7 +10,8 @@ def update if request.xhr? if params[:attended].present? - render partial: 'admin/workshop/attendance_row', locals: { invitation: InvitationPresenter.new(@invitation), workshop: @workshop } + render partial: 'admin/workshop/attendance_row', +locals: { invitation: InvitationPresenter.new(@invitation), workshop: @workshop } else set_admin_workshop_data render partial: 'admin/workshops/invitation_management' diff --git a/app/controllers/admin/workshops_controller.rb b/app/controllers/admin/workshops_controller.rb index fbada3680..c72a01633 100644 --- a/app/controllers/admin/workshops_controller.rb +++ b/app/controllers/admin/workshops_controller.rb @@ -119,11 +119,11 @@ def changes def workshop_params params.expect(workshop: [ :local_date, :local_time, :local_end_time, :chapter_id, - :invitable, :seats, :virtual, :slack_channel, :slack_channel_link, - :rsvp_open_local_date, :rsvp_open_local_time, :description, - :rsvp_close_local_date, :rsvp_close_local_time, - :coach_spaces, :student_spaces, - { sponsor_ids: [] } + :invitable, :seats, :virtual, :slack_channel, :slack_channel_link, + :rsvp_open_local_date, :rsvp_open_local_time, :description, + :rsvp_close_local_date, :rsvp_close_local_time, + :coach_spaces, :student_spaces, + { sponsor_ids: [] } ]) end diff --git a/app/controllers/concerns/member_concerns.rb b/app/controllers/concerns/member_concerns.rb index bb45052c0..873f4ae21 100644 --- a/app/controllers/concerns/member_concerns.rb +++ b/app/controllers/concerns/member_concerns.rb @@ -10,8 +10,9 @@ module InstanceMethods def member_params params.expect(member: [ - :pronouns, :name, :surname, :email, :mobile, :about_you, :skill_list, :newsletter, :other_dietary_restrictions, :how_you_found_us, - :how_you_found_us_other_reason, { dietary_restrictions: [] } + :pronouns, :name, :surname, :email, :mobile, :about_you, :skill_list, + :newsletter, :other_dietary_restrictions, :how_you_found_us, + :how_you_found_us_other_reason, { dietary_restrictions: [] } ]).tap do |permitted_params| # We want to keep Rails' hidden blank field in the form so that all dietary restrictions for a member can be # removed by submitting the form with all check boxes unticked. However, we want to remove the blank value diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 82c529996..37b135024 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -17,7 +17,8 @@ def show def dashboard @user = MemberPresenter.new(current_user) - @ordered_events = DashboardQuery.upcoming_events_for_user(current_user).map.each_with_object({}) do |(key, value), hash| + @ordered_events = DashboardQuery.upcoming_events_for_user(current_user) + .map.each_with_object({}) do |(key, value), hash| hash[key] = EventPresenter.decorate_collection(value) end @announcements = current_user.announcements.active diff --git a/app/models/workshop_invitation.rb b/app/models/workshop_invitation.rb index 1f206db00..fc8c24d2d 100644 --- a/app/models/workshop_invitation.rb +++ b/app/models/workshop_invitation.rb @@ -23,7 +23,8 @@ class WorkshopInvitation < ApplicationRecord scope :last_six_months, -> { joins(:workshop).where(workshops: { date_and_time: 6.months.ago...Time.zone.now }) } scope :not_reminded, -> { where(reminded_at: nil) } scope :on_waiting_list, -> { joins(:waiting_list) } - scope :with_notes_and_their_authors, -> { includes(member: [{ member_notes: :author }, :attendance_warnings]).includes(:overrider) } + scope :with_notes_and_their_authors, -> { + includes(member: [{ member_notes: :author }, :attendance_warnings]).includes(:overrider) } def waiting_list_position @waiting_list_position ||= WaitingList.by_workshop(workshop) diff --git a/lib/omniauth/strategies/codebar.rb b/lib/omniauth/strategies/codebar.rb index 1e61da0dd..9e668113d 100644 --- a/lib/omniauth/strategies/codebar.rb +++ b/lib/omniauth/strategies/codebar.rb @@ -88,17 +88,17 @@ def callback_phase email = payload['email'] || payload['sub'] @env['omniauth.auth'] = AuthHash.new({ provider: name, - uid: email, - info: { + uid: email, + info: { email: email, name: payload['name'] || email }, - credentials: { + credentials: { token: tokens['access_token'], expires: tokens['expires_at'], refresh_token: tokens['refresh_token'] }, - extra: { + extra: { raw_info: payload } }) @@ -141,10 +141,11 @@ def exchange_code(code, code_verifier) request['User-Agent'] = 'Codebar Planner/1.0' request.body = URI.encode_www_form({ grant_type: 'authorization_code', - code: code, - client_id: 'planner', - redirect_uri: session.delete('omniauth.codebar.redirect_uri') || callback_url, - code_verifier: code_verifier + code: code, + client_id: 'planner', + redirect_uri: session.delete('omniauth.codebar.redirect_uri') || + callback_url, + code_verifier: code_verifier }) response = http_for(uri).request(request) @@ -168,11 +169,11 @@ def verify_jwt(token) decode = lambda { |jwks| JWT.decode(token, nil, true, { algorithms: %w[RS256], - jwks: jwks, - iss: options.auth_url, - aud: options.audience, - verify_iss: true, - verify_aud: true + jwks: jwks, + iss: options.auth_url, + aud: options.audience, + verify_iss: true, + verify_aud: true }).first } diff --git a/lib/tasks/setup.rake b/lib/tasks/setup.rake index e7addb83a..d493a9f44 100644 --- a/lib/tasks/setup.rake +++ b/lib/tasks/setup.rake @@ -95,7 +95,8 @@ namespace :setup do def check_postgresql if !system('which psql > /dev/null 2>&1') error('PostgreSQL', 'psql not found', - 'Install: brew install postgresql && brew services start postgresql (macOS) or see docs/development-setup.md') + 'Install: brew install postgresql && brew services start postgresql (macOS)' \ + ' or see docs/development-setup.md') return end @@ -112,7 +113,8 @@ namespace :setup do ok('PostgreSQL', "running and accepting connections on #{host}:#{port}") else error('PostgreSQL', "not accepting connections on #{host}:#{port}", - 'Start PostgreSQL: brew services start postgresql (macOS). Check credentials in config/database.yml or env vars.') + 'Start PostgreSQL: brew services start postgresql (macOS).' \ + ' Check credentials in config/database.yml or env vars.') end end diff --git a/spec/components/event_card_component_spec.rb b/spec/components/event_card_component_spec.rb index f831b365e..9eae9efc2 100644 --- a/spec/components/event_card_component_spec.rb +++ b/spec/components/event_card_component_spec.rb @@ -86,5 +86,4 @@ expect(page).to have_text('Attending') end end - end diff --git a/spec/controllers/member/details_controller_spec.rb b/spec/controllers/member/details_controller_spec.rb index f67c23ef8..636e474b1 100644 --- a/spec/controllers/member/details_controller_spec.rb +++ b/spec/controllers/member/details_controller_spec.rb @@ -97,7 +97,6 @@ expect(response.body).to include('You must select one option') end - end end end diff --git a/spec/controllers/payments_controller_spec.rb b/spec/controllers/payments_controller_spec.rb index f3d1caa2d..6950159a0 100644 --- a/spec/controllers/payments_controller_spec.rb +++ b/spec/controllers/payments_controller_spec.rb @@ -42,6 +42,5 @@ expect(response).to be_successful end end - end end diff --git a/spec/features/admin/member_search_spec.rb b/spec/features/admin/member_search_spec.rb index 919ee2bb1..76bda891d 100644 --- a/spec/features/admin/member_search_spec.rb +++ b/spec/features/admin/member_search_spec.rb @@ -13,5 +13,4 @@ expect(page).to have_text('Juliet Capulet') end - end diff --git a/spec/features/manage_contact_preferences_spec.rb b/spec/features/manage_contact_preferences_spec.rb index 349524551..0e5956872 100644 --- a/spec/features/manage_contact_preferences_spec.rb +++ b/spec/features/manage_contact_preferences_spec.rb @@ -1,5 +1,4 @@ RSpec.feature 'Managing contact preferences', type: :feature do - context 'A sponsor contact can manage their contact preferences' do let(:manager) { Fabricate(:member) } diff --git a/spec/features/viewing_pages_spec.rb b/spec/features/viewing_pages_spec.rb index 46225f8fd..cb346b1b6 100644 --- a/spec/features/viewing_pages_spec.rb +++ b/spec/features/viewing_pages_spec.rb @@ -18,5 +18,4 @@ expect(page).to have_text('Page not found') end - end diff --git a/spec/helpers/email_header_helper_spec.rb b/spec/helpers/email_header_helper_spec.rb index 5b5c5d216..f7a7a0bb4 100644 --- a/spec/helpers/email_header_helper_spec.rb +++ b/spec/helpers/email_header_helper_spec.rb @@ -73,5 +73,4 @@ helper.mail_to_member(member, 'Test Subject', 'from@codebar.io', 'cc@codebar.io', 'bcc@codebar.io') end end - end diff --git a/spec/lib/services/mailing_list_spec.rb b/spec/lib/services/mailing_list_spec.rb index 9120eaeb1..1293d6260 100644 --- a/spec/lib/services/mailing_list_spec.rb +++ b/spec/lib/services/mailing_list_spec.rb @@ -19,9 +19,9 @@ expect(client).to receive(:subscribe) .with({ email: :email, - first_name: :first_name, - last_name: :last_name, - segment_ids: [:list_id] + first_name: :first_name, + last_name: :last_name, + segment_ids: [:list_id] }) mailing_list.subscribe(:email, :first_name, :last_name) diff --git a/spec/models/eligibility_inquiry_spec.rb b/spec/models/eligibility_inquiry_spec.rb index 973c902ff..311dd930c 100644 --- a/spec/models/eligibility_inquiry_spec.rb +++ b/spec/models/eligibility_inquiry_spec.rb @@ -8,6 +8,5 @@ expect(eligibility_inquiry.issued_by).to eq(admin) end - end end diff --git a/spec/models/feedback_request_spec.rb b/spec/models/feedback_request_spec.rb index 5e64b4818..01ef66a0a 100644 --- a/spec/models/feedback_request_spec.rb +++ b/spec/models/feedback_request_spec.rb @@ -23,5 +23,4 @@ end end end - end diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 038147b81..91b2817d9 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -10,8 +10,8 @@ # Try multiple patterns to find the headless shell executable on different platforms cache_dir = File.expand_path('~/.cache/ms-playwright') patterns = [ - 'chromium_headless_shell-*/**/headless_shell', # Linux - 'chromium_headless_shell-*/**/chrome-headless-shell' # Mac + 'chromium_headless_shell-*/**/headless_shell', # Linux + 'chromium_headless_shell-*/**/chrome-headless-shell' # Mac ] headless_shell = patterns.map do |pattern| diff --git a/spec/support/shared_examples/behaves_like_sending_workshop_emails.rb b/spec/support/shared_examples/behaves_like_sending_workshop_emails.rb index 03f6999fc..7cd6a6a0e 100644 --- a/spec/support/shared_examples/behaves_like_sending_workshop_emails.rb +++ b/spec/support/shared_examples/behaves_like_sending_workshop_emails.rb @@ -9,7 +9,7 @@ expect do manager.send(send_email, workshop, 'students') end.to change { ActionMailer::Base.deliveries.count }.by(students.count) - .and change { WorkshopInvitation.where(workshop: workshop, role: 'Student').count }.by(students.count) + .and change { WorkshopInvitation.where(workshop: workshop, role: 'Student').count }.by(students.count) # Verify emails were sent to the right recipients emails = ActionMailer::Base.deliveries.last(students.count) @@ -27,7 +27,7 @@ expect do manager.send(send_email, workshop, 'coaches') end.to change { ActionMailer::Base.deliveries.count }.by(coaches.count) - .and change { WorkshopInvitation.where(workshop: workshop, role: 'Coach').count }.by(coaches.count) + .and change { WorkshopInvitation.where(workshop: workshop, role: 'Coach').count }.by(coaches.count) # Verify emails were sent to the right recipients emails = ActionMailer::Base.deliveries.last(coaches.count)