brew vendor-gems: commit updates.

This commit is contained in:
BrewTestBot 2022-09-12 18:13:47 +00:00
parent 3a371a43d7
commit dd88369208
No known key found for this signature in database
GPG Key ID: 82D7D104050B0F0F
59 changed files with 83 additions and 94 deletions

View File

@ -87,7 +87,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-ast-1.21.0/li
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.11.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-2.2.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.35.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.14.3/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.15.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.16.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.12.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.11/lib"

View File

@ -1,5 +1,9 @@
# This is the default configuration file.
Performance:
Enabled: true
DocumentationBaseURL: https://docs.rubocop.org/rubocop-performance
Performance/AncestorsInclude:
Description: 'Use `A <= B` instead of `A.ancestors.include?(B)`.'
Reference: 'https://github.com/JuanitoFatas/fast-ruby#ancestorsinclude-vs--code'

View File

@ -14,6 +14,13 @@ module RuboCop
$send)
PATTERN
def_node_matcher :sort_with_numblock?, <<~PATTERN
(numblock
$(send _ :sort)
$_arg_count
$send)
PATTERN
def_node_matcher :replaceable_body?, <<~PATTERN
(send (lvar %1) :<=> (lvar %2))
PATTERN

View File

@ -41,11 +41,7 @@ module RuboCop
end
elsif (numeric_to_d = to_d?(node))
add_offense(numeric_to_d.source_range) do |corrector|
big_decimal_args = node
.arguments
.map(&:source)
.unshift("'#{numeric_to_d.source}'")
.join(', ')
big_decimal_args = node.arguments.map(&:source).unshift("'#{numeric_to_d.source}'").join(', ')
corrector.replace(node, "BigDecimal(#{big_decimal_args})")
end

View File

@ -26,8 +26,7 @@ module RuboCop
minimum_target_ruby_version 2.7
MSG = 'Use `bind_call(%<bind_arg>s%<comma>s%<call_args>s)` ' \
'instead of `bind(%<bind_arg>s).call(%<call_args>s)`.'
MSG = 'Use `bind_call(%<bind_arg>s%<comma>s%<call_args>s)` instead of `bind(%<bind_arg>s).call(%<call_args>s)`.'
RESTRICT_ON_SEND = %i[call].freeze
def_node_matcher :bind_with_call_method?, <<~PATTERN

View File

@ -99,8 +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].loc.expression.begin_pos, conditions[-1].loc.expression.end_pos)
corrector.replace(range, replacement(conditions))
end
@ -111,8 +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.source_range, reordering_correction(when_node))
end
def reordering_correction(when_node)
@ -126,11 +124,9 @@ module RuboCop
end
def when_branch_range(when_node)
next_branch =
when_node.parent.when_branches[when_node.branch_index + 1]
next_branch = when_node.parent.when_branches[when_node.branch_index + 1]
range_between(when_node.source_range.begin_pos,
next_branch.source_range.begin_pos)
range_between(when_node.source_range.begin_pos, next_branch.source_range.begin_pos)
end
def new_condition_with_then(node, new_condition)
@ -162,13 +158,11 @@ module RuboCop
def non_splat?(condition)
variable, = *condition
(condition.splat_type? && variable.array_type?) ||
!condition.splat_type?
(condition.splat_type? && variable.array_type?) || !condition.splat_type?
end
def needs_reorder?(when_node)
following_branches =
when_node.parent.when_branches[(when_node.branch_index + 1)..]
following_branches = when_node.parent.when_branches[(when_node.branch_index + 1)..]
following_branches.any? do |when_branch|
when_branch.conditions.any? do |condition|

View File

@ -104,9 +104,7 @@ module RuboCop
end
def loop?(ancestor, node)
keyword_loop?(ancestor.type) ||
kernel_loop?(ancestor) ||
node_within_enumerable_loop?(node, ancestor)
keyword_loop?(ancestor.type) || kernel_loop?(ancestor) || node_within_enumerable_loop?(node, ancestor)
end
def keyword_loop?(type)

View File

@ -39,9 +39,7 @@ module RuboCop
MSG = 'Extract this regexp into a constant, memoize it, or append an `/o` option to its options.'
def on_regexp(node)
return if within_allowed_assignment?(node) ||
!include_interpolated_const?(node) ||
node.single_interpolation?
return if within_allowed_assignment?(node) || !include_interpolated_const?(node) || node.single_interpolation?
add_offense(node) do |corrector|
corrector.insert_after(node, 'o')

View File

@ -41,8 +41,7 @@ module RuboCop
class DoubleStartEndWith < Base
extend AutoCorrector
MSG = 'Use `%<receiver>s.%<method>s(%<combined_args>s)` ' \
'instead of `%<original_code>s`.'
MSG = 'Use `%<receiver>s.%<method>s(%<combined_args>s)` instead of `%<original_code>s`.'
def on_or(node)
receiver, method, first_call_args, second_call_args = process_source(node)

View File

@ -50,8 +50,7 @@ module RuboCop
include RegexpMetacharacter
extend AutoCorrector
MSG = 'Use `String#end_with?` instead of a regex match anchored to ' \
'the end of the string.'
MSG = 'Use `String#end_with?` instead of a regex match anchored to the end of the string.'
RESTRICT_ON_SEND = %i[match =~ match?].freeze
def_node_matcher :redundant_regex?, <<~PATTERN

View File

@ -83,9 +83,7 @@ module RuboCop
def use_long_method
preferred_config = config.for_all_cops['Style/PreferredHashMethods']
preferred_config &&
preferred_config['EnforcedStyle'] == 'long' &&
preferred_config['Enabled']
preferred_config && preferred_config['EnforcedStyle'] == 'long' && preferred_config['Enabled']
end
def autocorrect_argument(node)

View File

@ -32,8 +32,7 @@ module RuboCop
# end
#
class OpenStruct < Base
MSG = 'Consider using `Struct` over `OpenStruct` ' \
'to optimize the performance.'
MSG = 'Consider using `Struct` over `OpenStruct` to optimize the performance.'
RESTRICT_ON_SEND = %i[new].freeze
def_node_matcher :open_struct, <<~PATTERN

View File

@ -20,8 +20,7 @@ module RuboCop
class RedundantMatch < Base
extend AutoCorrector
MSG = 'Use `=~` in places where the `MatchData` returned by ' \
'`#match` will not be used.'
MSG = 'Use `=~` in places where the `MatchData` returned by `#match` will not be used.'
RESTRICT_ON_SEND = %i[match].freeze
# 'match' is a fairly generic name, so we don't flag it unless we see
@ -41,21 +40,23 @@ module RuboCop
!(node.parent && node.parent.block_type?)
add_offense(node) do |corrector|
autocorrect(corrector, node)
autocorrect(corrector, node) if autocorrectable?(node)
end
end
private
def autocorrect(corrector, node)
# Regexp#match can take a second argument, but this cop doesn't
# register an offense in that case
return unless node.first_argument.regexp_type?
new_source = "#{node.receiver.source} =~ #{node.first_argument.source}"
corrector.replace(node.source_range, new_source)
end
def autocorrectable?(node)
# Regexp#match can take a second argument, but this cop doesn't
# register an offense in that case
node.receiver.regexp_type? || node.first_argument.regexp_type?
end
end
end
end

View File

@ -99,8 +99,7 @@ module RuboCop
end
def non_redundant_value_used?(receiver, node)
node.value_used? &&
!EachWithObjectInspector.new(node, receiver).value_used?
node.value_used? && !EachWithObjectInspector.new(node, receiver).value_used?
end
def correct_multiple_elements(corrector, node, parent, new_source)
@ -125,9 +124,7 @@ module RuboCop
key = key.sym_type? && pair.colon? ? ":#{key.source}" : key.source
format(AREF_ASGN, receiver: receiver.source,
key: key,
value: value.source)
format(AREF_ASGN, receiver: receiver.source, key: key, value: value.source)
end
end

View File

@ -16,25 +16,33 @@ module RuboCop
include SortBlock
extend AutoCorrector
MSG = 'Use `sort` instead of `%<bad_method>s`.'
MSG = 'Use `sort` without block.'
def on_block(node)
return unless (send, var_a, var_b, body = sort_with_block?(node))
replaceable_body?(body, var_a, var_b) do
range = sort_range(send, node)
add_offense(range, message: message(var_a, var_b)) do |corrector|
corrector.replace(range, 'sort')
register_offense(send, node)
end
end
def on_numblock(node)
return unless (send, arg_count, body = sort_with_numblock?(node))
return unless arg_count == 2
replaceable_body?(body, :_1, :_2) do
register_offense(send, node)
end
end
private
def message(var_a, var_b)
bad_method = "sort { |#{var_a}, #{var_b}| #{var_a} <=> #{var_b} }"
format(MSG, bad_method: bad_method)
def register_offense(send, node)
range = sort_range(send, node)
add_offense(range) do |corrector|
corrector.replace(range, 'sort')
end
end
end
end

View File

@ -217,8 +217,7 @@ module RuboCop
def find_last_match(body, range, scope_root)
last_matches(body).find do |ref|
ref_pos = ref.loc.expression.begin_pos
range.cover?(ref_pos) &&
scope_root(ref) == scope_root
range.cover?(ref_pos) && scope_root(ref) == scope_root
end
end
@ -241,14 +240,7 @@ module RuboCop
end
def match_gvar?(sym)
%i[
$~
$MATCH
$PREMATCH
$POSTMATCH
$LAST_PAREN_MATCH
$LAST_MATCH_INFO
].include?(sym)
%i[$~ $MATCH $PREMATCH $POSTMATCH $LAST_PAREN_MATCH $LAST_MATCH_INFO].include?(sym)
end
def correct_operator(corrector, recv, arg, oper = nil)

View File

@ -17,14 +17,32 @@ module RuboCop
include SortBlock
extend AutoCorrector
MSG = 'Use `sort.reverse` instead of `%<bad_method>s`.'
MSG = 'Use `sort.reverse` instead.'
def on_block(node)
sort_with_block?(node) do |send, var_a, var_b, body|
replaceable_body?(body, var_b, var_a) do
register_offense(send, node)
end
end
end
def on_numblock(node)
sort_with_numblock?(node) do |send, arg_count, body|
next unless arg_count == 2
replaceable_body?(body, :_2, :_1) do
register_offense(send, node)
end
end
end
private
def register_offense(send, node)
range = sort_range(send, node)
add_offense(range, message: message(var_a, var_b)) do |corrector|
add_offense(range) do |corrector|
replacement = 'sort.reverse'
corrector.replace(range, replacement)
@ -32,14 +50,5 @@ module RuboCop
end
end
end
private
def message(var_a, var_b)
bad_method = "sort { |#{var_a}, #{var_b}| #{var_b} <=> #{var_a} }"
format(MSG, bad_method: bad_method)
end
end
end
end
end

View File

@ -24,10 +24,7 @@ module RuboCop
MSG = 'Use `%<prefer>s` instead of `%<current>s`.'
RESTRICT_ON_SEND = %i[gsub gsub!].freeze
PREFERRED_METHODS = {
gsub: :squeeze,
gsub!: :squeeze!
}.freeze
PREFERRED_METHODS = { gsub: :squeeze, gsub!: :squeeze! }.freeze
def_node_matcher :squeeze_candidate?, <<~PATTERN
(send

View File

@ -50,8 +50,7 @@ module RuboCop
include RegexpMetacharacter
extend AutoCorrector
MSG = 'Use `String#start_with?` instead of a regex match anchored to ' \
'the beginning of the string.'
MSG = 'Use `String#start_with?` instead of a regex match anchored to the beginning of the string.'
RESTRICT_ON_SEND = %i[match =~ match?].freeze
def_node_matcher :redundant_regex?, <<~PATTERN

View File

@ -86,8 +86,7 @@ module RuboCop
unless first_param.str_type?
return true if options
return true unless first_source.is_a?(String) &&
first_source =~ DETERMINISTIC_REGEX
return true unless first_source.is_a?(String) && first_source =~ DETERMINISTIC_REGEX
# This must be done after checking DETERMINISTIC_REGEX
# Otherwise things like \s will trip us up
@ -141,8 +140,7 @@ module RuboCop
end
def message(node, first_source, second_source)
replacement_method =
replacement_method(node, first_source, second_source)
replacement_method = replacement_method(node, first_source, second_source)
format(MSG, prefer: replacement_method, current: node.method_name)
end
@ -152,8 +150,7 @@ module RuboCop
end
def remove_second_param(corrector, node, first_param)
end_range = range_between(first_param.source_range.end_pos,
node.source_range.end_pos)
end_range = range_between(first_param.source_range.end_pos, node.source_range.end_pos)
corrector.replace(end_range, method_suffix(node))
end

View File

@ -32,8 +32,7 @@ module RuboCop
class TimesMap < Base
extend AutoCorrector
MESSAGE = 'Use `Array.new(%<count>s)` with a block ' \
'instead of `.times.%<map_or_collect>s`'
MESSAGE = 'Use `Array.new(%<count>s)` with a block instead of `.times.%<map_or_collect>s`'
MESSAGE_ONLY_IF = 'only if `%<count>s` is always 0 or more'
RESTRICT_ON_SEND = %i[map collect].freeze
@ -44,14 +43,14 @@ module RuboCop
def on_block(node)
check(node)
end
alias on_numblock on_block
private
def check(node)
times_map_call(node) do |map_or_collect, count|
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})"
replacement = "Array.new(#{count.source}#{map_or_collect.arguments.map { |arg| ", #{arg.source}" }.join})"
corrector.replace(map_or_collect.loc.expression, replacement)
end
@ -68,7 +67,7 @@ module RuboCop
end
def_node_matcher :times_map_call, <<~PATTERN
{(block $(send (send $!nil? :times) {:map :collect}) ...)
{({block numblock} $(send (send $!nil? :times) {:map :collect}) ...)
$(send (send $!nil? :times) {:map :collect} (block_pass ...))}
PATTERN
end

View File

@ -15,8 +15,7 @@ module RuboCop
class UriDefaultParser < Base
extend AutoCorrector
MSG = 'Use `%<double_colon>sURI::DEFAULT_PARSER` instead of ' \
'`%<double_colon>sURI::Parser.new`.'
MSG = 'Use `%<double_colon>sURI::DEFAULT_PARSER` instead of `%<double_colon>sURI::Parser.new`.'
RESTRICT_ON_SEND = %i[new].freeze
def_node_matcher :uri_parser_new?, <<~PATTERN

View File

@ -4,7 +4,7 @@ module RuboCop
module Performance
# This module holds the RuboCop Performance version information.
module Version
STRING = '1.14.3'
STRING = '1.15.0'
def self.document_version
STRING.match('\d+\.\d+').to_s