Skip to content

Commit

Permalink
Drop Ruby 2.5 support
Browse files Browse the repository at this point in the history
This includes the following changes:

This PR drops Ruby 2.5 support.
And CRuby 2.5 compatible JRuby 9.2 will be dropped and CRuby 2.6 compatible
JRuby 9.3 or higher is required.
  • Loading branch information
koic authored and bbatsov committed Apr 25, 2022
1 parent 7fb0157 commit 1a60305
Show file tree
Hide file tree
Showing 71 changed files with 420 additions and 576 deletions.
31 changes: 1 addition & 30 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,6 @@ rubocop_steps: &rubocop_steps
jobs:

# Ruby 2.5
ruby-2.5-spec:
docker:
- image: cimg/ruby:2.5
environment:
<<: *common_env
steps:
*spec_steps
ruby-2.5-ascii_spec:
docker:
- image: cimg/ruby:2.5
environment:
<<: *common_env
steps:
*ascii_spec_steps
ruby-2.5-rubocop:
docker:
- image: cimg/ruby:2.5
environment:
<<: *common_env
steps:
*rubocop_steps

# Ruby 2.6
ruby-2.6-spec:
docker:
Expand Down Expand Up @@ -244,7 +221,7 @@ jobs:
- run:
name: Upload coverage results to Code Climate
command: |
./tmp/cc-test-reporter sum-coverage tmp/codeclimate.*.json --parts 6 --output tmp/codeclimate.total.json
./tmp/cc-test-reporter sum-coverage tmp/codeclimate.*.json --parts 5 --output tmp/codeclimate.total.json
./tmp/cc-test-reporter upload-coverage --input tmp/codeclimate.total.json
# Miscellaneous tasks
Expand All @@ -267,11 +244,6 @@ workflows:
jobs:
- documentation-checks
- cc-setup
- ruby-2.5-spec:
requires:
- cc-setup
- ruby-2.5-ascii_spec
- ruby-2.5-rubocop
- ruby-2.6-spec:
requires:
- cc-setup
Expand Down Expand Up @@ -308,7 +280,6 @@ workflows:

- cc-upload-coverage:
requires:
- ruby-2.5-spec
- ruby-2.6-spec
- ruby-2.7-spec
- ruby-3.0-spec
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
# [ubuntu, macos, windows]
os: [windows]
ruby: ['2.5', '2.6', '2.7', '3.0', '3.1', 'head']
ruby: ['2.6', '2.7', '3.0', '3.1', 'head']
include:
- os: windows
ruby: mingw
Expand Down
4 changes: 0 additions & 4 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pull_request_rules:
- label=auto-merge
- "#review-requested=0"
- "#changes-requested-reviews-by=0"
- "status-success=windows 2.5"
- "status-success=windows 2.6"
- "status-success=windows 2.7"
- "status-success=windows 3.0"
Expand All @@ -20,9 +19,6 @@ pull_request_rules:
- "status-success=ci/circleci: jruby-9.2-ascii_spec"
- "status-success=ci/circleci: jruby-9.2-rubocop"
- "status-success=ci/circleci: jruby-9.2-spec"
- "status-success=ci/circleci: ruby-2.5-ascii_spec"
- "status-success=ci/circleci: ruby-2.5-rubocop"
- "status-success=ci/circleci: ruby-2.5-spec"
- "status-success=ci/circleci: ruby-2.6-ascii_spec"
- "status-success=ci/circleci: ruby-2.6-rubocop"
- "status-success=ci/circleci: ruby-2.6-spec"
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ AllCops:
- 'tmp/**/*'
- '.git/**/*'
- 'bin/*'
TargetRubyVersion: 2.5
TargetRubyVersion: 2.6
SuggestExtensions: false

Naming/PredicateName:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ You can read a lot more about RuboCop in its [official docs](https://docs.ruboco

RuboCop officially supports the following Ruby implementations:

* MRI 2.5+
* JRuby 9.2+
* MRI 2.6+
* JRuby 9.3+

See the [compatibility documentation](https://docs.rubocop.org/rubocop/compatibility.html) for further details.

Expand Down
1 change: 1 addition & 0 deletions changelog/change_drop_ruby_25.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#10577](https://github.com/rubocop/rubocop/pull/10577): **(Breaking)** Drop support for Ruby 2.5 and JRuby 9.2 (CRuby 2.5 compatible). ([@koic][])
2 changes: 1 addition & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ AllCops:
# or gems.locked file. (Although the Ruby version is specified in the Gemfile
# or gems.rb file, RuboCop reads the final value from the lock file.) If the
# Ruby version is still unresolved, RuboCop will use the oldest officially
# supported Ruby version (currently Ruby 2.5).
# supported Ruby version (currently Ruby 2.6).
TargetRubyVersion: ~
# Determines if a notification for extension libraries should be shown when
# rubocop is run. Keys are the name of the extension, and values are an array
Expand Down
10 changes: 5 additions & 5 deletions docs/modules/ROOT/pages/compatibility.adoc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
= Compatibility

RuboCop targets Ruby 2.5+.footnote:[As defined by its reference implementation MRI.]
RuboCop targets Ruby 2.6+.footnote:[As defined by its reference implementation MRI.]

RuboCop officially supports MRI (a.k.a. CRuby) and JRuby.

- MRI 2.5+
- JRuby 9.2+
- MRI 2.6+
- JRuby 9.3+
The oldest supported JRuby version is derived from the oldest compatible MRI version.

Expand All @@ -14,7 +14,7 @@ NOTE: RuboCop might be working with other Ruby implementations as well, but it's
== Support Matrix

RuboCop generally aims to follow MRI's own support policy - meaning RuboCop would support all officially supported MRI releases.footnote:[Typically the last 3 releases.] To give people extra time for a smooth transition, we've customarily provided support for about one year after EOL of MRI version.
This means that if Ruby 2.5 reaches its EOL in Spring 2021, it would be supported by RuboCop (at least) until Spring 2022.footnote:[At the core team's discretion this policy might be waived aside for MRI releases causing significant maintenance overhead.]
This means that if Ruby 2.6 reaches its EOL in Spring 2022, it would be supported by RuboCop (at least) until Spring 2023.footnote:[At the core team's discretion this policy might be waived aside for MRI releases causing significant maintenance overhead.]

The following table is the support matrix.

Expand All @@ -27,7 +27,7 @@ The following table is the support matrix.
| 2.2 | 0.68
| 2.3 | 0.81
| 2.4 | 1.12
| 2.5 | -
| 2.5 | 1.28
| 2.6 | -
| 2.7 | -
| 3.0 | -
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/badge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Badge
def self.for(class_name)
parts = class_name.split('::')
name_deep_enough = parts.length >= 4
new(name_deep_enough ? parts[2..-1] : parts.last(2))
new(name_deep_enough ? parts[2..] : parts.last(2))
end

def self.parse(identifier)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/bundler/duplicated_gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def on_new_investigation
return if processed_source.blank?

duplicated_gem_nodes.each do |nodes|
nodes[1..-1].each do |node|
nodes[1..].each do |node|
register_offense(node, node.first_argument.to_a.first, nodes.first.first_line)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/bundler/gem_comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def version_specified_gem?(node)
def restrictive_version_specified_gem?(node)
return unless version_specified_gem?(node)

node.arguments[1..-1]
node.arguments[1..]
.any? { |arg| arg&.str_type? && RESTRICTIVE_VERSION_PATTERN.match?(arg.value) }
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/gemspec/duplicated_assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def on_new_investigation
return if processed_source.blank?

duplicated_assignment_method_nodes.each do |nodes|
nodes[1..-1].each do |node|
nodes[1..].each do |node|
register_offense(node, node.method_name, nodes.first.first_line)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Gemspec
#
# # bad
# Gem::Specification.new do |spec|
# if RUBY_VERSION >= '2.5'
# if RUBY_VERSION >= '3.0'
# spec.add_runtime_dependency 'gem_a'
# else
# spec.add_runtime_dependency 'gem_b'
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/layout/comment_indentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def own_line_comment?(comment)

def line_after_comment(comment)
lines = processed_source.lines
lines[comment.loc.line..-1].find { |line| !line.blank? }
lines[comment.loc.line..].find { |line| !line.blank? }
end

def correct_indentation(next_line)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def always_indented?(dstr_node)

def check_aligned(children, start_index)
base_column = children[start_index - 1].loc.column
children[start_index..-1].each do |child|
children[start_index..].each do |child|
@column_delta = base_column - child.loc.column
add_offense_and_correction(child, MSG_ALIGN) if @column_delta != 0
base_column = child.loc.column
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/layout/space_around_block_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def check_closing_pipe_space(arguments, closing_pipe)
def last_end_pos_inside_pipes(arguments, range)
pos = range.end_pos
num = pos - arguments.source_range.begin_pos
trailing_comma_index = arguments.source[num..-1].index(',')
trailing_comma_index = arguments.source[num..].index(',')

trailing_comma_index ? pos + trailing_comma_index + 1 : pos
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/layout/space_inside_reference_brackets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def closing_bracket(tokens, opening_bracket)
i = tokens.index(opening_bracket)
inner_left_brackets_needing_closure = 0

tokens[i..-1].each do |token|
tokens[i..].each do |token|
inner_left_brackets_needing_closure += 1 if token.left_bracket?
inner_left_brackets_needing_closure -= 1 if token.right_bracket?
return token if inner_left_brackets_needing_closure.zero? && token.right_bracket?
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/layout/trailing_empty_lines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def ends_in_end?(processed_source)
return true if buffer.source.strip.start_with?('__END__')
return false if processed_source.tokens.empty?

extra = buffer.source[processed_source.tokens.last.end_pos..-1]
extra = buffer.source[processed_source.tokens.last.end_pos..]
extra&.strip&.start_with?('__END__')
end

Expand Down
3 changes: 0 additions & 3 deletions lib/rubocop/cop/lint/erb_new_arguments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,8 @@ module Lint
#
class ErbNewArguments < Base
include RangeHelp
extend TargetRubyVersion
extend AutoCorrector

minimum_target_ruby_version 2.6

MESSAGES = [
'Passing safe_level with the 2nd argument of `ERB.new` is ' \
'deprecated. Do not use it, and specify other arguments as ' \
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def spaces_before_left_parenthesis(node)
else
0
end
without_receiver = node.source[receiver_length..-1]
without_receiver = node.source[receiver_length..]

# Escape question mark if any.
method_regexp = Regexp.escape(node.method_name)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/useless_times.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def fix_indentation(source, range)
# Cleanup indentation in a multiline block
source_lines = source.split("\n")

source_lines[1..-1].each do |line|
source_lines[1..].each do |line|
next if line.empty?

line[range] = ''
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/mixin/duplication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def duplicates(collection)
# @param [Array] collection an array to return consecutive duplicates for
# @return [Array] the consecutive duplicates
def consecutive_duplicates(collection)
grouped_duplicates(collection).flat_map { |items| items[1..-1] }
grouped_duplicates(collection).flat_map { |items| items[1..] }
end

# Returns a hash of grouped duplicates. The key will be the first
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/mixin/preferred_delimiters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def preferred_delimiters
ensure_valid_preferred_delimiters

if preferred_delimiters_config.key?('default')
PERCENT_LITERAL_TYPES.map do |type|
PERCENT_LITERAL_TYPES.to_h do |type|
[type, preferred_delimiters_config[type] || preferred_delimiters_config['default']]
end.to_h
end
else
preferred_delimiters_config
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/mixin/statement_modifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def first_line_comment(node)

def code_after(node)
end_element = node.loc.end
code = end_element.source_line[end_element.last_column..-1]
code = end_element.source_line[end_element.last_column..]
code unless code.empty?
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/mixin/trailing_comma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def put_comma(items, kind)
def autocorrect_range(item)
expr = item.source_range
ix = expr.source.rindex("\n") || 0
ix += expr.source[ix..-1] =~ /\S/
ix += expr.source[ix..] =~ /\S/

range_between(expr.begin_pos + ix, expr.end_pos)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/naming/block_forwarding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def expected_block_forwarding_style?(node, last_argument)
if style == :anonymous
!explicit_block_argument?(last_argument) ||
use_kwarg_in_method_definition?(node) ||
use_block_argument_as_local_variable?(node, last_argument.source[1..-1])
use_block_argument_as_local_variable?(node, last_argument.source[1..])
else
!anonymous_block_argument?(last_argument)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/naming/file_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def to_namespace(path) # rubocop:disable Metrics/AbcSize
if start_index.nil?
[to_module_name(components.last)]
else
components[start_index..-1].map { |c| to_module_name(c) }
components[start_index..].map { |c| to_module_name(c) }
end
end

Expand Down
6 changes: 3 additions & 3 deletions lib/rubocop/cop/style/alias.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def alias_method_possible?(node)

def add_offense_for_args(node, &block)
existing_args = node.children.map(&:source).join(' ')
preferred_args = node.children.map { |a| a.source[1..-1] }.join(' ')
preferred_args = node.children.map { |a| a.source[1..] }.join(' ')
arg_ranges = node.children.map(&:source_range)
msg = format(MSG_SYMBOL_ARGS, prefer: preferred_args, current: existing_args)
add_offense(arg_ranges.reduce(&:join), message: msg, &block)
Expand Down Expand Up @@ -134,8 +134,8 @@ def correct_alias_to_alias_method(corrector, node)
end

def correct_alias_with_symbol_args(corrector, node)
corrector.replace(node.new_identifier, node.new_identifier.source[1..-1])
corrector.replace(node.old_identifier, node.old_identifier.source[1..-1])
corrector.replace(node.new_identifier, node.new_identifier.source[1..])
corrector.replace(node.old_identifier, node.old_identifier.source[1..])
end

# @!method identifier(node)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/style/bisected_attr_accessor/macro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def self.macro?(node)

def initialize(node)
@node = node
@attrs = node.arguments.map { |attr| [attr.source, attr] }.to_h
@attrs = node.arguments.to_h { |attr| [attr.source, attr] }
@bisection = []
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/style/character_literal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def offense?(node)
end

def autocorrect(corrector, node)
string = node.source[1..-1]
string = node.source[1..]

# special character like \n
# or ' which needs to use "" or be escaped.
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/style/empty_case_condition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def correct_case_when(corrector, case_node, when_nodes)

keep_first_when_comment(case_range, corrector)

when_nodes[1..-1].each do |when_node|
when_nodes[1..].each do |when_node|
corrector.replace(when_node.loc.keyword, 'elsif')
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/style/empty_literal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def correction(node)
# because the braces are interpreted as a block. We will have
# to rewrite the arguments to wrap them in parenthesis.
args = node.parent.arguments
"(#{args[1..-1].map(&:source).unshift('{}').join(', ')})"
"(#{args[1..].map(&:source).unshift('{}').join(', ')})"
else
'{}'
end
Expand Down
3 changes: 0 additions & 3 deletions lib/rubocop/cop/style/map_to_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ module Style
#
class MapToHash < Base
extend AutoCorrector
extend TargetRubyVersion
include RangeHelp

minimum_target_ruby_version 2.6

MSG = 'Pass a block to `to_h` instead of calling `%<method>s.to_h`.'
RESTRICT_ON_SEND = %i[to_h].freeze

Expand Down
Loading

0 comments on commit 1a60305

Please sign in to comment.