Merge pull request #10758 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-performance-1.10.1
build(deps): bump rubocop-performance from 1.10.0 to 1.10.1 in /Library/Homebrew
This commit is contained in:
commit
b024954a0f
@ -119,7 +119,7 @@ GEM
|
||||
unicode-display_width (>= 1.4.0, < 3.0)
|
||||
rubocop-ast (1.4.1)
|
||||
parser (>= 2.7.1.5)
|
||||
rubocop-performance (1.10.0)
|
||||
rubocop-performance (1.10.1)
|
||||
rubocop (>= 0.90.0, < 2.0)
|
||||
rubocop-ast (>= 0.4.0)
|
||||
rubocop-rails (2.9.1)
|
||||
|
@ -492,11 +492,14 @@ class RuboCop::Cop::Performance::RedundantEqualityComparisonBlock < ::RuboCop::C
|
||||
|
||||
def new_argument(block_argument, block_body); end
|
||||
def offense_range(node); end
|
||||
def same_block_argument_and_is_a_argument?(block_body, block_argument); end
|
||||
def use_equality_comparison_block?(block_body); end
|
||||
end
|
||||
|
||||
RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::COMPARISON_METHODS = T.let(T.unsafe(nil), Array)
|
||||
|
||||
RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::IS_A_METHODS = T.let(T.unsafe(nil), Array)
|
||||
|
||||
RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::TARGET_METHODS = T.let(T.unsafe(nil), Array)
|
||||
@ -588,9 +591,8 @@ class RuboCop::Cop::Performance::RedundantSplitRegexpArgument < ::RuboCop::Cop::
|
||||
|
||||
private
|
||||
|
||||
def autocorrect(corrector, node); end
|
||||
def determinist_regexp?(first_argument); end
|
||||
def replacement(node); end
|
||||
def determinist_regexp?(regexp_node); end
|
||||
def replacement(regexp_node); end
|
||||
end
|
||||
|
||||
RuboCop::Cop::Performance::RedundantSplitRegexpArgument::DETERMINISTIC_REGEX = T.let(T.unsafe(nil), Regexp)
|
@ -82,7 +82,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-ast-1.4.1/lib
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.11.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-2.0.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.10.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.10.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.10.1/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.9.1/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.2.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.5.1/lib"
|
||||
|
@ -32,13 +32,15 @@ module RuboCop
|
||||
|
||||
TARGET_METHODS = %i[all? any? one? none?].freeze
|
||||
COMPARISON_METHODS = %i[== === is_a? kind_of?].freeze
|
||||
IS_A_METHODS = %i[is_a? kind_of?].freeze
|
||||
|
||||
def on_block(node)
|
||||
return unless TARGET_METHODS.include?(node.method_name)
|
||||
return unless TARGET_METHODS.include?(node.method_name) && node.arguments.one?
|
||||
|
||||
block_argument = node.arguments.first
|
||||
block_body = node.body
|
||||
return unless use_equality_comparison_block?(block_body)
|
||||
return if same_block_argument_and_is_a_argument?(block_body, block_argument)
|
||||
return unless (new_argument = new_argument(block_argument, block_body))
|
||||
|
||||
range = offense_range(node)
|
||||
@ -55,6 +57,12 @@ module RuboCop
|
||||
block_body.send_type? && COMPARISON_METHODS.include?(block_body.method_name)
|
||||
end
|
||||
|
||||
def same_block_argument_and_is_a_argument?(block_body, block_argument)
|
||||
return false unless IS_A_METHODS.include?(block_body.method_name)
|
||||
|
||||
block_argument.source == block_body.first_argument.source
|
||||
end
|
||||
|
||||
def new_argument(block_argument, block_body)
|
||||
if block_argument.source == block_body.receiver.source
|
||||
block_body.first_argument.source
|
@ -21,32 +21,29 @@ module RuboCop
|
||||
STR_SPECIAL_CHARS = %w[\n \" \' \\\\ \t \b \f \r].freeze
|
||||
|
||||
def_node_matcher :split_call_with_regexp?, <<~PATTERN
|
||||
{(send !nil? :split {regexp})}
|
||||
{(send !nil? :split $regexp)}
|
||||
PATTERN
|
||||
|
||||
def on_send(node)
|
||||
return unless split_call_with_regexp?(node)
|
||||
return unless determinist_regexp?(node.first_argument)
|
||||
return unless (regexp_node = split_call_with_regexp?(node))
|
||||
return if regexp_node.ignore_case?
|
||||
return unless determinist_regexp?(regexp_node)
|
||||
|
||||
add_offense(node.first_argument) do |corrector|
|
||||
autocorrect(corrector, node)
|
||||
add_offense(regexp_node) do |corrector|
|
||||
new_argument = replacement(regexp_node)
|
||||
|
||||
corrector.replace(regexp_node, "\"#{new_argument}\"")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def determinist_regexp?(first_argument)
|
||||
DETERMINISTIC_REGEX.match?(first_argument.source)
|
||||
def determinist_regexp?(regexp_node)
|
||||
DETERMINISTIC_REGEX.match?(regexp_node.source)
|
||||
end
|
||||
|
||||
def autocorrect(corrector, node)
|
||||
new_argument = replacement(node)
|
||||
|
||||
corrector.replace(node.first_argument, "\"#{new_argument}\"")
|
||||
end
|
||||
|
||||
def replacement(node)
|
||||
regexp_content = node.first_argument.content
|
||||
def replacement(regexp_node)
|
||||
regexp_content = regexp_node.content
|
||||
stack = []
|
||||
chars = regexp_content.chars.each_with_object([]) do |char, strings|
|
||||
if stack.empty? && char == '\\'
|
@ -4,7 +4,7 @@ module RuboCop
|
||||
module Performance
|
||||
# This module holds the RuboCop Performance version information.
|
||||
module Version
|
||||
STRING = '1.10.0'
|
||||
STRING = '1.10.1'
|
||||
|
||||
def self.document_version
|
||||
STRING.match('\d+\.\d+').to_s
|
Loading…
x
Reference in New Issue
Block a user