brew vendor-gems: commit updates.
This commit is contained in:
parent
ff1756e634
commit
0581d7b9ba
@ -87,7 +87,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-ast-1.12.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.1.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.22.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.11.5/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.12.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.12.4/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.5.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.2/lib"
|
||||
|
||||
@ -76,6 +76,12 @@ Performance/CompareWithBlock:
|
||||
Enabled: true
|
||||
VersionAdded: '0.46'
|
||||
|
||||
Performance/ConcurrentMonotonicTime:
|
||||
Description: 'Use `Process.clock_gettime(Process::CLOCK_MONOTONIC)` instead of `Concurrent.monotonic_time`.'
|
||||
Reference: 'https://github.com/rails/rails/pull/43502'
|
||||
Enabled: pending
|
||||
VersionAdded: '1.12'
|
||||
|
||||
Performance/ConstantRegexp:
|
||||
Description: 'Finds regular expressions with dynamic components that are all constants.'
|
||||
Enabled: pending
|
||||
@ -309,9 +315,9 @@ Performance/StartWith:
|
||||
Performance/StringInclude:
|
||||
Description: 'Use `String#include?` instead of a regex match with literal-only pattern.'
|
||||
Enabled: 'pending'
|
||||
AutoCorrect: false
|
||||
SafeAutoCorrect: false
|
||||
VersionAdded: '1.7'
|
||||
VersionChanged: '1.12'
|
||||
|
||||
Performance/StringReplacement:
|
||||
Description: >-
|
||||
@ -6,6 +6,10 @@ module RuboCop
|
||||
# This cop is used to identify usages of `ancestors.include?` and
|
||||
# change them to use `<=` instead.
|
||||
#
|
||||
# @safety
|
||||
# This cop is unsafe because it can't tell whether the receiver is a class or an object.
|
||||
# e.g. the false positive was for `Nokogiri::XML::Node#ancestors`.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
# A.ancestors.include?(B)
|
||||
@ -7,7 +7,9 @@ module RuboCop
|
||||
# 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.
|
||||
# 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.
|
||||
#
|
||||
# @safety
|
||||
# This cop is unsafe for string slices because strings do not have `#take` and `#drop` methods.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
@ -17,11 +17,13 @@ module RuboCop
|
||||
# this defining a higher level when condition to override a condition
|
||||
# that is inside of the splat expansion.
|
||||
#
|
||||
# This is not a guaranteed performance improvement. If the data being
|
||||
# processed by the `case` condition is normalized in a manner that favors
|
||||
# hitting a condition in the splat expansion, it is possible that
|
||||
# moving the splat condition to the end will use more memory,
|
||||
# and run slightly slower.
|
||||
# @safety
|
||||
# This cop is not unsafe auto-correction because it is not a guaranteed
|
||||
# performance improvement. If the data being processed by the `case` condition is
|
||||
# normalized in a manner that favors hitting a condition in the splat expansion,
|
||||
# it is possible that moving the splat condition to the end will use more memory,
|
||||
# and run slightly slower.
|
||||
# See for more details: https://github.com/rubocop/rubocop/pull/6163
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
@ -5,8 +5,10 @@ module RuboCop
|
||||
module Performance
|
||||
# This cop identifies places where a case-insensitive string comparison
|
||||
# can better be implemented using `casecmp`.
|
||||
# This cop is unsafe because `String#casecmp` and `String#casecmp?` behave
|
||||
# differently when using Non-ASCII characters.
|
||||
#
|
||||
# @safety
|
||||
# This cop is unsafe because `String#casecmp` and `String#casecmp?` behave
|
||||
# differently when using Non-ASCII characters.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
@ -0,0 +1,42 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module RuboCop
|
||||
module Cop
|
||||
module Performance
|
||||
# This cop identifies places where `Concurrent.monotonic_time`
|
||||
# can be replaced by `Process.clock_gettime(Process::CLOCK_MONOTONIC)`.
|
||||
#
|
||||
# @example
|
||||
#
|
||||
# # bad
|
||||
# Concurrent.monotonic_time
|
||||
#
|
||||
# # good
|
||||
# Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
||||
#
|
||||
class ConcurrentMonotonicTime < Base
|
||||
extend AutoCorrector
|
||||
|
||||
MSG = 'Use `%<prefer>s` instead of `%<current>s`.'
|
||||
RESTRICT_ON_SEND = %i[monotonic_time].freeze
|
||||
|
||||
def_node_matcher :concurrent_monotonic_time?, <<~PATTERN
|
||||
(send
|
||||
(const {nil? cbase} :Concurrent) :monotonic_time ...)
|
||||
PATTERN
|
||||
|
||||
def on_send(node)
|
||||
return unless concurrent_monotonic_time?(node)
|
||||
|
||||
optional_unit_parameter = ", #{node.first_argument.source}" if node.first_argument
|
||||
prefer = "Process.clock_gettime(Process::CLOCK_MONOTONIC#{optional_unit_parameter})"
|
||||
message = format(MSG, prefer: prefer, current: node.source)
|
||||
|
||||
add_offense(node, message: message) do |corrector|
|
||||
corrector.replace(node, prefer)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -7,6 +7,28 @@ module RuboCop
|
||||
# follow calls to `select`, `find_all`, `filter` or `reject`. Querying logic can instead be
|
||||
# passed to the `count` call.
|
||||
#
|
||||
# @safety
|
||||
# This cop is unsafe because it has known compatibility issues with `ActiveRecord` and other
|
||||
# frameworks. ActiveRecord's `count` ignores the block that is passed to it.
|
||||
# `ActiveRecord` will ignore the block that is passed to `count`.
|
||||
# Other methods, such as `select`, will convert the association to an
|
||||
# array and then run the block on the array. A simple work around to
|
||||
# make `count` work with a block is to call `to_a.count {...}`.
|
||||
#
|
||||
# For example:
|
||||
#
|
||||
# [source,ruby]
|
||||
# ----
|
||||
# `Model.where(id: [1, 2, 3]).select { |m| m.method == true }.size`
|
||||
# ----
|
||||
#
|
||||
# becomes:
|
||||
#
|
||||
# [source,ruby]
|
||||
# ----
|
||||
# `Model.where(id: [1, 2, 3]).to_a.count { |m| m.method == true }`
|
||||
# ----
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
# [1, 2, 3].select { |e| e > 2 }.size
|
||||
@ -24,19 +46,6 @@ module RuboCop
|
||||
# [1, 2, 3].count { |e| e < 2 && e.even? }
|
||||
# Model.select('field AS field_one').count
|
||||
# Model.select(:value).count
|
||||
#
|
||||
# `ActiveRecord` compatibility:
|
||||
# `ActiveRecord` will ignore the block that is passed to `count`.
|
||||
# Other methods, such as `select`, will convert the association to an
|
||||
# array and then run the block on the array. A simple work around to
|
||||
# make `count` work with a block is to call `to_a.count {...}`.
|
||||
#
|
||||
# Example:
|
||||
# `Model.where(id: [1, 2, 3]).select { |m| m.method == true }.size`
|
||||
#
|
||||
# becomes:
|
||||
#
|
||||
# `Model.where(id: [1, 2, 3]).to_a.count { |m| m.method == true }`
|
||||
class Count < Base
|
||||
include RangeHelp
|
||||
extend AutoCorrector
|
||||
@ -7,7 +7,6 @@ module RuboCop
|
||||
#
|
||||
# This cop identifies places where `gsub(/\Aprefix/, '')` and `sub(/\Aprefix/, '')`
|
||||
# can be replaced by `delete_prefix('prefix')`.
|
||||
# It is marked as unsafe by default because `Pathname` has `sub` but not `delete_prefix`.
|
||||
#
|
||||
# This cop has `SafeMultiline` configuration option that `true` by default because
|
||||
# `^prefix` is unsafe as it will behave incompatible with `delete_prefix`
|
||||
@ -15,6 +14,9 @@ module RuboCop
|
||||
#
|
||||
# The `delete_prefix('prefix')` method is faster than `gsub(/\Aprefix/, '')`.
|
||||
#
|
||||
# @safety
|
||||
# This cop is unsafe because `Pathname` has `sub` but not `delete_prefix`.
|
||||
#
|
||||
# @example
|
||||
#
|
||||
# # bad
|
||||
@ -47,9 +49,6 @@ module RuboCop
|
||||
class DeletePrefix < Base
|
||||
include RegexpMetacharacter
|
||||
extend AutoCorrector
|
||||
extend TargetRubyVersion
|
||||
|
||||
minimum_target_ruby_version 2.5
|
||||
|
||||
MSG = 'Use `%<prefer>s` instead of `%<current>s`.'
|
||||
RESTRICT_ON_SEND = %i[gsub gsub! sub sub!].freeze
|
||||
@ -7,7 +7,6 @@ module RuboCop
|
||||
#
|
||||
# This cop identifies places where `gsub(/suffix\z/, '')` and `sub(/suffix\z/, '')`
|
||||
# can be replaced by `delete_suffix('suffix')`.
|
||||
# It is marked as unsafe by default because `Pathname` has `sub` but not `delete_suffix`.
|
||||
#
|
||||
# This cop has `SafeMultiline` configuration option that `true` by default because
|
||||
# `suffix$` is unsafe as it will behave incompatible with `delete_suffix?`
|
||||
@ -15,6 +14,9 @@ module RuboCop
|
||||
#
|
||||
# The `delete_suffix('suffix')` method is faster than `gsub(/suffix\z/, '')`.
|
||||
#
|
||||
# @safety
|
||||
# This cop is unsafe because `Pathname` has `sub` but not `delete_suffix`.
|
||||
#
|
||||
# @example
|
||||
#
|
||||
# # bad
|
||||
@ -47,9 +49,6 @@ module RuboCop
|
||||
class DeleteSuffix < Base
|
||||
include RegexpMetacharacter
|
||||
extend AutoCorrector
|
||||
extend TargetRubyVersion
|
||||
|
||||
minimum_target_ruby_version 2.5
|
||||
|
||||
MSG = 'Use `%<prefer>s` instead of `%<current>s`.'
|
||||
RESTRICT_ON_SEND = %i[gsub gsub! sub sub!].freeze
|
||||
@ -7,6 +7,11 @@ module RuboCop
|
||||
# chained to `select`, `find_all` or `filter` and change them to use
|
||||
# `detect` instead.
|
||||
#
|
||||
# @safety
|
||||
# This cop is unsafe because is has known compatibility issues with `ActiveRecord` and other
|
||||
# frameworks. `ActiveRecord` does not implement a `detect` method and `find` has its own
|
||||
# meaning. Correcting `ActiveRecord` methods with this cop should be considered unsafe.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
# [].select { |item| true }.first
|
||||
@ -90,7 +95,7 @@ module RuboCop
|
||||
end
|
||||
|
||||
def replacement(method, index)
|
||||
if method == :last || method == :[] && index == -1
|
||||
if method == :last || (method == :[] && index == -1)
|
||||
"reverse.#{preferred_method}"
|
||||
else
|
||||
preferred_method
|
||||
@ -9,6 +9,11 @@ module RuboCop
|
||||
# `end$` is unsafe as it will behave incompatible with `end_with?`
|
||||
# for receiver is multiline string.
|
||||
#
|
||||
# @safety
|
||||
# This will change to a new method call which isn't guaranteed to be on the
|
||||
# object. Switching these methods has to be done with knowledge of the types
|
||||
# of the variables which rubocop doesn't have.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
# 'abc'.match?(/bc\Z/)
|
||||
@ -15,6 +15,9 @@ module RuboCop
|
||||
# both perform an O(n) search through all of the values, calling `values`
|
||||
# allocates a new array while using `value?` does not.
|
||||
#
|
||||
# @safety
|
||||
# This cop is unsafe because it can't tell whether the receiver is a hash object.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
# { a: 1, b: 2 }.keys.include?(:a)
|
||||
@ -6,8 +6,10 @@ module RuboCop
|
||||
# In Ruby 2.7, `Enumerable#filter_map` has been added.
|
||||
#
|
||||
# This cop identifies places where `map { ... }.compact` can be replaced by `filter_map`.
|
||||
# It is marked as unsafe auto-correction by default because `map { ... }.compact`
|
||||
# that is not compatible with `filter_map`.
|
||||
#
|
||||
# @safety
|
||||
# This cop's autocorrection is unsafe because `map { ... }.compact` that is not
|
||||
# compatible with `filter_map`.
|
||||
#
|
||||
# [source,ruby]
|
||||
# ----
|
||||
@ -11,6 +11,10 @@ module RuboCop
|
||||
# especially in case of single-threaded
|
||||
# applications with multiple `OpenStruct` instantiations.
|
||||
#
|
||||
# @safety
|
||||
# This cop is unsafe because `OpenStruct.new` and `Struct.new`
|
||||
# are not equivalent.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
# class MyClass
|
||||
@ -9,8 +9,9 @@ module RuboCop
|
||||
# end points of the `Range`. In a great majority of cases, this is what
|
||||
# is wanted.
|
||||
#
|
||||
# This cop is `Safe: false` by default because `Range#include?` (or `Range#member?`) and
|
||||
# `Range#cover?` are not equivalent behaviour.
|
||||
# @safety
|
||||
# This cop is unsafe because `Range#include?` (or `Range#member?`) and `Range#cover?`
|
||||
# are not equivalent behaviour.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
@ -55,6 +55,7 @@ module RuboCop
|
||||
end
|
||||
end
|
||||
end
|
||||
alias on_defs on_def
|
||||
|
||||
private
|
||||
|
||||
@ -9,8 +9,9 @@ module RuboCop
|
||||
# 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.
|
||||
#
|
||||
# @safety
|
||||
# This cop is unsafe because `===` and `==` do not always behave the same.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
@ -24,9 +25,6 @@ module RuboCop
|
||||
#
|
||||
class RedundantEqualityComparisonBlock < Base
|
||||
extend AutoCorrector
|
||||
extend TargetRubyVersion
|
||||
|
||||
minimum_target_ruby_version 2.5
|
||||
|
||||
MSG = 'Use `%<prefer>s` instead of block.'
|
||||
|
||||
@ -8,8 +8,9 @@ module RuboCop
|
||||
# You can set the maximum number of key-value pairs to consider
|
||||
# an offense with `MaxKeyValuePairs`.
|
||||
#
|
||||
# This cop is marked as unsafe because RuboCop cannot determine if the
|
||||
# receiver of `merge!` is actually a hash or not.
|
||||
# @safety
|
||||
# This cop is unsafe because RuboCop cannot determine if the
|
||||
# receiver of `merge!` is actually a hash or not.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
@ -91,7 +92,7 @@ module RuboCop
|
||||
end
|
||||
|
||||
def non_redundant_pairs?(receiver, pairs)
|
||||
pairs.size > 1 && !receiver.pure? || pairs.size > max_key_value_pairs
|
||||
(pairs.size > 1 && !receiver.pure?) || pairs.size > max_key_value_pairs
|
||||
end
|
||||
|
||||
def kwsplat_used?(pairs)
|
||||
@ -9,6 +9,11 @@ module RuboCop
|
||||
# `^start` is unsafe as it will behave incompatible with `start_with?`
|
||||
# for receiver is multiline string.
|
||||
#
|
||||
# @safety
|
||||
# This will change to a new method call which isn't guaranteed to be on the
|
||||
# object. Switching these methods has to be done with knowledge of the types
|
||||
# of the variables which rubocop doesn't have.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
# 'abc'.match?(/\Aab/)
|
||||
@ -6,7 +6,8 @@ module RuboCop
|
||||
# This cop identifies unnecessary use of a regex where
|
||||
# `String#include?` would suffice.
|
||||
#
|
||||
# This cop's offenses are not safe to auto-correct if a receiver is nil.
|
||||
# @safety
|
||||
# This cop's offenses are not safe to auto-correct if a receiver is nil.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
@ -156,7 +156,7 @@ module RuboCop
|
||||
end
|
||||
|
||||
def sum_method_range(node)
|
||||
range_between(node.loc.selector.begin_pos, node.loc.end.end_pos)
|
||||
range_between(node.loc.selector.begin_pos, node.loc.expression.end_pos)
|
||||
end
|
||||
|
||||
def sum_map_range(map, sum)
|
||||
@ -7,6 +7,18 @@ module RuboCop
|
||||
# In most cases such calls can be replaced
|
||||
# with an explicit array creation.
|
||||
#
|
||||
# @safety
|
||||
# This cop's autocorrection is unsafe because `Integer#times` does nothing if receiver is 0
|
||||
# or less. However, `Array.new` raises an error if argument is less than 0.
|
||||
#
|
||||
# For example:
|
||||
#
|
||||
# [source,ruby]
|
||||
# ----
|
||||
# -1.times{} # does nothing
|
||||
# Array.new(-1) # ArgumentError: negative array size
|
||||
# ----
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
# 9.times.map do |i|
|
||||
@ -7,11 +7,11 @@ module RuboCop
|
||||
# literal instead of `String#dup` and `String.new`.
|
||||
# Unary plus operator is faster than `String#dup`.
|
||||
#
|
||||
# NOTE: `String.new` (without operator) is not exactly the same as `+''`.
|
||||
# These differ in encoding. `String.new.encoding` is always `ASCII-8BIT`.
|
||||
# However, `(+'').encoding` is the same as script encoding(e.g. `UTF-8`).
|
||||
# Therefore, auto-correction is unsafe.
|
||||
# So, if you expect `ASCII-8BIT` encoding, disable this cop.
|
||||
# @safety
|
||||
# This cop's autocorrection is unsafe because `String.new` (without operator) is not
|
||||
# exactly the same as `+''`. These differ in encoding. `String.new.encoding` is always
|
||||
# `ASCII-8BIT`. However, `(+'').encoding` is the same as script encoding(e.g. `UTF-8`).
|
||||
# if you expect `ASCII-8BIT` encoding, disable this cop.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
@ -13,6 +13,7 @@ require_relative 'performance/case_when_splat'
|
||||
require_relative 'performance/casecmp'
|
||||
require_relative 'performance/collection_literal_in_loop'
|
||||
require_relative 'performance/compare_with_block'
|
||||
require_relative 'performance/concurrent_monotonic_time'
|
||||
require_relative 'performance/constant_regexp'
|
||||
require_relative 'performance/count'
|
||||
require_relative 'performance/delete_prefix'
|
||||
@ -4,7 +4,7 @@ module RuboCop
|
||||
module Performance
|
||||
# This module holds the RuboCop Performance version information.
|
||||
module Version
|
||||
STRING = '1.11.5'
|
||||
STRING = '1.12.0'
|
||||
|
||||
def self.document_version
|
||||
STRING.match('\d+\.\d+').to_s
|
||||
Loading…
x
Reference in New Issue
Block a user