diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3ca89b264..85df1262f 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 13:09:10 UTC using RuboCop version 1.88.2. +# on 2026-07-28 13:24:16 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 @@ -28,12 +28,6 @@ Lint/AmbiguousBlockAssociation: - 'spec/models/feedback_spec.rb' - 'spec/services/three_month_email_service_spec.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Lint/AmbiguousOperator: - Exclude: - - 'spec/controllers/admin/workshops_controller_spec.rb' - # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowSafeAssignment. @@ -62,12 +56,6 @@ Lint/MissingSuper: Exclude: - 'app/components/event_card_component.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Lint/RedundantStringCoercion: - Exclude: - - 'spec/features/admin/sponsor_spec.rb' - # Offense count: 1 # Configuration parameters: AllowKeywordBlockArguments. Lint/UnderscorePrefixedVariableName: @@ -273,12 +261,6 @@ RSpec/AnyInstance: - 'spec/controllers/member/details_controller_spec.rb' - 'spec/support/helpers/login_helpers.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -RSpec/BeEmpty: - Exclude: - - 'spec/presenters/event_presenter_spec.rb' - # Offense count: 25 # This cop supports unsafe autocorrection (--autocorrect-all). RSpec/BeEq: @@ -294,13 +276,6 @@ RSpec/BeEq: - 'spec/presenters/workshop_presenter_spec.rb' - 'spec/support/shared_examples/behaves_like_an_invitation_route.rb' -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: NegatedMatcher. -RSpec/ChangeByZero: - Exclude: - - 'spec/controllers/admin/sponsors_controller_spec.rb' - # Offense count: 67 # This cop supports safe autocorrection (--autocorrect). RSpec/ContextMethod: @@ -515,14 +490,6 @@ RSpec/InstanceVariable: - 'spec/features/admin/add_user_to_workshop_spec.rb' - 'spec/features/member_feedback_spec.rb' -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: it_behaves_like, it_should_behave_like -RSpec/ItBehavesLike: - Exclude: - - 'spec/models/workshop_spec.rb' - # Offense count: 1 RSpec/LeakyConstantDeclaration: Exclude: @@ -773,14 +740,6 @@ Rails/Blank: - 'app/controllers/application_controller.rb' - 'lib/omniauth/strategies/codebar.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: slashes, arguments -Rails/FilePath: - Exclude: - - 'spec/controllers/admin/sponsors_controller_spec.rb' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedMethods, AllowedPatterns. @@ -870,34 +829,6 @@ Rails/UniqueValidationWithoutIndex: - 'app/models/workshop_invitation.rb' - 'app/models/workshop_sponsor.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Keywords, RequireColon. -# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE -Style/CommentAnnotation: - Exclude: - - 'spec/services/invitation_manager_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -Style/DefWithParentheses: - Exclude: - - 'app/helpers/email_header_helper.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/ExpandPathArguments: - Exclude: - - 'spec/spec_helper.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: braces, no_braces -Style/HashAsLastArrayItem: - Exclude: - - 'app/models/sponsor.rb' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: InverseMethods, InverseBlocks. @@ -905,36 +836,12 @@ 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: Exclude: - 'spec/presenters/address_presenter_spec.rb' -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: both, prefix, postfix -Style/NegatedIf: - Exclude: - - 'lib/tasks/setup.rake' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedOctalStyle. -# SupportedOctalStyles: zero_with_o, zero_only -Style/NumericLiteralPrefix: - Exclude: - - 'spec/features/admin/workshops_spec.rb' - # Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. @@ -958,21 +865,6 @@ Style/RedundantInterpolation: - 'script/benchmark_events.rb' - 'spec/features/admin/sponsor_spec.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowMultipleReturnValues. -Style/RedundantReturn: - Exclude: - - 'lib/omniauth/strategies/codebar.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, AllowInnerSlashes. -# SupportedStyles: slashes, percent_r, mixed -Style/RegexpLiteral: - Exclude: - - 'spec/spec_helper.rb' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. diff --git a/app/helpers/email_header_helper.rb b/app/helpers/email_header_helper.rb index 418dd5adb..4af6fd728 100644 --- a/app/helpers/email_header_helper.rb +++ b/app/helpers/email_header_helper.rb @@ -1,9 +1,9 @@ module EmailHeaderHelper class SkippedEmail - def deliver_now() = self - def deliver_later() = self - def deliver() = self - def deliver!() = self + def deliver_now = self + def deliver_later = self + def deliver = self + def deliver! = self end private diff --git a/app/models/sponsor.rb b/app/models/sponsor.rb index 52b5b8ce3..a4ab7caa7 100644 --- a/app/models/sponsor.rb +++ b/app/models/sponsor.rb @@ -19,7 +19,7 @@ class Sponsor < ApplicationRecord class_name: 'Sponsorship', inverse_of: :sponsor has_many :events, through: :event_sponsorships has_many :workshop_sponsors, lambda { - includes([workshop: :chapter]) + includes([{ workshop: :chapter }]) .joins(:workshop) .order('workshops.date_and_time desc') }, diff --git a/app/models/workshop_invitation.rb b/app/models/workshop_invitation.rb index df46751d6..ee5a7dfff 100644 --- a/app/models/workshop_invitation.rb +++ b/app/models/workshop_invitation.rb @@ -23,7 +23,7 @@ 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, -> { + scope :with_notes_and_their_authors, lambda { includes(member: [{ member_notes: :author }, :attendance_warnings]).includes(:overrider) } diff --git a/lib/omniauth/strategies/codebar.rb b/lib/omniauth/strategies/codebar.rb index 461082207..f6de6c965 100644 --- a/lib/omniauth/strategies/codebar.rb +++ b/lib/omniauth/strategies/codebar.rb @@ -107,7 +107,7 @@ def callback_phase rescue StandardError => e return if env['omniauth.error'] - return fail!(:unknown_error, e) + fail!(:unknown_error, e) end private diff --git a/lib/tasks/setup.rake b/lib/tasks/setup.rake index d493a9f44..fd887a223 100644 --- a/lib/tasks/setup.rake +++ b/lib/tasks/setup.rake @@ -93,7 +93,7 @@ namespace :setup do end def check_postgresql - if !system('which psql > /dev/null 2>&1') + unless 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') @@ -128,7 +128,7 @@ namespace :setup do end def check_github_credentials - if !File.exist?('mise.local.toml') + unless File.exist?('mise.local.toml') error('GitHub OAuth', 'mise.local.toml not found', 'Copy: cp mise.local.toml.example mise.local.toml, then edit with your GitHub app credentials.') return diff --git a/spec/controllers/admin/sponsors_controller_spec.rb b/spec/controllers/admin/sponsors_controller_spec.rb index 14f6174bc..e5aaf5ed5 100644 --- a/spec/controllers/admin/sponsors_controller_spec.rb +++ b/spec/controllers/admin/sponsors_controller_spec.rb @@ -3,7 +3,7 @@ let(:member1) { Fabricate(:member) } let(:address) { Fabricate(:address) } let(:admin) { Fabricate(:chapter_organiser) } - let(:avatar) { Rack::Test::UploadedFile.new(Rails.root.join('app', 'assets', 'images', 'logo.png'), 'image/png') } + let(:avatar) { Rack::Test::UploadedFile.new(Rails.root.join('app/assets/images/logo.png'), 'image/png') } let(:sponsor) { Fabricate(:sponsor) } describe 'POST #create' do @@ -15,7 +15,7 @@ address: address, avatar: avatar, members: [1, 2] } } - end.to change(Sponsor, :count).by(0) + end.not_to change(Sponsor, :count) end it "Doesn't allow regular users to create sponsors" do @@ -28,7 +28,7 @@ address: address, avatar: avatar } } - end.to change(Sponsor, :count).by(0) + end.not_to change(Sponsor, :count) end context 'Allows chapter organisers to create sponsors with' do @@ -98,7 +98,7 @@ address: '', avatar: '', members: [] } } - end.to change(Sponsor, :count).by(0) + end.not_to change(Sponsor, :count) end end diff --git a/spec/controllers/admin/workshops_controller_spec.rb b/spec/controllers/admin/workshops_controller_spec.rb index fca26ee61..b7eeea555 100644 --- a/spec/controllers/admin/workshops_controller_spec.rb +++ b/spec/controllers/admin/workshops_controller_spec.rb @@ -73,7 +73,7 @@ it 'should successfully delete the workshop' do expect do delete :destroy, params: { id: workshop.id } - end.to change { Workshop.count }.by -1 + end.to change { Workshop.count }.by(-1) end it 'should display workshop deleted successfully related flash message' do diff --git a/spec/features/admin/sponsor_spec.rb b/spec/features/admin/sponsor_spec.rb index 7349e597d..76dc7b01b 100644 --- a/spec/features/admin/sponsor_spec.rb +++ b/spec/features/admin/sponsor_spec.rb @@ -136,7 +136,7 @@ within '#sponsorships' do expect(page).to have_text('Events') - expect(page).to have_text("#{gold_event.to_s} - GOLD") + expect(page).to have_text("#{gold_event} - GOLD") expect(page).to have_text("#{silver_event} - SILVER") expect(page).to have_text("#{standard_event} - Standard") end diff --git a/spec/features/admin/workshops_spec.rb b/spec/features/admin/workshops_spec.rb index 881b59152..140c3d102 100644 --- a/spec/features/admin/workshops_spec.rb +++ b/spec/features/admin/workshops_spec.rb @@ -40,7 +40,7 @@ context '#creation' do context 'creating a workshop' do around do |example| - travel_to Time.zone.local(2020, 12, 01, 0, 0, 0) + travel_to Time.zone.local(2020, 12, 0o1, 0, 0, 0) example.run travel_back end diff --git a/spec/models/workshop_spec.rb b/spec/models/workshop_spec.rb index 30928f04c..446166b7e 100644 --- a/spec/models/workshop_spec.rb +++ b/spec/models/workshop_spec.rb @@ -109,11 +109,11 @@ end context 'with rsvp_open' do - it_should_behave_like 'date_time_fields_must_be_paired', 'rsvp_open' + it_behaves_like 'date_time_fields_must_be_paired', 'rsvp_open' end context 'with rsvp_close' do - it_should_behave_like 'date_time_fields_must_be_paired', 'rsvp_close' + it_behaves_like 'date_time_fields_must_be_paired', 'rsvp_close' end end diff --git a/spec/presenters/event_presenter_spec.rb b/spec/presenters/event_presenter_spec.rb index 675501647..ffd129f19 100644 --- a/spec/presenters/event_presenter_spec.rb +++ b/spec/presenters/event_presenter_spec.rb @@ -30,7 +30,7 @@ describe '#organisers' do it 'when there are no organisers' do - expect(event.organisers).to match_array([]) + expect(event.organisers).to be_empty end it 'when there are organisers' do diff --git a/spec/services/invitation_manager_spec.rb b/spec/services/invitation_manager_spec.rb index 5eb191d2b..715a25cc4 100644 --- a/spec/services/invitation_manager_spec.rb +++ b/spec/services/invitation_manager_spec.rb @@ -145,7 +145,7 @@ end describe '#send_workshop_waiting_list_reminders', :wip do - # Note: This test is WIP because the method is async + # NOTE: This test is WIP because the method is async it 'emails everyone that hasn\'t already been reminded from the workshop\'s waitinglist' do workshop = Fabricate(:workshop) invitations = Fabricate.times(2, :waitinglist_invitation, workshop: workshop) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 22c232bea..659006747 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -37,7 +37,7 @@ end ENV['RAILS_ENV'] ||= 'test' -require File.expand_path('../../config/environment', __FILE__) +require File.expand_path('../config/environment', __dir__) require 'rspec/rails' # Block all external HTTP requests in tests; allows localhost for Capybara @@ -70,7 +70,7 @@ config.before(:each) do # Stub all Flodesk API endpoints globally so tests don't make external requests # when fabricating members (which trigger Subscription.after_create callback) - WebMock.stub_request(:any, %r{api\.flodesk\.com}) + WebMock.stub_request(:any, /api\.flodesk\.com/) .to_return(status: 200, body: '{"status":"active","segments":[]}', headers: { 'Content-Type' => 'application/json' }) DatabaseCleaner.strategy = :transaction