brew vendor-gems: commit updates.
This commit is contained in:
parent
1b052fa167
commit
47ec180089
@ -105,7 +105,7 @@ $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/unicode-display_width-2.4.2/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-1.49.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-capybara-2.17.1/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-performance-1.16.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-performance-1.17.1/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rails-2.19.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rspec-2.19.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-sorbet-0.7.0/lib")
|
||||
|
@ -226,6 +226,7 @@ Performance/RedundantEqualityComparisonBlock:
|
||||
Reference: 'https://github.com/rails/rails/pull/41363'
|
||||
Enabled: pending
|
||||
Safe: false
|
||||
AllowRegexpMatch: true
|
||||
VersionAdded: '1.10'
|
||||
|
||||
Performance/RedundantMatch:
|
@ -99,7 +99,7 @@ module RuboCop
|
||||
|
||||
def inline_fix_branch(corrector, when_node)
|
||||
conditions = when_node.conditions
|
||||
range = range_between(conditions[0].loc.expression.begin_pos, conditions[-1].loc.expression.end_pos)
|
||||
range = range_between(conditions[0].source_range.begin_pos, conditions[-1].source_range.end_pos)
|
||||
|
||||
corrector.replace(range, replacement(conditions))
|
||||
end
|
||||
@ -110,7 +110,7 @@ module RuboCop
|
||||
return if when_branches.one?
|
||||
|
||||
corrector.remove(when_branch_range(when_node))
|
||||
corrector.insert_after(when_branches.last.source_range, reordering_correction(when_node))
|
||||
corrector.insert_after(when_branches.last, reordering_correction(when_node))
|
||||
end
|
||||
|
||||
def reordering_correction(when_node)
|
@ -110,7 +110,7 @@ module RuboCop
|
||||
|
||||
def negate_block_pass_reject(corrector, node)
|
||||
corrector.replace(
|
||||
node.receiver.loc.expression.with(begin_pos: node.receiver.loc.begin.begin_pos),
|
||||
node.receiver.source_range.with(begin_pos: node.receiver.loc.begin.begin_pos),
|
||||
negate_block_pass_as_inline_block(node.receiver)
|
||||
)
|
||||
end
|
@ -8,12 +8,9 @@ module RuboCop
|
||||
# `detect` instead.
|
||||
#
|
||||
# @safety
|
||||
# This cop is unsafe because is assumes the class implements the
|
||||
# `Enumerable` interface, but can't reliably detect this. This creates
|
||||
# known compatibility issues with `Hash`, `ActiveRecord` and other
|
||||
# frameworks. `Hash` and `ActiveRecord` do not implement a `detect`
|
||||
# method and `find` has its own meaning. Correcting `Hash` and
|
||||
# `ActiveRecord` methods with this cop should be considered unsafe.
|
||||
# This cop is unsafe because it assumes that the receiver is an
|
||||
# `Array` or equivalent, but can't reliably detect it. For example,
|
||||
# if the receiver is a `Hash`, it may report a false positive.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
@ -58,8 +58,8 @@ module RuboCop
|
||||
private
|
||||
|
||||
def autocorrect(corrector, first_call_args, second_call_args, combined_args)
|
||||
first_argument = first_call_args.first.loc.expression
|
||||
last_argument = second_call_args.last.loc.expression
|
||||
first_argument = first_call_args.first.source_range
|
||||
last_argument = second_call_args.last.source_range
|
||||
range = first_argument.join(last_argument)
|
||||
|
||||
corrector.replace(range, combined_args)
|
@ -69,7 +69,7 @@ module RuboCop
|
||||
|
||||
new_source = "#{receiver.source}.end_with?(#{to_string_literal(regex_str)})"
|
||||
|
||||
corrector.replace(node.source_range, new_source)
|
||||
corrector.replace(node, new_source)
|
||||
end
|
||||
end
|
||||
alias on_match_with_lvasgn on_send
|
@ -28,7 +28,7 @@ module RuboCop
|
||||
def_node_matcher :flat_map_candidate?, <<~PATTERN
|
||||
(send
|
||||
{
|
||||
(block $(send _ ${:collect :map}) ...)
|
||||
$(block (send _ ${:collect :map}) ...)
|
||||
$(send _ ${:collect :map} (block_pass _))
|
||||
}
|
||||
${:flatten :flatten!}
|
||||
@ -60,7 +60,8 @@ module RuboCop
|
||||
end
|
||||
|
||||
def register_offense(node, map_node, first_method, flatten, message)
|
||||
range = range_between(map_node.loc.selector.begin_pos, node.loc.expression.end_pos)
|
||||
map_send_node = map_node.block_type? ? map_node.send_node : map_node
|
||||
range = range_between(map_send_node.loc.selector.begin_pos, node.source_range.end_pos)
|
||||
message = format(message, method: first_method, flatten: flatten)
|
||||
|
||||
add_offense(range, message: message) do |corrector|
|
||||
@ -74,10 +75,11 @@ module RuboCop
|
||||
|
||||
return unless flatten_level
|
||||
|
||||
range = range_between(node.loc.dot.begin_pos, node.source_range.end_pos)
|
||||
map_send_node = map_node.block_type? ? map_node.send_node : map_node
|
||||
range = range_between(map_node.source_range.end_pos, node.source_range.end_pos)
|
||||
|
||||
corrector.remove(range)
|
||||
corrector.replace(map_node.loc.selector, 'flat_map')
|
||||
corrector.replace(map_send_node.loc.selector, 'flat_map')
|
||||
end
|
||||
end
|
||||
end
|
@ -57,7 +57,7 @@ module RuboCop
|
||||
# Replace `keys.include?` or `values.include?` with the appropriate
|
||||
# `key?`/`value?` method.
|
||||
corrector.replace(
|
||||
node.loc.expression,
|
||||
node,
|
||||
"#{autocorrect_hash_expression(node)}.#{autocorrect_method(node)}(#{autocorrect_argument(node)})"
|
||||
)
|
||||
end
|
@ -95,7 +95,7 @@ module RuboCop
|
||||
begin_pos = readlines_call.loc.selector.begin_pos
|
||||
|
||||
end_pos = if enumerable_call.method?(:each)
|
||||
enumerable_call.loc.expression.end_pos
|
||||
enumerable_call.source_range.end_pos
|
||||
else
|
||||
enumerable_call.loc.dot.begin_pos
|
||||
end
|
@ -75,7 +75,7 @@ module RuboCop
|
||||
|
||||
new_source << CLOSE_PAREN if parentheses?(node) && !args.empty?
|
||||
|
||||
corrector.replace(node.source_range, new_source)
|
||||
corrector.replace(node, new_source)
|
||||
end
|
||||
|
||||
def calls_to_report(argname, body)
|
@ -10,6 +10,16 @@ module RuboCop
|
||||
# behavior is appropriately overridden in subclass. For example,
|
||||
# `Range#===` returns `true` when argument is within the range.
|
||||
#
|
||||
# This cop has `AllowRegexpMatch` option and it is true by default because
|
||||
# `regexp.match?('string')` often used in block changes to the opposite result:
|
||||
#
|
||||
# [source,ruby]
|
||||
# ----
|
||||
# [/pattern/].all? { |regexp| regexp.match?('pattern') } # => true
|
||||
# [/pattern/].all? { |regexp| regexp =~ 'pattern' } # => true
|
||||
# [/pattern/].all?('pattern') # => false
|
||||
# ----
|
||||
#
|
||||
# @safety
|
||||
# This cop is unsafe because `===` and `==` do not always behave the same.
|
||||
#
|
||||
@ -22,6 +32,19 @@ module RuboCop
|
||||
#
|
||||
# # good
|
||||
# items.all?(pattern)
|
||||
# items.all?(Klass)
|
||||
#
|
||||
# @example AllowRegexpMatch: true (default)
|
||||
#
|
||||
# # good
|
||||
# items.all? { |item| item =~ pattern }
|
||||
# items.all? { |item| item.match?(pattern) }
|
||||
#
|
||||
# @example AllowRegexpMatch: false
|
||||
#
|
||||
# # bad
|
||||
# items.all? { |item| item =~ pattern }
|
||||
# items.all? { |item| item.match?(pattern) }
|
||||
#
|
||||
class RedundantEqualityComparisonBlock < Base
|
||||
extend AutoCorrector
|
||||
@ -33,6 +56,7 @@ module RuboCop
|
||||
|
||||
TARGET_METHODS = %i[all? any? one? none?].freeze
|
||||
COMPARISON_METHODS = %i[== === is_a? kind_of?].freeze
|
||||
REGEXP_METHODS = %i[=~ match?].freeze
|
||||
IS_A_METHODS = %i[is_a? kind_of?].freeze
|
||||
|
||||
def on_block(node)
|
||||
@ -60,7 +84,11 @@ module RuboCop
|
||||
end
|
||||
|
||||
def use_equality_comparison_block?(block_body)
|
||||
block_body.send_type? && COMPARISON_METHODS.include?(block_body.method_name)
|
||||
return false unless block_body.send_type?
|
||||
|
||||
method_name = block_body.method_name
|
||||
|
||||
COMPARISON_METHODS.include?(method_name) || (!allow_regexp_match? && REGEXP_METHODS.include?(method_name))
|
||||
end
|
||||
|
||||
def same_block_argument_and_is_a_argument?(block_body, block_argument)
|
||||
@ -99,6 +127,10 @@ module RuboCop
|
||||
def offense_range(node)
|
||||
node.send_node.loc.selector.join(node.source_range.end)
|
||||
end
|
||||
|
||||
def allow_regexp_match?
|
||||
cop_config.fetch('AllowRegexpMatch', true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -49,7 +49,7 @@ module RuboCop
|
||||
def autocorrect(corrector, node)
|
||||
new_source = "#{node.receiver.source} =~ #{node.first_argument.source}"
|
||||
|
||||
corrector.replace(node.source_range, new_source)
|
||||
corrector.replace(node, new_source)
|
||||
end
|
||||
|
||||
def autocorrectable?(node)
|
@ -112,11 +112,11 @@ module RuboCop
|
||||
new_source.gsub!(/\n/, padding)
|
||||
end
|
||||
|
||||
corrector.replace(node.source_range, new_source)
|
||||
corrector.replace(node, new_source)
|
||||
end
|
||||
|
||||
def correct_single_element(corrector, node, new_source)
|
||||
corrector.replace(node.source_range, new_source)
|
||||
corrector.replace(node, new_source)
|
||||
end
|
||||
|
||||
def to_assignments(receiver, pairs)
|
@ -69,11 +69,11 @@ module RuboCop
|
||||
private
|
||||
|
||||
def offense_range(receiver, node)
|
||||
range_between(receiver.loc.selector.begin_pos, node.loc.expression.end_pos)
|
||||
range_between(receiver.loc.selector.begin_pos, node.source_range.end_pos)
|
||||
end
|
||||
|
||||
def correction_range(receiver, node)
|
||||
range_between(receiver.loc.dot.begin_pos, node.loc.expression.end_pos)
|
||||
range_between(receiver.loc.dot.begin_pos, node.source_range.end_pos)
|
||||
end
|
||||
|
||||
def build_message(method, args)
|
@ -185,9 +185,9 @@ module RuboCop
|
||||
|
||||
def range_to_search_for_last_matches(match_node, body, scope_root)
|
||||
expression = if modifier_form?(match_node)
|
||||
match_node.parent.if_branch.loc.expression
|
||||
match_node.parent.if_branch.source_range
|
||||
else
|
||||
match_node.loc.expression
|
||||
match_node.source_range
|
||||
end
|
||||
|
||||
match_node_pos = expression.begin_pos
|
||||
@ -199,15 +199,15 @@ module RuboCop
|
||||
def next_match_pos(body, match_node_pos, scope_root)
|
||||
node = search_match_nodes(body).find do |match|
|
||||
begin_pos = if modifier_form?(match)
|
||||
match.parent.if_branch.loc.expression.begin_pos
|
||||
match.parent.if_branch.source_range.begin_pos
|
||||
else
|
||||
match.loc.expression.begin_pos
|
||||
match.source_range.begin_pos
|
||||
end
|
||||
|
||||
begin_pos > match_node_pos && scope_root(match) == scope_root
|
||||
end
|
||||
|
||||
node ? node.loc.expression.begin_pos : Float::INFINITY
|
||||
node ? node.source_range.begin_pos : Float::INFINITY
|
||||
end
|
||||
|
||||
def modifier_form?(match_node)
|
||||
@ -216,7 +216,7 @@ module RuboCop
|
||||
|
||||
def find_last_match(body, range, scope_root)
|
||||
last_matches(body).find do |ref|
|
||||
ref_pos = ref.loc.expression.begin_pos
|
||||
ref_pos = ref.source_range.begin_pos
|
||||
range.cover?(ref_pos) && scope_root(ref) == scope_root
|
||||
end
|
||||
end
|
||||
@ -248,8 +248,8 @@ module RuboCop
|
||||
|
||||
replace_with_match_predicate_method(corrector, recv, arg, op_range)
|
||||
|
||||
corrector.insert_after(arg.loc.expression, ')') unless op_range.source.end_with?('(')
|
||||
corrector.insert_before(recv.loc.expression, '!') if oper == :!~
|
||||
corrector.insert_after(arg, ')') unless op_range.source.end_with?('(')
|
||||
corrector.insert_before(recv, '!') if oper == :!~
|
||||
end
|
||||
|
||||
def replace_with_match_predicate_method(corrector, recv, arg, op_range)
|
||||
@ -264,14 +264,14 @@ module RuboCop
|
||||
end
|
||||
|
||||
def swap_receiver_and_arg(corrector, recv, arg)
|
||||
corrector.replace(recv.loc.expression, arg.source)
|
||||
corrector.replace(arg.loc.expression, recv.source)
|
||||
corrector.replace(recv, arg.source)
|
||||
corrector.replace(arg, recv.source)
|
||||
end
|
||||
|
||||
def correction_range(recv, arg)
|
||||
buffer = processed_source.buffer
|
||||
op_begin_pos = recv.loc.expression.end_pos
|
||||
op_end_pos = arg.loc.expression.begin_pos
|
||||
op_begin_pos = recv.source_range.end_pos
|
||||
op_end_pos = arg.source_range.begin_pos
|
||||
Parser::Source::Range.new(buffer, op_begin_pos, op_end_pos)
|
||||
end
|
||||
end
|
@ -43,7 +43,7 @@ module RuboCop
|
||||
private
|
||||
|
||||
def correction_range(receiver, node)
|
||||
range_between(receiver.loc.selector.begin_pos, node.loc.expression.end_pos)
|
||||
range_between(receiver.loc.selector.begin_pos, node.source_range.end_pos)
|
||||
end
|
||||
|
||||
def build_message(node)
|
@ -52,7 +52,7 @@ module RuboCop
|
||||
end
|
||||
|
||||
def offense_range(node, map_method)
|
||||
range_between(node.loc.selector.begin_pos, map_method.loc.expression.end_pos)
|
||||
range_between(node.loc.selector.begin_pos, map_method.source_range.end_pos)
|
||||
end
|
||||
end
|
||||
end
|
@ -48,7 +48,7 @@ module RuboCop
|
||||
string_literal = to_string_literal(replace_str)
|
||||
new_code = "#{receiver.source}.#{good_method}(#{string_literal})"
|
||||
|
||||
corrector.replace(node.source_range, new_code)
|
||||
corrector.replace(node, new_code)
|
||||
end
|
||||
end
|
||||
end
|
@ -69,7 +69,7 @@ module RuboCop
|
||||
|
||||
new_source = "#{receiver.source}.start_with?(#{to_string_literal(regex_str)})"
|
||||
|
||||
corrector.replace(node.source_range, new_source)
|
||||
corrector.replace(node, new_source)
|
||||
end
|
||||
end
|
||||
alias on_match_with_lvasgn on_send
|
@ -27,28 +27,33 @@ module RuboCop
|
||||
|
||||
MSG = 'Use `%<symbol_arg>s` instead of `%<string_arg>s`.'
|
||||
|
||||
COMMAND_METHODS = %i[
|
||||
alias_method attr_accessor attr_reader attr_writer autoload autoload? private private_constant
|
||||
protected public public_constant module_function
|
||||
].freeze
|
||||
|
||||
# NOTE: `attr` method is not included in this list as it can cause false positives in Nokogiri API.
|
||||
# And `attr` may not be used because `Style/Attr` registers an offense.
|
||||
# https://github.com/rubocop/rubocop-performance/issues/278
|
||||
RESTRICT_ON_SEND = %i[
|
||||
alias_method attr_accessor attr_reader attr_writer autoload autoload?
|
||||
RESTRICT_ON_SEND = (%i[
|
||||
class_variable_defined? const_defined? const_get const_set const_source_location
|
||||
define_method instance_method method_defined? private_class_method? private_method_defined?
|
||||
protected_method_defined? public_class_method public_instance_method public_method_defined?
|
||||
remove_class_variable remove_method undef_method class_variable_get class_variable_set
|
||||
deprecate_constant module_function private private_constant protected public public_constant
|
||||
remove_const ruby2_keywords
|
||||
define_singleton_method instance_variable_defined? instance_variable_get instance_variable_set
|
||||
method public_method public_send remove_instance_variable respond_to? send singleton_method
|
||||
__send__
|
||||
].freeze
|
||||
deprecate_constant remove_const ruby2_keywords define_singleton_method instance_variable_defined?
|
||||
instance_variable_get instance_variable_set method public_method public_send remove_instance_variable
|
||||
respond_to? send singleton_method __send__
|
||||
] + COMMAND_METHODS).freeze
|
||||
|
||||
def on_send(node)
|
||||
return if COMMAND_METHODS.include?(node.method_name) && node.receiver
|
||||
return unless (first_argument = node.first_argument)
|
||||
return unless first_argument.str_type?
|
||||
return if first_argument.value.include?(' ') || first_argument.value.include?('::')
|
||||
|
||||
replacement = first_argument.value.to_sym.inspect
|
||||
first_argument_value = first_argument.value
|
||||
return if first_argument_value.include?(' ') || first_argument_value.include?('::')
|
||||
|
||||
replacement = first_argument_value.to_sym.inspect
|
||||
|
||||
message = format(MSG, symbol_arg: replacement, string_arg: first_argument.source)
|
||||
|
@ -43,7 +43,7 @@ module RuboCop
|
||||
|
||||
new_source = "#{'!' if negation}#{receiver.source}.include?(#{to_string_literal(regex_str)})"
|
||||
|
||||
corrector.replace(node.source_range, new_source)
|
||||
corrector.replace(node, new_source)
|
||||
end
|
||||
end
|
||||
alias on_match_with_lvasgn on_send
|
@ -70,7 +70,7 @@ module RuboCop
|
||||
replacement_method = replacement_method(node, first_source, second_source)
|
||||
|
||||
corrector.replace(node.loc.selector, replacement_method)
|
||||
corrector.replace(first_param.source_range, to_string_literal(first_source)) unless first_param.str_type?
|
||||
corrector.replace(first_param, to_string_literal(first_source)) unless first_param.str_type?
|
||||
|
||||
remove_second_param(corrector, node, first_param) if second_source.empty? && first_source.length == 1
|
||||
end
|
@ -183,7 +183,7 @@ module RuboCop
|
||||
end
|
||||
|
||||
def sum_method_range(node)
|
||||
range_between(node.loc.selector.begin_pos, node.loc.expression.end_pos)
|
||||
range_between(node.loc.selector.begin_pos, node.source_range.end_pos)
|
||||
end
|
||||
|
||||
def sum_map_range(map, sum)
|
@ -52,7 +52,7 @@ module RuboCop
|
||||
add_offense(node, message: message(map_or_collect, count)) do |corrector|
|
||||
replacement = "Array.new(#{count.source}#{map_or_collect.arguments.map { |arg| ", #{arg.source}" }.join})"
|
||||
|
||||
corrector.replace(map_or_collect.loc.expression, replacement)
|
||||
corrector.replace(map_or_collect, replacement)
|
||||
end
|
||||
end
|
||||
end
|
@ -30,7 +30,7 @@ module RuboCop
|
||||
message = format(MSG, double_colon: double_colon)
|
||||
|
||||
add_offense(node, message: message) do |corrector|
|
||||
corrector.replace(node.loc.expression, "#{double_colon}URI::DEFAULT_PARSER")
|
||||
corrector.replace(node, "#{double_colon}URI::DEFAULT_PARSER")
|
||||
end
|
||||
end
|
||||
end
|
@ -4,7 +4,7 @@ module RuboCop
|
||||
module Performance
|
||||
# This module holds the RuboCop Performance version information.
|
||||
module Version
|
||||
STRING = '1.16.0'
|
||||
STRING = '1.17.1'
|
||||
|
||||
def self.document_version
|
||||
STRING.match('\d+\.\d+').to_s
|
Loading…
x
Reference in New Issue
Block a user