Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Ruby 2.5 support #697

Merged
merged 1 commit into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ workflows:
build:
jobs:
- documentation-checks
- rake_default:
name: Ruby 2.5
image: cimg/ruby:2.5
- rake_default:
name: Ruby 2.6
image: cimg/ruby:2.6
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ AllCops:
- 'vendor/**/*'
- 'spec/fixtures/**/*'
- 'tmp/**/*'
TargetRubyVersion: 2.5
TargetRubyVersion: 2.6
SuggestExtensions: false

InternalAffairs/NodeMatcherDirective:
Expand Down
1 change: 1 addition & 0 deletions changelog/change_drop_ruby_2_5_support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#697](https://github.com/rubocop/rubocop-rails/pull/697): **(Breaking)** Drop Ruby 2.5 support. ([@koic][])
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/ignored_skip_action_filter_option.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def on_send(node)
def options_hash(options)
options.pairs
.select { |pair| pair.key.sym_type? }
.map { |pair| [pair.key.value, pair] }.to_h
.to_h { |pair| [pair.key.value, pair] }
end

def if_and_only?(options)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/safe_navigation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def on_send(node)

def autocorrect(corrector, node)
method_node, *params = *node.arguments
method = method_node.source[1..-1]
method = method_node.source[1..]

range = if node.receiver
range_between(node.loc.dot.begin_pos, node.loc.expression.end_pos)
Expand Down
2 changes: 1 addition & 1 deletion rubocop-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Gem::Specification.new do |s|
s.name = 'rubocop-rails'
s.version = RuboCop::Rails::Version::STRING
s.platform = Gem::Platform::RUBY
s.required_ruby_version = '>= 2.5.0'
s.required_ruby_version = '>= 2.6.0'
s.authors = ['Bozhidar Batsov', 'Jonas Arvidsson', 'Yuji Nakayama']
s.description = <<~DESCRIPTION
Automatic Rails code style checking tool.
Expand Down
26 changes: 8 additions & 18 deletions spec/rubocop/cop/rails/index_by_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,24 +145,14 @@
RUBY
end

context 'when using Ruby 2.6 or newer', :ruby26 do
it 'registers an offense for `to_h { ... }`' do
expect_offense(<<~RUBY)
x.to_h { |el| [el.to_sym, el] }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `index_by` over `to_h { ... }`.
RUBY

expect_correction(<<~RUBY)
x.index_by { |el| el.to_sym }
RUBY
end
end
it 'registers an offense for `to_h { ... }`' do
expect_offense(<<~RUBY)
x.to_h { |el| [el.to_sym, el] }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `index_by` over `to_h { ... }`.
RUBY

context 'when using Ruby 2.5 or older', :ruby25 do
it 'does not register an offense for `to_h { ... }`' do
expect_no_offenses(<<~RUBY)
x.to_h { |el| [el.to_sym, el] }
RUBY
end
expect_correction(<<~RUBY)
x.index_by { |el| el.to_sym }
RUBY
end
end
32 changes: 10 additions & 22 deletions spec/rubocop/cop/rails/index_with_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,25 +118,15 @@
RUBY
end

context 'when using Ruby 2.6 or newer', :ruby26 do
it 'registers an offense for `to_h { ... }`' do
expect_offense(<<~RUBY)
x.to_h { |el| [el, el.to_sym] }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `index_with` over `to_h { ... }`.
RUBY

expect_correction(<<~RUBY)
x.index_with { |el| el.to_sym }
RUBY
end
end
it 'registers an offense for `to_h { ... }`' do
expect_offense(<<~RUBY)
x.to_h { |el| [el, el.to_sym] }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `index_with` over `to_h { ... }`.
RUBY

context 'when using Ruby 2.5 or older', :ruby25 do
it 'does not register an offense for `to_h { ... }`' do
expect_no_offenses(<<~RUBY)
x.to_h { |el| [el, el.to_sym] }
RUBY
end
expect_correction(<<~RUBY)
x.index_with { |el| el.to_sym }
RUBY
end
end

Expand All @@ -145,10 +135,8 @@
expect_no_offenses('x.each_with_object({}) { |el, h| h[el] = foo(el) }')
end

context 'when using Ruby 2.6 or newer', :ruby26 do
it 'does not register an offense for `to_h { ... }`' do
expect_no_offenses('x.to_h { |el| [el, el.to_sym] }')
end
it 'does not register an offense for `to_h { ... }`' do
expect_no_offenses('x.to_h { |el| [el, el.to_sym] }')
end

it 'does not register an offense for `map { ... }.to_h`' do
Expand Down