From b38642d52467575b973e38c31d001d054045b905 Mon Sep 17 00:00:00 2001 From: James Mead Date: Thu, 17 Apr 2025 12:17:01 +0100 Subject: [PATCH 1/2] Remove unnecessary disabling of rubocop cops - Metrics/AbcSize. - RSpec/NestedGroups --- lib/rpi_auth/spec_helpers.rb | 2 +- spec/dummy/spec/requests/auth_request_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/rpi_auth/spec_helpers.rb b/lib/rpi_auth/spec_helpers.rb index 4c6fc8d..e58bef6 100644 --- a/lib/rpi_auth/spec_helpers.rb +++ b/lib/rpi_auth/spec_helpers.rb @@ -5,7 +5,7 @@ module SpecHelpers # This sets up the OmniAuth mock for the given user. It assumes the User # model has an `:user_id` method which returns the users ID, but this can # be changed by setting the `id_param` option. - def stub_auth_for(user:, id_param: :user_id) # rubocop:disable Metrics/AbcSize + def stub_auth_for(user:, id_param: :user_id) expires_at = user.respond_to?(:expires_at) && user.expires_at expires_in = expires_at.present? ? expires_at.to_i - Time.zone.now.to_i : 3600 token = user.respond_to?(:access_token) ? user.access_token : SecureRandom.hex(16) diff --git a/spec/dummy/spec/requests/auth_request_spec.rb b/spec/dummy/spec/requests/auth_request_spec.rb index b91cf5d..9476af1 100644 --- a/spec/dummy/spec/requests/auth_request_spec.rb +++ b/spec/dummy/spec/requests/auth_request_spec.rb @@ -265,7 +265,7 @@ expect(response).to redirect_to('/') end - context 'when the proc resolves to something other than nil' do # rubocop:disable RSpec/NestedGroups + context 'when the proc resolves to something other than nil' do # We use `current_user` and `request.env` here as they're available # in the context of the controller. We use `let!` to make sure the # proc is defined straightaway, rather than later, when `request` and @@ -283,7 +283,7 @@ end end - context 'when the proc raises an exception' do # rubocop:disable RSpec/NestedGroups + context 'when the proc raises an exception' do # We use `current_user` and `request.env` here as they're available # in the context of the controller. We use `let!` to make sure the # proc is defined straightaway, rather than later, when `request` and From f47b373e9ebc0185e9e6a8093cfadd920a13b487 Mon Sep 17 00:00:00 2001 From: James Mead Date: Thu, 17 Apr 2025 12:15:46 +0100 Subject: [PATCH 2/2] Add rubocop linting step to CI build So we don't accidentally introduce violations. --- .github/workflows/test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a062fff..fe03015 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,12 +22,18 @@ jobs: BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile steps: - uses: actions/checkout@v3 + - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} rubygems: 3.4.10 bundler-cache: true # runs 'bundle install' and caches installed gems automatically + + - name: Run linter + if: matrix.ruby-version == '3.3' && matrix.gemfile == 'rails_7.2' + run: bundle exec rubocop + - name: Run tests run: bundle exec rspec