brew vendor-gems: commit updates.

This commit is contained in:
BrewTestBot 2021-03-01 07:39:38 +00:00
parent f1d439eaae
commit b39df83bf1
54 changed files with 186 additions and 21 deletions

View File

@ -63,7 +63,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/pry-0.14.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rack-2.2.3/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rack-2.2.3/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/x86_64-darwin-14/2.6.0-static/rdiscount-2.2.0.2" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/x86_64-darwin-14/2.6.0-static/rdiscount-2.2.0.2"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rdiscount-2.2.0.2/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rdiscount-2.2.0.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/regexp_parser-2.0.3/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/regexp_parser-2.1.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rexml-3.2.4/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rexml-3.2.4/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ronn-0.7.3/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ronn-0.7.3/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-support-3.10.2/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-support-3.10.2/lib"
@ -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/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/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-1.10.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.9.2/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.10.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.9.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-rspec-2.2.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.5.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.5.1/lib"

View File

@ -10,7 +10,7 @@ Performance/AncestorsInclude:
Performance/ArraySemiInfiniteRangeSlice: Performance/ArraySemiInfiniteRangeSlice:
Description: 'Identifies places where slicing arrays with semi-infinite ranges can be replaced by `Array#take` and `Array#drop`.' Description: 'Identifies places where slicing arrays with semi-infinite ranges can be replaced by `Array#take` and `Array#drop`.'
# This cop was created due to a mistake in microbenchmark. # This cop was created due to a mistake in microbenchmark.
# Refer https://github.com/rubocop-hq/rubocop-performance/pull/175#issuecomment-731892717 # Refer https://github.com/rubocop/rubocop-performance/pull/175#issuecomment-731892717
Enabled: false Enabled: false
# Unsafe for string slices because strings do not have `#take` and `#drop` methods. # Unsafe for string slices because strings do not have `#take` and `#drop` methods.
Safe: false Safe: false
@ -80,6 +80,7 @@ Performance/ConstantRegexp:
Description: 'Finds regular expressions with dynamic components that are all constants.' Description: 'Finds regular expressions with dynamic components that are all constants.'
Enabled: pending Enabled: pending
VersionAdded: '1.9' VersionAdded: '1.9'
VersionChanged: '1.10'
Performance/Count: Performance/Count:
Description: >- Description: >-
@ -136,11 +137,10 @@ Performance/EndWith:
# object. Switching these methods has to be done with knowledge of the types # object. Switching these methods has to be done with knowledge of the types
# of the variables which rubocop doesn't have. # of the variables which rubocop doesn't have.
SafeAutoCorrect: false SafeAutoCorrect: false
AutoCorrect: false
Enabled: true Enabled: true
SafeMultiline: true SafeMultiline: true
VersionAdded: '0.36' VersionAdded: '0.36'
VersionChanged: '1.6' VersionChanged: '1.10'
Performance/FixedSize: Performance/FixedSize:
Description: 'Do not compute the size of statically sized objects except in constants.' Description: 'Do not compute the size of statically sized objects except in constants.'
@ -200,6 +200,15 @@ Performance/RedundantBlockCall:
Enabled: true Enabled: true
VersionAdded: '0.36' VersionAdded: '0.36'
Performance/RedundantEqualityComparisonBlock:
Description: >-
Checks for uses `Enumerable#all?`, `Enumerable#any?`, `Enumerable#one?`,
or `Enumerable#none?` are compared with `===` or similar methods in block.
Reference: 'https://github.com/rails/rails/pull/41363'
Enabled: pending
Safe: false
VersionAdded: '1.10'
Performance/RedundantMatch: Performance/RedundantMatch:
Description: >- Description: >-
Use `=~` instead of `String#match` or `Regexp#match` in a context where the Use `=~` instead of `String#match` or `Regexp#match` in a context where the
@ -220,6 +229,11 @@ Performance/RedundantSortBlock:
Enabled: 'pending' Enabled: 'pending'
VersionAdded: '1.7' VersionAdded: '1.7'
Performance/RedundantSplitRegexpArgument:
Description: 'This cop identifies places where `split` argument can be replaced from a deterministic regexp to a string.'
Enabled: pending
VersionAdded: '1.10'
Performance/RedundantStringChars: Performance/RedundantStringChars:
Description: 'Checks for redundant `String#chars`.' Description: 'Checks for redundant `String#chars`.'
Enabled: 'pending' Enabled: 'pending'
@ -270,11 +284,10 @@ Performance/StartWith:
# object. Switching these methods has to be done with knowledge of the types # object. Switching these methods has to be done with knowledge of the types
# of the variables which rubocop doesn't have. # of the variables which rubocop doesn't have.
SafeAutoCorrect: false SafeAutoCorrect: false
AutoCorrect: false
Enabled: true Enabled: true
SafeMultiline: true SafeMultiline: true
VersionAdded: '0.36' VersionAdded: '0.36'
VersionChanged: '1.6' VersionChanged: '1.10'
Performance/StringInclude: Performance/StringInclude:
Description: 'Use `String#include?` instead of a regex match with literal-only pattern.' Description: 'Use `String#include?` instead of a regex match with literal-only pattern.'
@ -304,7 +317,7 @@ Performance/TimesMap:
Enabled: true Enabled: true
VersionAdded: '0.36' VersionAdded: '0.36'
VersionChanged: '0.50' VersionChanged: '0.50'
SafeAutoCorrect: false # see https://github.com/rubocop-hq/rubocop/issues/4658 SafeAutoCorrect: false # see https://github.com/rubocop/rubocop/issues/4658
Performance/UnfreezeString: Performance/UnfreezeString:
Description: 'Use unary plus to get an unfrozen string literal.' Description: 'Use unary plus to get an unfrozen string literal.'

View File

@ -6,7 +6,7 @@ module RuboCop
# This cop identifies places where slicing arrays with semi-infinite ranges # This cop identifies places where slicing arrays with semi-infinite ranges
# can be replaced by `Array#take` and `Array#drop`. # can be replaced by `Array#take` and `Array#drop`.
# This cop was created due to a mistake in microbenchmark and hence is disabled by default. # This cop was created due to a mistake in microbenchmark and hence is disabled by default.
# Refer https://github.com/rubocop-hq/rubocop-performance/pull/175#issuecomment-731892717 # Refer https://github.com/rubocop/rubocop-performance/pull/175#issuecomment-731892717
# This cop is also unsafe for string slices because strings do not have `#take` and `#drop` methods. # This cop is also unsafe for string slices because strings do not have `#take` and `#drop` methods.
# #
# @example # @example

View File

@ -33,7 +33,7 @@ module RuboCop
def_node_matcher :bind_with_call_method?, <<~PATTERN def_node_matcher :bind_with_call_method?, <<~PATTERN
(send (send
$(send $(send
(send nil? _) :bind _ :bind
$(...)) :call $(...)) :call
$...) $...)
PATTERN PATTERN
@ -64,7 +64,7 @@ module RuboCop
def correction_range(receiver, node) def correction_range(receiver, node)
location_of_bind = receiver.loc.selector.begin_pos location_of_bind = receiver.loc.selector.begin_pos
location_of_call = node.loc.end.end_pos location_of_call = node.source_range.end.end_pos
range_between(location_of_bind, location_of_call) range_between(location_of_bind, location_of_call)
end end

View File

@ -6,9 +6,9 @@ module RuboCop
# This cop finds regular expressions with dynamic components that are all constants. # This cop finds regular expressions with dynamic components that are all constants.
# #
# Ruby allocates a new Regexp object every time it executes a code containing such # Ruby allocates a new Regexp object every time it executes a code containing such
# a regular expression. It is more efficient to extract it into a constant # a regular expression. It is more efficient to extract it into a constant,
# or add an `/o` option to perform `#{}` interpolation only once and reuse that # memoize it, or add an `/o` option to perform `#{}` interpolation only once and
# Regexp object. # reuse that Regexp object.
# #
# @example # @example
# #
@ -28,13 +28,18 @@ module RuboCop
# pattern.scan(TOKEN).reject { |token| token.match?(/\A#{SEPARATORS}\Z/o) } # pattern.scan(TOKEN).reject { |token| token.match?(/\A#{SEPARATORS}\Z/o) }
# end # end
# #
# # good
# def separators
# @separators ||= /\A#{SEPARATORS}\Z/
# end
#
class ConstantRegexp < Base class ConstantRegexp < Base
extend AutoCorrector extend AutoCorrector
MSG = 'Extract this regexp into a constant or append an `/o` option to its options.' MSG = 'Extract this regexp into a constant, memoize it, or append an `/o` option to its options.'
def on_regexp(node) def on_regexp(node)
return if within_const_assignment?(node) || return if within_allowed_assignment?(node) ||
!include_interpolated_const?(node) || !include_interpolated_const?(node) ||
node.single_interpolation? node.single_interpolation?
@ -45,8 +50,8 @@ module RuboCop
private private
def within_const_assignment?(node) def within_allowed_assignment?(node)
node.each_ancestor(:casgn).any? node.each_ancestor(:casgn, :or_asgn).any?
end end
def_node_matcher :regexp_escape?, <<~PATTERN def_node_matcher :regexp_escape?, <<~PATTERN

View File

@ -0,0 +1,72 @@
# frozen_string_literal: true
module RuboCop
module Cop
module Performance
# This cop checks for uses `Enumerable#all?`, `Enumerable#any?`, `Enumerable#one?`,
# and `Enumerable#none?` are compared with `===` or similar methods in block.
#
# By default, `Object#===` behaves the same as `Object#==`, but this
# behavior is appropriately overridden in subclass. For example,
# `Range#===` returns `true` when argument is within the range.
# Therefore, It is marked as unsafe by default because `===` and `==`
# do not always behave the same.
#
# @example
# # bad
# items.all? { |item| pattern === item }
# items.all? { |item| item == other }
# items.all? { |item| item.is_a?(Klass) }
# items.all? { |item| item.kind_of?(Klass) }
#
# # good
# items.all?(pattern)
#
class RedundantEqualityComparisonBlock < Base
extend AutoCorrector
extend TargetRubyVersion
minimum_target_ruby_version 2.5
MSG = 'Use `%<prefer>s` instead of block.'
TARGET_METHODS = %i[all? any? one? none?].freeze
COMPARISON_METHODS = %i[== === is_a? kind_of?].freeze
def on_block(node)
return unless TARGET_METHODS.include?(node.method_name)
block_argument = node.arguments.first
block_body = node.body
return unless use_equality_comparison_block?(block_body)
return unless (new_argument = new_argument(block_argument, block_body))
range = offense_range(node)
prefer = "#{node.method_name}(#{new_argument})"
add_offense(range, message: format(MSG, prefer: prefer)) do |corrector|
corrector.replace(range, prefer)
end
end
private
def use_equality_comparison_block?(block_body)
block_body.send_type? && COMPARISON_METHODS.include?(block_body.method_name)
end
def new_argument(block_argument, block_body)
if block_argument.source == block_body.receiver.source
block_body.first_argument.source
elsif block_argument.source == block_body.first_argument.source
block_body.receiver.source
end
end
def offense_range(node)
node.send_node.loc.selector.join(node.source_range.end)
end
end
end
end
end

View File

@ -0,0 +1,67 @@
# frozen_string_literal: true
module RuboCop
module Cop
module Performance
# This cop identifies places where `split` argument can be replaced from
# a deterministic regexp to a string.
#
# @example
# # bad
# 'a,b,c'.split(/,/)
#
# # good
# 'a,b,c'.split(',')
class RedundantSplitRegexpArgument < Base
extend AutoCorrector
MSG = 'Use string as argument instead of regexp.'
RESTRICT_ON_SEND = %i[split].freeze
DETERMINISTIC_REGEX = /\A(?:#{LITERAL_REGEX})+\Z/.freeze
STR_SPECIAL_CHARS = %w[\n \" \' \\\\ \t \b \f \r].freeze
def_node_matcher :split_call_with_regexp?, <<~PATTERN
{(send !nil? :split {regexp})}
PATTERN
def on_send(node)
return unless split_call_with_regexp?(node)
return unless determinist_regexp?(node.first_argument)
add_offense(node.first_argument) do |corrector|
autocorrect(corrector, node)
end
end
private
def determinist_regexp?(first_argument)
DETERMINISTIC_REGEX.match?(first_argument.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
stack = []
chars = regexp_content.chars.each_with_object([]) do |char, strings|
if stack.empty? && char == '\\'
stack.push(char)
else
strings << "#{stack.pop}#{char}"
end
end
chars.map do |char|
char = char.dup
char.delete!('\\') unless STR_SPECIAL_CHARS.include?(char)
char
end.join
end
end
end
end
end

View File

@ -150,7 +150,9 @@ module RuboCop
replacement = build_good_method(init, block_pass) replacement = build_good_method(init, block_pass)
corrector.remove(sum_range) corrector.remove(sum_range)
corrector.replace(map_range, ".#{replacement}")
dot = '.' if map.receiver
corrector.replace(map_range, "#{dot}#{replacement}")
end end
def sum_method_range(node) def sum_method_range(node)
@ -228,7 +230,11 @@ module RuboCop
end end
def method_call_with_args_range(node) def method_call_with_args_range(node)
node.receiver.source_range.end.join(node.source_range.end) if (receiver = node.receiver)
receiver.source_range.end.join(node.source_range.end)
else
node.source_range
end
end end
end end
end end

View File

@ -28,9 +28,11 @@ require_relative 'performance/open_struct'
require_relative 'performance/range_include' require_relative 'performance/range_include'
require_relative 'performance/io_readlines' require_relative 'performance/io_readlines'
require_relative 'performance/redundant_block_call' require_relative 'performance/redundant_block_call'
require_relative 'performance/redundant_equality_comparison_block'
require_relative 'performance/redundant_match' require_relative 'performance/redundant_match'
require_relative 'performance/redundant_merge' require_relative 'performance/redundant_merge'
require_relative 'performance/redundant_sort_block' require_relative 'performance/redundant_sort_block'
require_relative 'performance/redundant_split_regexp_argument'
require_relative 'performance/redundant_string_chars' require_relative 'performance/redundant_string_chars'
require_relative 'performance/regexp_match' require_relative 'performance/regexp_match'
require_relative 'performance/reverse_each' require_relative 'performance/reverse_each'

View File

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