brew vendor-gems: commit updates.
This commit is contained in:
parent
01a0df0aca
commit
a3f251965e
@ -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.11.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.10.1/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.10.2/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.6.1/lib"
|
||||
|
||||
@ -78,7 +78,7 @@ module RuboCop
|
||||
end
|
||||
|
||||
def calls_to_report(argname, body)
|
||||
return [] if blockarg_assigned?(body, argname)
|
||||
return [] if blockarg_assigned?(body, argname) || shadowed_block_argument?(body, argname)
|
||||
|
||||
blockarg_calls(body, argname).map do |call|
|
||||
return [] if args_include_block_pass?(call)
|
||||
@ -87,6 +87,12 @@ module RuboCop
|
||||
end
|
||||
end
|
||||
|
||||
def shadowed_block_argument?(body, block_argument_of_method_signature)
|
||||
return false unless body.block_type?
|
||||
|
||||
body.arguments.map(&:source).include?(block_argument_of_method_signature.to_s)
|
||||
end
|
||||
|
||||
def args_include_block_pass?(blockcall)
|
||||
_receiver, _call, *args = *blockcall
|
||||
|
||||
@ -35,7 +35,8 @@ module RuboCop
|
||||
IS_A_METHODS = %i[is_a? kind_of?].freeze
|
||||
|
||||
def on_block(node)
|
||||
return unless TARGET_METHODS.include?(node.method_name) && node.arguments.one?
|
||||
return unless TARGET_METHODS.include?(node.method_name)
|
||||
return unless one_block_argument?(node.arguments)
|
||||
|
||||
block_argument = node.arguments.first
|
||||
block_body = node.body
|
||||
@ -53,14 +54,22 @@ module RuboCop
|
||||
|
||||
private
|
||||
|
||||
def one_block_argument?(block_arguments)
|
||||
block_arguments.one? && !block_arguments.source.include?(',')
|
||||
end
|
||||
|
||||
def use_equality_comparison_block?(block_body)
|
||||
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
|
||||
if block_body.method?(:===)
|
||||
block_argument.source != block_body.children[2].source
|
||||
elsif IS_A_METHODS.include?(block_body.method_name)
|
||||
block_argument.source == block_body.first_argument.source
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def new_argument(block_argument, block_body)
|
||||
@ -26,7 +26,7 @@ module RuboCop
|
||||
|
||||
def on_send(node)
|
||||
return unless (regexp_node = split_call_with_regexp?(node))
|
||||
return if regexp_node.ignore_case?
|
||||
return if regexp_node.ignore_case? || regexp_node.content == ' '
|
||||
return unless determinist_regexp?(regexp_node)
|
||||
|
||||
add_offense(regexp_node) do |corrector|
|
||||
@ -6,12 +6,20 @@ module RuboCop
|
||||
# This cop is used to identify usages of `reverse.each` and
|
||||
# change them to use `reverse_each` instead.
|
||||
#
|
||||
# If the return value is used, it will not be detected because the result will be different.
|
||||
#
|
||||
# [source,ruby]
|
||||
# ----
|
||||
# [1, 2, 3].reverse.each {} #=> [3, 2, 1]
|
||||
# [1, 2, 3].reverse_each {} #=> [1, 2, 3]
|
||||
# ----
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
# [].reverse.each
|
||||
# items.reverse.each
|
||||
#
|
||||
# # good
|
||||
# [].reverse_each
|
||||
# items.reverse_each
|
||||
class ReverseEach < Base
|
||||
include RangeHelp
|
||||
extend AutoCorrector
|
||||
@ -24,6 +32,8 @@ module RuboCop
|
||||
MATCHER
|
||||
|
||||
def on_send(node)
|
||||
return if use_return_value?(node)
|
||||
|
||||
reverse_each?(node) do
|
||||
range = offense_range(node)
|
||||
|
||||
@ -35,6 +45,12 @@ module RuboCop
|
||||
|
||||
private
|
||||
|
||||
def use_return_value?(node)
|
||||
!!node.ancestors.detect do |ancestor|
|
||||
ancestor.assignment? || ancestor.send_type? || ancestor.return_type?
|
||||
end
|
||||
end
|
||||
|
||||
def offense_range(node)
|
||||
range_between(node.children.first.loc.selector.begin_pos, node.loc.selector.end_pos)
|
||||
end
|
||||
@ -4,7 +4,7 @@ module RuboCop
|
||||
module Performance
|
||||
# This module holds the RuboCop Performance version information.
|
||||
module Version
|
||||
STRING = '1.10.1'
|
||||
STRING = '1.10.2'
|
||||
|
||||
def self.document_version
|
||||
STRING.match('\d+\.\d+').to_s
|
||||
Loading…
x
Reference in New Issue
Block a user