From a8c416a13308de56f9fc756c4e3237fbd836f36f Mon Sep 17 00:00:00 2001 From: MarttiCheng Date: Tue, 26 Apr 2022 00:39:44 +0900 Subject: [PATCH] Drop Ruby 2.5 support Follow up https://github.com/rubocop/rubocop/pull/10577. --- .circleci/config.yml | 3 --- .rubocop.yml | 2 +- changelog/change_drop_ruby_2_5_support.md | 1 + lib/rubocop/cop/mixin/regexp_metacharacter.rb | 4 ++-- lib/rubocop/cop/performance/case_when_splat.rb | 2 +- rubocop-performance.gemspec | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) create mode 100644 changelog/change_drop_ruby_2_5_support.md diff --git a/.circleci/config.yml b/.circleci/config.yml index ee76813..a663940 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 diff --git a/.rubocop.yml b/.rubocop.yml index 6d5a66a..f959c48 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ AllCops: - 'vendor/**/*' - 'spec/fixtures/**/*' - 'tmp/**/*' - TargetRubyVersion: 2.5 + TargetRubyVersion: 2.6 SuggestExtensions: false InternalAffairs/NodeMatcherDirective: diff --git a/changelog/change_drop_ruby_2_5_support.md b/changelog/change_drop_ruby_2_5_support.md new file mode 100644 index 0000000..7dfac90 --- /dev/null +++ b/changelog/change_drop_ruby_2_5_support.md @@ -0,0 +1 @@ +* [#287](https://github.com/rubocop/rubocop-performance/pull/287): **(Breaking)** Drop Ruby 2.5 support. ([@koic][]) diff --git a/lib/rubocop/cop/mixin/regexp_metacharacter.rb b/lib/rubocop/cop/mixin/regexp_metacharacter.rb index db41b0a..e1f543b 100644 --- a/lib/rubocop/cop/mixin/regexp_metacharacter.rb +++ b/lib/rubocop/cop/mixin/regexp_metacharacter.rb @@ -54,9 +54,9 @@ def literal_at_end_with_dollar?(regex_str) def drop_start_metacharacter(regexp_string) if regexp_string.start_with?('\\A') - regexp_string[2..-1] # drop `\A` anchor + regexp_string[2..] # drop `\A` anchor else - regexp_string[1..-1] # drop `^` anchor + regexp_string[1..] # drop `^` anchor end end diff --git a/lib/rubocop/cop/performance/case_when_splat.rb b/lib/rubocop/cop/performance/case_when_splat.rb index 241bc8a..ab533a5 100644 --- a/lib/rubocop/cop/performance/case_when_splat.rb +++ b/lib/rubocop/cop/performance/case_when_splat.rb @@ -168,7 +168,7 @@ def non_splat?(condition) def needs_reorder?(when_node) following_branches = - when_node.parent.when_branches[(when_node.branch_index + 1)..-1] + when_node.parent.when_branches[(when_node.branch_index + 1)..] following_branches.any? do |when_branch| when_branch.conditions.any? do |condition| diff --git a/rubocop-performance.gemspec b/rubocop-performance.gemspec index 57b6fe7..c481e24 100644 --- a/rubocop-performance.gemspec +++ b/rubocop-performance.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |s| s.name = 'rubocop-performance' s.version = RuboCop::Performance::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 A collection of RuboCop cops to check for performance optimizations