Skip to content

Commit

Permalink
Require RuboCop 1.30+ as runtime dependency
Browse files Browse the repository at this point in the history
This PR makes RuboCop Performance require RuboCop 1.30+ to fix some errors:
https://github.com/rubocop/rubocop-performance/actions/runs/6966652446/job/18957154150

It introduces CI for the oldest RuboCop version still supported,
implementing a workflow for regression testing that is similar to the one found a
rubocop/rubocop-rails@c9acb7a.
  • Loading branch information
koic committed Nov 24, 2023
1 parent 8232082 commit 4c525a8
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on:
push:
branches:
- master
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
oldest_supported_rubocop:
runs-on: ubuntu-latest
name: The oldest supported RuboCop version
steps:
- uses: actions/checkout@v4
- name: Use the oldest supported RuboCop
run: |
sed -e "/gem 'rubocop', github: 'rubocop\/rubocop'/d" \
-e "/gem 'rubocop-rspec',/d" -i Gemfile
cat << EOF > Gemfile.local
gem 'rubocop', '1.30.0' # Specify the oldest supported RuboCop version
EOF
- name: set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true
- name: spec
run: bundle exec rake spec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#388](https://github.com/rubocop/rubocop-performance/pull/388): Require RuboCop 1.30+ as runtime dependency. ([@koic][])
4 changes: 3 additions & 1 deletion lib/rubocop/cop/performance/redundant_merge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ def to_assignments(receiver, pairs)
end

def rewrite_with_modifier(node, parent, new_source)
indent = ' ' * configured_indentation_width
# FIXME: `|| 2` can be removed when support is limited to RuboCop 1.44 or higher.
# https://github.com/rubocop/rubocop/commit/02d1e5b
indent = ' ' * (configured_indentation_width || 2)
padding = "\n#{indent + leading_spaces(node)}"
new_source.gsub!("\n", padding)

Expand Down
2 changes: 1 addition & 1 deletion rubocop-performance.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ Gem::Specification.new do |s|
'rubygems_mfa_required' => 'true'
}

s.add_runtime_dependency('rubocop', '>= 1.7.0', '< 2.0')
s.add_runtime_dependency('rubocop', '>= 1.30.0', '< 2.0')
s.add_runtime_dependency('rubocop-ast', '>= 1.30.0', '< 2.0')
end

0 comments on commit 4c525a8

Please sign in to comment.