Skip to content

Commit

Permalink
[Fix rubocop#6945] Drop support for Ruby 2.2
Browse files Browse the repository at this point in the history
Fixes rubocop#6945.

By convention, a year after Ruby became an EOL, it seems that the old
Ruby version support has been dropped. I'm not sure if it's good to drop
Ruby 2.3 support, but it's good time to drop Ruby 2.2 support.
  • Loading branch information
koic committed May 8, 2019
1 parent 1939bbe commit bcbcfb8
Show file tree
Hide file tree
Showing 527 changed files with 2,926 additions and 2,763 deletions.
31 changes: 1 addition & 30 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,6 @@ rubocop_steps: &rubocop_steps
jobs:

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

# Ruby 2.3
ruby-2.3-spec:
docker:
Expand Down Expand Up @@ -240,7 +217,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 @@ -265,11 +242,6 @@ workflows:
jobs:
- documentation-checks
- cc-setup
- ruby-2.2-spec:
requires:
- cc-setup
- ruby-2.2-ascii_spec
- ruby-2.2-rubocop
- ruby-2.3-spec:
requires:
- cc-setup
Expand Down Expand Up @@ -303,7 +275,6 @@ workflows:

- cc-upload-coverage:
requires:
- ruby-2.2-spec
- ruby-2.3-spec
- ruby-2.4-spec
- ruby-2.5-spec
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ AllCops:
- 'vendor/**/*'
- 'spec/fixtures/**/*'
- 'tmp/**/*'
TargetRubyVersion: 2.2
TargetRubyVersion: 2.3

Naming/PredicateName:
# Method define macros for dynamically generated method.
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
* [#7007](https://github.com/rubocop-hq/rubocop/pull/7007): Fix `Style/BlockDelimiters` with `braces_for_chaining` style false positive, when chaining using safe navigation. ([@Darhazer][])
* [#6880](https://github.com/rubocop-hq/rubocop/issues/6880): Fix `.rubocop` file parsing. ([@hoshinotsuyoshi][])

### Changes

* [#6945](https://github.com/rubocop-hq/rubocop/issues/6945): Drop support for Ruby 2.2. ([@koic][])

## 0.68.1 (2019-04-30)

### Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ You can read a ton more about RuboCop in its [official manual](https://docs.rubo

RuboCop supports the following Ruby implementations:

* MRI 2.2+
* MRI 2.3+
* JRuby 9.0+

The Rails cops support the following versions:
Expand Down
2 changes: 1 addition & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ AllCops:
# followed by the Gemfile.lock 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.2).
# use the oldest officially supported Ruby version (currently Ruby 2.3).
TargetRubyVersion: ~
# What version of Rails is the inspected code using? If a value is specified
# for TargetRailsVersion then it is used. Acceptable values are specificed
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/ast/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,11 @@ def call_type?
end

def chained?
parent && parent.call_type? && eql?(parent.receiver)
parent&.call_type? && eql?(parent.receiver)
end

def argument?
parent && parent.send_type? && parent.arguments.include?(self)
parent&.send_type? && parent.arguments.include?(self)
end

def numeric_type?
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/ast/node/array_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def values
#
# @return [Boolean] whether the array is enclosed in square brackets
def square_brackets?
loc.begin && loc.begin.is?('[')
loc.begin&.is?('[')
end

# Checks whether the `array` literal is delimited by percent brackets.
Expand All @@ -40,7 +40,7 @@ def percent_literal?(type = nil)
if type
loc.begin && loc.begin.source =~ PERCENT_LITERAL_TYPES[type]
else
loc.begin && loc.begin.source.start_with?('%')
loc.begin&.source&.start_with?('%')
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/ast/node/block_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ def arguments?
#
# @return [Boolean] whether the `block` literal is enclosed in braces
def braces?
loc.end && loc.end.is?('}')
loc.end&.is?('}')
end

# Checks whether the `block` literal is delimited by `do`-`end` keywords.
#
# @return [Boolean] whether the `block` literal is enclosed in `do`-`end`
def keywords?
loc.end && loc.end.is?('end')
loc.end&.is?('end')
end

# The delimiters for this `block` literal.
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/ast/node/for_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def keyword
#
# @return [Boolean] whether the `for` node has a `do` keyword
def do?
loc.begin && loc.begin.is?('do')
loc.begin&.is?('do')
end

# Checks whether this node body is a void context.
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/ast/node/hash_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def mixed_delimiters?
#
# @return [Boolean] whether the `hash` literal is enclosed in braces
def braces?
loc.end && loc.end.is?('}')
loc.end&.is?('}')
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/ast/node/if_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def nested_conditional?
#
# @return [Boolean] whether the `if` node has at least one `elsif` branch
def elsif_conditional?
else_branch && else_branch.if_type? && else_branch.elsif?
else_branch&.if_type? && else_branch&.elsif?
end

# Returns the branch of the `if` node that gets evaluated when its
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/ast/node/keyword_splat_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module AST
class KeywordSplatNode < Node
include HashElementNode

DOUBLE_SPLAT = '**'.freeze
DOUBLE_SPLAT = '**'

# This is used for duck typing with `pair` nodes which also appear as
# `hash` elements.
Expand Down
6 changes: 3 additions & 3 deletions lib/rubocop/ast/node/mixin/method_dispatch_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def double_colon?
#
# @return [Boolean] whether the receiver of this method dispatch is `self`
def self_receiver?
receiver && receiver.self_type?
receiver&.self_type?
end

# Checks whether the *explicit* receiver of this method dispatch is a
Expand All @@ -125,7 +125,7 @@ def self_receiver?
# @return [Boolean] whether the receiver of this method dispatch
# is a `const` node
def const_receiver?
receiver && receiver.const_type?
receiver&.const_type?
end

# Checks whether the method dispatch is the implicit form of `#call`,
Expand All @@ -140,7 +140,7 @@ def implicit_call?
#
# @return [Boolean] whether the dispatched method has a block
def block_literal?
parent && parent.block_type? && eql?(parent.send_node)
parent&.block_type? && eql?(parent.send_node)
end

# Checks whether this node is an arithmetic operation
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/ast/node/mixin/method_identifier_predicates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ def camel_case_method?
#
# @return [Boolean] whether the receiver of this node is `self`
def self_receiver?
receiver && receiver.self_type?
receiver&.self_type?
end

# Checks whether the *explicit* receiver of node is a `const` node.
#
# @return [Boolean] whether the receiver of this node is a `const` node
def const_receiver?
receiver && receiver.const_type?
receiver&.const_type?
end

# Checks whether this is a negation method, i.e. `!` or keyword `not`.
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/ast/node/mixin/parameterized_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module ParameterizedNode
# @return [Boolean] whether this node's arguments are
# wrapped in parentheses
def parenthesized?
loc.end && loc.end.is?(')')
loc.end&.is?(')')
end

# A shorthand for getting the first argument of the node.
Expand Down
8 changes: 4 additions & 4 deletions lib/rubocop/ast/node/mixin/predicate_operator_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ module AST
# Common functionality for nodes that are predicates:
# `or`, `and` ...
module PredicateOperatorNode
LOGICAL_AND = '&&'.freeze
SEMANTIC_AND = 'and'.freeze
LOGICAL_OR = '||'.freeze
SEMANTIC_OR = 'or'.freeze
LOGICAL_AND = '&&'
SEMANTIC_AND = 'and'
LOGICAL_OR = '||'
SEMANTIC_OR = 'or'

# Returns the operator as a string.
#
Expand Down
8 changes: 4 additions & 4 deletions lib/rubocop/ast/node/pair_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ module AST
class PairNode < Node
include HashElementNode

HASH_ROCKET = '=>'.freeze
SPACED_HASH_ROCKET = ' => '.freeze
COLON = ':'.freeze
SPACED_COLON = ': '.freeze
HASH_ROCKET = '=>'
SPACED_HASH_ROCKET = ' => '
COLON = ':'
SPACED_COLON = ': '

# Checks whether the `pair` uses a hash rocket delimiter.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/ast/node/until_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def inverse_keyword
#
# @return [Boolean] whether the `until` node has a `do` keyword
def do?
loc.begin && loc.begin.is?('do')
loc.begin&.is?('do')
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/ast/node/when_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def branch_index
#
# @return [Boolean] whether the `when` node has a `then` keyword
def then?
loc.begin && loc.begin.is?('then')
loc.begin&.is?('then')
end

# Returns the body of the `when` node.
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/ast/node/while_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def inverse_keyword
#
# @return [Boolean] whether the `until` node has a `do` keyword
def do?
loc.begin && loc.begin.is?('do')
loc.begin&.is?('do')
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/rubocop/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ module RuboCop
class CLI
include Formatter::TextUtil

PHASE_1 = 'Phase 1 of 2: run Metrics/LineLength cop'.freeze
PHASE_2 = 'Phase 2 of 2: run all cops'.freeze
PHASE_1 = 'Phase 1 of 2: run Metrics/LineLength cop'
PHASE_2 = 'Phase 2 of 2: run all cops'

PHASE_1_OVERRIDDEN = '(skipped because the default Metrics/LineLength:Max' \
' is overridden)'.freeze
' is overridden)'
PHASE_1_DISABLED = '(skipped because Metrics/LineLength is ' \
'disabled)'.freeze
'disabled)'

STATUS_SUCCESS = 0
STATUS_OFFENSES = 1
Expand Down
12 changes: 6 additions & 6 deletions lib/rubocop/comment_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ module RuboCop
# This class parses the special `rubocop:disable` comments in a source
# and provides a way to check if each cop is enabled at arbitrary line.
class CommentConfig
UNNEEDED_DISABLE = 'Lint/UnneededCopDisableDirective'.freeze
UNNEEDED_DISABLE = 'Lint/UnneededCopDisableDirective'

COP_NAME_PATTERN = '([A-Z]\w+/)?(?:[A-Z]\w+)'.freeze
COP_NAMES_PATTERN = "(?:#{COP_NAME_PATTERN} , )*#{COP_NAME_PATTERN}".freeze
COPS_PATTERN = "(all|#{COP_NAMES_PATTERN})".freeze
COP_NAME_PATTERN = '([A-Z]\w+/)?(?:[A-Z]\w+)'
COP_NAMES_PATTERN = "(?:#{COP_NAME_PATTERN} , )*#{COP_NAME_PATTERN}"
COPS_PATTERN = "(all|#{COP_NAMES_PATTERN})"

COMMENT_DIRECTIVE_REGEXP = Regexp.new(
('# rubocop : ((?:dis|en)able)\b ' + COPS_PATTERN).gsub(' ', '\s*')
Expand Down Expand Up @@ -175,7 +175,7 @@ def enable_all?(comment)
def handle_enable_all(names, extras, comment)
enabled_cops = 0
names.each do |name, counter|
next unless counter > 0
next unless counter.positive?

names[name] -= 1
enabled_cops += 1
Expand All @@ -189,7 +189,7 @@ def handle_switch(cop_names, names, disabled, extras, comment)
names[name] ||= 0
if disabled
names[name] += 1
elsif names[name] > 0
elsif (names[name]).positive?
names[name] -= 1
else
extras << [comment, name]
Expand Down
14 changes: 8 additions & 6 deletions lib/rubocop/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ class Config
INTERNAL_PARAMS = %w[Description StyleGuide VersionAdded
VersionChanged Reference Safe SafeAutoCorrect].freeze

# 2.2 is the oldest officially supported Ruby version.
DEFAULT_RUBY_VERSION = 2.2
KNOWN_RUBIES = [2.2, 2.3, 2.4, 2.5, 2.6].freeze
OBSOLETE_RUBIES = { 1.9 => '0.50', 2.0 => '0.50', 2.1 => '0.58' }.freeze
RUBY_VERSION_FILENAME = '.ruby-version'.freeze
# 2.3 is the oldest officially supported Ruby version.
DEFAULT_RUBY_VERSION = 2.3
KNOWN_RUBIES = [2.3, 2.4, 2.5, 2.6].freeze
OBSOLETE_RUBIES = {
1.9 => '0.50', 2.0 => '0.50', 2.1 => '0.58', 2.2 => '0.69'
}.freeze
RUBY_VERSION_FILENAME = '.ruby-version'
DEFAULT_RAILS_VERSION = 5.0
OBSOLETE_COPS = {
'Style/FlipFlop' =>
Expand Down Expand Up @@ -570,7 +572,7 @@ def obsolete_parameters
end

def obsolete_parameter_message(cop, parameter, alternative)
return unless self[cop] && self[cop].key?(parameter)
return unless self[cop]&.key?(parameter)

"obsolete parameter #{parameter} (for #{cop}) " \
"found in #{smart_loaded_path}" \
Expand Down
6 changes: 3 additions & 3 deletions lib/rubocop/config_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class ConfigNotFoundError < Error
# during a run of the rubocop program, if files in several
# directories are inspected.
class ConfigLoader
DOTFILE = '.rubocop.yml'.freeze
XDG_CONFIG = 'config.yml'.freeze
DOTFILE = '.rubocop.yml'
XDG_CONFIG = 'config.yml'
RUBOCOP_HOME = File.realpath(File.join(File.dirname(__FILE__), '..', '..'))
DEFAULT_FILE = File.join(RUBOCOP_HOME, 'config', 'default.yml')
AUTO_GENERATED_FILE = '.rubocop_todo.yml'.freeze
AUTO_GENERATED_FILE = '.rubocop_todo.yml'

class << self
include FileFinder
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 @@ -13,7 +13,7 @@ class Badge
# Error raised when a badge parse fails.
class InvalidBadge < Error
MSG = 'Invalid badge %<badge>p. ' \
'Expected `Department/CopName` or `CopName`.'.freeze
'Expected `Department/CopName` or `CopName`.'

def initialize(token)
super(format(MSG, badge: token))
Expand Down

0 comments on commit bcbcfb8

Please sign in to comment.