brew vendor-gems: commit updates.
This commit is contained in:
parent
9cb7975b18
commit
554eaa27da
@ -85,7 +85,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-ast-1.18.0/li
|
|||||||
$:.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.1.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.27.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.27.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.13.3/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.14.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.14.2/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.14.2/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.11.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.11.1/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.8/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.8/lib"
|
||||||
|
|||||||
@ -247,7 +247,7 @@ Performance/RedundantSortBlock:
|
|||||||
VersionAdded: '1.7'
|
VersionAdded: '1.7'
|
||||||
|
|
||||||
Performance/RedundantSplitRegexpArgument:
|
Performance/RedundantSplitRegexpArgument:
|
||||||
Description: 'This cop identifies places where `split` argument can be replaced from a deterministic regexp to a string.'
|
Description: 'Identifies places where `split` argument can be replaced from a deterministic regexp to a string.'
|
||||||
Enabled: pending
|
Enabled: pending
|
||||||
VersionAdded: '1.10'
|
VersionAdded: '1.10'
|
||||||
|
|
||||||
@ -54,9 +54,9 @@ module RuboCop
|
|||||||
|
|
||||||
def drop_start_metacharacter(regexp_string)
|
def drop_start_metacharacter(regexp_string)
|
||||||
if regexp_string.start_with?('\\A')
|
if regexp_string.start_with?('\\A')
|
||||||
regexp_string[2..-1] # drop `\A` anchor
|
regexp_string[2..] # drop `\A` anchor
|
||||||
else
|
else
|
||||||
regexp_string[1..-1] # drop `^` anchor
|
regexp_string[1..] # drop `^` anchor
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3,8 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop is used to identify usages of `ancestors.include?` and
|
# Identifies usages of `ancestors.include?` and change them to use `<=` instead.
|
||||||
# change them to use `<=` instead.
|
|
||||||
#
|
#
|
||||||
# @safety
|
# @safety
|
||||||
# This cop is unsafe because it can't tell whether the receiver is a class or an object.
|
# This cop is unsafe because it can't tell whether the receiver is a class or an object.
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where slicing arrays with semi-infinite ranges
|
# 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/rubocop-performance/pull/175#issuecomment-731892717
|
# Refer https://github.com/rubocop/rubocop-performance/pull/175#issuecomment-731892717
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where numeric argument to BigDecimal should be
|
# Identifies places where numeric argument to BigDecimal should be
|
||||||
# converted to string. Initializing from String is faster
|
# converted to string. Initializing from String is faster
|
||||||
# than from Numeric for BigDecimal.
|
# than from Numeric for BigDecimal.
|
||||||
#
|
#
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies unnecessary use of a `block_given?` where explicit check
|
# Identifies unnecessary use of a `block_given?` where explicit check
|
||||||
# of block argument would suffice.
|
# of block argument would suffice.
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
@ -3,8 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where `caller[n]`
|
# Identifies places where `caller[n]` can be replaced by `caller(n..n).first`.
|
||||||
# can be replaced by `caller(n..n).first`.
|
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
@ -18,7 +18,7 @@ module RuboCop
|
|||||||
# that is inside of the splat expansion.
|
# that is inside of the splat expansion.
|
||||||
#
|
#
|
||||||
# @safety
|
# @safety
|
||||||
# This cop is not unsafe auto-correction because it is not a guaranteed
|
# This cop is not unsafe autocorrection because it is not a guaranteed
|
||||||
# performance improvement. If the data being processed by the `case` condition is
|
# 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,
|
# 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,
|
# it is possible that moving the splat condition to the end will use more memory,
|
||||||
@ -168,7 +168,7 @@ module RuboCop
|
|||||||
|
|
||||||
def needs_reorder?(when_node)
|
def needs_reorder?(when_node)
|
||||||
following_branches =
|
following_branches =
|
||||||
when_node.parent.when_branches[(when_node.branch_index + 1)..-1]
|
when_node.parent.when_branches[(when_node.branch_index + 1)..]
|
||||||
|
|
||||||
following_branches.any? do |when_branch|
|
following_branches.any? do |when_branch|
|
||||||
when_branch.conditions.any? do |condition|
|
when_branch.conditions.any? do |condition|
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where a case-insensitive string comparison
|
# Identifies places where a case-insensitive string comparison
|
||||||
# can better be implemented using `casecmp`.
|
# can better be implemented using `casecmp`.
|
||||||
#
|
#
|
||||||
# @safety
|
# @safety
|
||||||
@ -54,11 +54,11 @@ module RuboCop
|
|||||||
return unless (parts = take_method_apart(node))
|
return unless (parts = take_method_apart(node))
|
||||||
|
|
||||||
_receiver, method, arg, variable = parts
|
_receiver, method, arg, variable = parts
|
||||||
good_method = build_good_method(arg, variable)
|
good_method = build_good_method(method, arg, variable)
|
||||||
|
|
||||||
message = format(MSG, good: good_method, bad: node.source)
|
message = format(MSG, good: good_method, bad: node.source)
|
||||||
add_offense(node, message: message) do |corrector|
|
add_offense(node, message: message) do |corrector|
|
||||||
correction(corrector, node, method, arg, variable)
|
autocorrect(corrector, node, good_method)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -81,22 +81,20 @@ module RuboCop
|
|||||||
[receiver, method, arg, variable]
|
[receiver, method, arg, variable]
|
||||||
end
|
end
|
||||||
|
|
||||||
def correction(corrector, node, method, arg, variable)
|
def autocorrect(corrector, node, replacement)
|
||||||
corrector.insert_before(node.loc.expression, '!') if method == :!=
|
corrector.replace(node, replacement)
|
||||||
|
|
||||||
replacement = build_good_method(arg, variable)
|
|
||||||
|
|
||||||
corrector.replace(node.loc.expression, replacement)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_good_method(arg, variable)
|
def build_good_method(method, arg, variable)
|
||||||
|
bang = method == :!= ? '!' : ''
|
||||||
|
|
||||||
# We want resulting call to be parenthesized
|
# We want resulting call to be parenthesized
|
||||||
# if arg already includes one or more sets of parens, don't add more
|
# if arg already includes one or more sets of parens, don't add more
|
||||||
# or if method call already used parens, again, don't add more
|
# or if method call already used parens, again, don't add more
|
||||||
if arg.send_type? || !parentheses?(arg)
|
if arg.send_type? || !parentheses?(arg)
|
||||||
"#{variable.source}.casecmp(#{arg.source}).zero?"
|
"#{bang}#{variable.source}.casecmp(#{arg.source}).zero?"
|
||||||
else
|
else
|
||||||
"#{variable.source}.casecmp#{arg.source}.zero?"
|
"#{bang}#{variable.source}.casecmp#{arg.source}.zero?"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop is used to identify usages of `array.compact.flatten.map { |x| x.downcase }`.
|
# Identifies usages of `array.compact.flatten.map { |x| x.downcase }`.
|
||||||
# Each of these methods (`compact`, `flatten`, `map`) will generate a new intermediate array
|
# Each of these methods (`compact`, `flatten`, `map`) will generate a new intermediate array
|
||||||
# that is promptly thrown away. Instead it is faster to mutate when we know it's safe.
|
# that is promptly thrown away. Instead it is faster to mutate when we know it's safe.
|
||||||
#
|
#
|
||||||
@ -5,8 +5,8 @@ require 'set'
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where Array and Hash literals are used
|
# Identifies places where Array and Hash literals are used within loops.
|
||||||
# within loops. It is better to extract them into a local variable or constant
|
# It is better to extract them into a local variable or constant
|
||||||
# to avoid unnecessary allocations on each iteration.
|
# to avoid unnecessary allocations on each iteration.
|
||||||
#
|
#
|
||||||
# You can set the minimum number of elements to consider
|
# You can set the minimum number of elements to consider
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where `sort { |a, b| a.foo <=> b.foo }`
|
# Identifies places where `sort { |a, b| a.foo <=> b.foo }`
|
||||||
# can be replaced by `sort_by(&:foo)`.
|
# can be replaced by `sort_by(&:foo)`.
|
||||||
# This cop also checks `max` and `min` methods.
|
# This cop also checks `max` and `min` methods.
|
||||||
#
|
#
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where `Concurrent.monotonic_time`
|
# Identifies places where `Concurrent.monotonic_time`
|
||||||
# can be replaced by `Process.clock_gettime(Process::CLOCK_MONOTONIC)`.
|
# can be replaced by `Process.clock_gettime(Process::CLOCK_MONOTONIC)`.
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop finds regular expressions with dynamic components that are all constants.
|
# 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,
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop is used to identify usages of `count` on an `Enumerable` that
|
# Identifies usages of `count` on an `Enumerable` that
|
||||||
# follow calls to `select`, `find_all`, `filter` or `reject`. Querying logic can instead be
|
# follow calls to `select`, `find_all`, `filter` or `reject`. Querying logic can instead be
|
||||||
# passed to the `count` call.
|
# passed to the `count` call.
|
||||||
#
|
#
|
||||||
@ -49,6 +49,9 @@ module RuboCop
|
|||||||
class DeletePrefix < Base
|
class DeletePrefix < Base
|
||||||
include RegexpMetacharacter
|
include RegexpMetacharacter
|
||||||
extend AutoCorrector
|
extend AutoCorrector
|
||||||
|
extend TargetRubyVersion
|
||||||
|
|
||||||
|
minimum_target_ruby_version 2.5
|
||||||
|
|
||||||
MSG = 'Use `%<prefer>s` instead of `%<current>s`.'
|
MSG = 'Use `%<prefer>s` instead of `%<current>s`.'
|
||||||
RESTRICT_ON_SEND = %i[gsub gsub! sub sub!].freeze
|
RESTRICT_ON_SEND = %i[gsub gsub! sub sub!].freeze
|
||||||
@ -49,6 +49,9 @@ module RuboCop
|
|||||||
class DeleteSuffix < Base
|
class DeleteSuffix < Base
|
||||||
include RegexpMetacharacter
|
include RegexpMetacharacter
|
||||||
extend AutoCorrector
|
extend AutoCorrector
|
||||||
|
extend TargetRubyVersion
|
||||||
|
|
||||||
|
minimum_target_ruby_version 2.5
|
||||||
|
|
||||||
MSG = 'Use `%<prefer>s` instead of `%<current>s`.'
|
MSG = 'Use `%<prefer>s` instead of `%<current>s`.'
|
||||||
RESTRICT_ON_SEND = %i[gsub gsub! sub sub!].freeze
|
RESTRICT_ON_SEND = %i[gsub gsub! sub sub!].freeze
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop is used to identify usages of `first`, `last`, `[0]` or `[-1]`
|
# Identifies usages of `first`, `last`, `[0]` or `[-1]`
|
||||||
# chained to `select`, `find_all` or `filter` and change them to use
|
# chained to `select`, `find_all` or `filter` and change them to use
|
||||||
# `detect` instead.
|
# `detect` instead.
|
||||||
#
|
#
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop checks for double `#start_with?` or `#end_with?` calls
|
# Checks for double `#start_with?` or `#end_with?` calls
|
||||||
# separated by `||`. In some cases such calls can be replaced
|
# separated by `||`. In some cases such calls can be replaced
|
||||||
# with an single `#start_with?`/`#end_with?` call.
|
# with an single `#start_with?`/`#end_with?` call.
|
||||||
#
|
#
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies unnecessary use of a regex where `String#end_with?` would suffice.
|
# Identifies unnecessary use of a regex where `String#end_with?` would suffice.
|
||||||
#
|
#
|
||||||
# This cop has `SafeMultiline` configuration option that `true` by default because
|
# This cop has `SafeMultiline` configuration option that `true` by default because
|
||||||
# `end$` is unsafe as it will behave incompatible with `end_with?`
|
# `end$` is unsafe as it will behave incompatible with `end_with?`
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop is used to identify usages of `map { ... }.flatten` and
|
# Identifies usages of `map { ... }.flatten` and
|
||||||
# change them to use `flat_map { ... }` instead.
|
# change them to use `flat_map { ... }` instead.
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop checks for inefficient searching of keys and values within
|
# Checks for inefficient searching of keys and values within
|
||||||
# hashes.
|
# hashes.
|
||||||
#
|
#
|
||||||
# `Hash#keys.include?` is less efficient than `Hash#key?` because
|
# `Hash#keys.include?` is less efficient than `Hash#key?` because
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where inefficient `readlines` method
|
# Identifies places where inefficient `readlines` method
|
||||||
# can be replaced by `each_line` to avoid fully loading file content into memory.
|
# can be replaced by `each_line` to avoid fully loading file content into memory.
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where methods are converted to blocks, with the
|
# Identifies places where methods are converted to blocks, with the
|
||||||
# use of `&method`, and passed as arguments to method calls.
|
# use of `&method`, and passed as arguments to method calls.
|
||||||
# It is faster to replace those with explicit blocks, calling those methods inside.
|
# It is faster to replace those with explicit blocks, calling those methods inside.
|
||||||
#
|
#
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop checks for `OpenStruct.new` calls.
|
# Checks for `OpenStruct.new` calls.
|
||||||
# Instantiation of an `OpenStruct` invalidates
|
# Instantiation of an `OpenStruct` invalidates
|
||||||
# Ruby global method cache as it causes dynamic method
|
# Ruby global method cache as it causes dynamic method
|
||||||
# definition during program runtime.
|
# definition during program runtime.
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies uses of `Range#include?` and `Range#member?`, which iterates over each
|
# Identifies uses of `Range#include?` and `Range#member?`, which iterates over each
|
||||||
# item in a `Range` to see if a specified item is there. In contrast,
|
# item in a `Range` to see if a specified item is there. In contrast,
|
||||||
# `Range#cover?` simply compares the target item with the beginning and
|
# `Range#cover?` simply compares the target item with the beginning and
|
||||||
# end points of the `Range`. In a great majority of cases, this is what
|
# end points of the `Range`. In a great majority of cases, this is what
|
||||||
@ -11,7 +11,7 @@ module RuboCop
|
|||||||
#
|
#
|
||||||
# @safety
|
# @safety
|
||||||
# This cop is unsafe because `Range#include?` (or `Range#member?`) and `Range#cover?`
|
# This cop is unsafe because `Range#include?` (or `Range#member?`) and `Range#cover?`
|
||||||
# are not equivalent behaviour.
|
# are not equivalent behavior.
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies the use of a `&block` parameter and `block.call`
|
# Identifies the use of a `&block` parameter and `block.call`
|
||||||
# where `yield` would do just as well.
|
# where `yield` would do just as well.
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop checks for uses `Enumerable#all?`, `Enumerable#any?`, `Enumerable#one?`,
|
# Checks for uses `Enumerable#all?`, `Enumerable#any?`, `Enumerable#one?`,
|
||||||
# and `Enumerable#none?` are compared with `===` or similar methods in block.
|
# and `Enumerable#none?` are compared with `===` or similar methods in block.
|
||||||
#
|
#
|
||||||
# By default, `Object#===` behaves the same as `Object#==`, but this
|
# By default, `Object#===` behaves the same as `Object#==`, but this
|
||||||
@ -25,6 +25,9 @@ module RuboCop
|
|||||||
#
|
#
|
||||||
class RedundantEqualityComparisonBlock < Base
|
class RedundantEqualityComparisonBlock < Base
|
||||||
extend AutoCorrector
|
extend AutoCorrector
|
||||||
|
extend TargetRubyVersion
|
||||||
|
|
||||||
|
minimum_target_ruby_version 2.5
|
||||||
|
|
||||||
MSG = 'Use `%<prefer>s` instead of block.'
|
MSG = 'Use `%<prefer>s` instead of block.'
|
||||||
|
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies the use of `Regexp#match` or `String#match`, which
|
# Identifies the use of `Regexp#match` or `String#match`, which
|
||||||
# returns `#<MatchData>`/`nil`. The return value of `=~` is an integral
|
# returns `#<MatchData>`/`nil`. The return value of `=~` is an integral
|
||||||
# index/`nil` and is more performant.
|
# index/`nil` and is more performant.
|
||||||
#
|
#
|
||||||
@ -3,8 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where `Hash#merge!` can be replaced by
|
# Identifies places where `Hash#merge!` can be replaced by `Hash#[]=`.
|
||||||
# `Hash#[]=`.
|
|
||||||
# You can set the maximum number of key-value pairs to consider
|
# You can set the maximum number of key-value pairs to consider
|
||||||
# an offense with `MaxKeyValuePairs`.
|
# an offense with `MaxKeyValuePairs`.
|
||||||
#
|
#
|
||||||
@ -3,8 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where `sort { |a, b| a <=> b }`
|
# Identifies places where `sort { |a, b| a <=> b }` can be replaced with `sort`.
|
||||||
# can be replaced with `sort`.
|
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where `split` argument can be replaced from
|
# Identifies places where `split` argument can be replaced from
|
||||||
# a deterministic regexp to a string.
|
# a deterministic regexp to a string.
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop checks for redundant `String#chars`.
|
# Checks for redundant `String#chars`.
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
@ -3,8 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop is used to identify usages of `reverse.each` and
|
# Identifies usages of `reverse.each` and change them to use `reverse_each` instead.
|
||||||
# change them to use `reverse_each` instead.
|
|
||||||
#
|
#
|
||||||
# If the return value is used, it will not be detected because the result will be different.
|
# If the return value is used, it will not be detected because the result will be different.
|
||||||
#
|
#
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where `reverse.first(n)` and `reverse.first`
|
# Identifies places where `reverse.first(n)` and `reverse.first`
|
||||||
# can be replaced by `last(n).reverse` and `last`.
|
# can be replaced by `last(n).reverse` and `last`.
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
@ -3,8 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop is used to identify usages of `count` on an
|
# Identifies usages of `count` on an `Array` and `Hash` and change them to `size`.
|
||||||
# `Array` and `Hash` and change them to `size`.
|
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where `sort { |a, b| b <=> a }`
|
# Identifies places where `sort { |a, b| b <=> a }`
|
||||||
# can be replaced by a faster `sort.reverse`.
|
# can be replaced by a faster `sort.reverse`.
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where `gsub(/a+/, 'a')` and `gsub!(/a+/, 'a')`
|
# Identifies places where `gsub(/a+/, 'a')` and `gsub!(/a+/, 'a')`
|
||||||
# can be replaced by `squeeze('a')` and `squeeze!('a')`.
|
# can be replaced by `squeeze('a')` and `squeeze!('a')`.
|
||||||
#
|
#
|
||||||
# The `squeeze('a')` method is faster than `gsub(/a+/, 'a')`.
|
# The `squeeze('a')` method is faster than `gsub(/a+/, 'a')`.
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies unnecessary use of a regex where `String#start_with?` would suffice.
|
# Identifies unnecessary use of a regex where `String#start_with?` would suffice.
|
||||||
#
|
#
|
||||||
# This cop has `SafeMultiline` configuration option that `true` by default because
|
# This cop has `SafeMultiline` configuration option that `true` by default because
|
||||||
# `^start` is unsafe as it will behave incompatible with `start_with?`
|
# `^start` is unsafe as it will behave incompatible with `start_with?`
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where string identifier argument can be replaced
|
# Identifies places where string identifier argument can be replaced
|
||||||
# by symbol identifier argument.
|
# by symbol identifier argument.
|
||||||
# It prevents the redundancy of the internal string-to-symbol conversion.
|
# It prevents the redundancy of the internal string-to-symbol conversion.
|
||||||
#
|
#
|
||||||
@ -46,7 +46,7 @@ module RuboCop
|
|||||||
def on_send(node)
|
def on_send(node)
|
||||||
return unless (first_argument = node.first_argument)
|
return unless (first_argument = node.first_argument)
|
||||||
return unless first_argument.str_type?
|
return unless first_argument.str_type?
|
||||||
return if first_argument.value.include?(' ')
|
return if first_argument.value.include?(' ') || first_argument.value.include?('::')
|
||||||
|
|
||||||
replacement = first_argument.value.to_sym.inspect
|
replacement = first_argument.value.to_sym.inspect
|
||||||
|
|
||||||
@ -3,11 +3,10 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies unnecessary use of a regex where
|
# Identifies unnecessary use of a regex where `String#include?` would suffice.
|
||||||
# `String#include?` would suffice.
|
|
||||||
#
|
#
|
||||||
# @safety
|
# @safety
|
||||||
# This cop's offenses are not safe to auto-correct if a receiver is nil.
|
# This cop's offenses are not safe to autocorrect if a receiver is nil.
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
@ -3,8 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where `gsub` can be replaced by
|
# Identifies places where `gsub` can be replaced by `tr` or `delete`.
|
||||||
# `tr` or `delete`.
|
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where custom code finding the sum of elements
|
# Identifies places where custom code finding the sum of elements
|
||||||
# in some Enumerable object can be replaced by `Enumerable#sum` method.
|
# in some Enumerable object can be replaced by `Enumerable#sum` method.
|
||||||
#
|
#
|
||||||
# @safety
|
# @safety
|
||||||
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop checks for .times.map calls.
|
# Checks for .times.map calls.
|
||||||
# In most cases such calls can be replaced
|
# In most cases such calls can be replaced
|
||||||
# with an explicit array creation.
|
# with an explicit array creation.
|
||||||
#
|
#
|
||||||
@ -3,8 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where `URI::Parser.new`
|
# Identifies places where `URI::Parser.new` can be replaced by `URI::DEFAULT_PARSER`.
|
||||||
# can be replaced by `URI::DEFAULT_PARSER`.
|
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
@ -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.13.3'
|
STRING = '1.14.0'
|
||||||
|
|
||||||
def self.document_version
|
def self.document_version
|
||||||
STRING.match('\d+\.\d+').to_s
|
STRING.match('\d+\.\d+').to_s
|
||||||
Loading…
x
Reference in New Issue
Block a user