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/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.22.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-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-rspec-2.5.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.2/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.2/lib"
|
||||||
|
|||||||
@ -76,6 +76,12 @@ Performance/CompareWithBlock:
|
|||||||
Enabled: true
|
Enabled: true
|
||||||
VersionAdded: '0.46'
|
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:
|
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
|
||||||
@ -309,9 +315,9 @@ Performance/StartWith:
|
|||||||
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.'
|
||||||
Enabled: 'pending'
|
Enabled: 'pending'
|
||||||
AutoCorrect: false
|
|
||||||
SafeAutoCorrect: false
|
SafeAutoCorrect: false
|
||||||
VersionAdded: '1.7'
|
VersionAdded: '1.7'
|
||||||
|
VersionChanged: '1.12'
|
||||||
|
|
||||||
Performance/StringReplacement:
|
Performance/StringReplacement:
|
||||||
Description: >-
|
Description: >-
|
||||||
@ -6,6 +6,10 @@ module RuboCop
|
|||||||
# This cop is used to identify usages of `ancestors.include?` and
|
# This cop is used to identify usages of `ancestors.include?` and
|
||||||
# change them to use `<=` instead.
|
# 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
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
# A.ancestors.include?(B)
|
# A.ancestors.include?(B)
|
||||||
@ -7,7 +7,9 @@ module RuboCop
|
|||||||
# 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
|
||||||
# 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
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
@ -17,11 +17,13 @@ module RuboCop
|
|||||||
# this defining a higher level when condition to override a condition
|
# this defining a higher level when condition to override a condition
|
||||||
# that is inside of the splat expansion.
|
# that is inside of the splat expansion.
|
||||||
#
|
#
|
||||||
# This is not a guaranteed performance improvement. If the data being
|
# @safety
|
||||||
# processed by the `case` condition is normalized in a manner that favors
|
# This cop is not unsafe auto-correction because it is not a guaranteed
|
||||||
# hitting a condition in the splat expansion, it is possible that
|
# performance improvement. If the data being processed by the `case` condition is
|
||||||
# moving the splat condition to the end will use more memory,
|
# normalized in a manner that favors hitting a condition in the splat expansion,
|
||||||
# and run slightly slower.
|
# 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
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
@ -5,8 +5,10 @@ module RuboCop
|
|||||||
module Performance
|
module Performance
|
||||||
# This cop identifies places where a case-insensitive string comparison
|
# This cop identifies places where a case-insensitive string comparison
|
||||||
# can better be implemented using `casecmp`.
|
# 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
|
# @example
|
||||||
# # bad
|
# # 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
|
# follow calls to `select`, `find_all`, `filter` or `reject`. Querying logic can instead be
|
||||||
# passed to the `count` call.
|
# 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
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
# [1, 2, 3].select { |e| e > 2 }.size
|
# [1, 2, 3].select { |e| e > 2 }.size
|
||||||
@ -24,19 +46,6 @@ module RuboCop
|
|||||||
# [1, 2, 3].count { |e| e < 2 && e.even? }
|
# [1, 2, 3].count { |e| e < 2 && e.even? }
|
||||||
# Model.select('field AS field_one').count
|
# Model.select('field AS field_one').count
|
||||||
# Model.select(:value).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
|
class Count < Base
|
||||||
include RangeHelp
|
include RangeHelp
|
||||||
extend AutoCorrector
|
extend AutoCorrector
|
||||||
@ -7,7 +7,6 @@ module RuboCop
|
|||||||
#
|
#
|
||||||
# This cop identifies places where `gsub(/\Aprefix/, '')` and `sub(/\Aprefix/, '')`
|
# This cop identifies places where `gsub(/\Aprefix/, '')` and `sub(/\Aprefix/, '')`
|
||||||
# can be replaced by `delete_prefix('prefix')`.
|
# 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
|
# This cop has `SafeMultiline` configuration option that `true` by default because
|
||||||
# `^prefix` is unsafe as it will behave incompatible with `delete_prefix`
|
# `^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/, '')`.
|
# The `delete_prefix('prefix')` method is faster than `gsub(/\Aprefix/, '')`.
|
||||||
#
|
#
|
||||||
|
# @safety
|
||||||
|
# This cop is unsafe because `Pathname` has `sub` but not `delete_prefix`.
|
||||||
|
#
|
||||||
# @example
|
# @example
|
||||||
#
|
#
|
||||||
# # bad
|
# # bad
|
||||||
@ -47,9 +49,6 @@ 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
|
||||||
@ -7,7 +7,6 @@ module RuboCop
|
|||||||
#
|
#
|
||||||
# This cop identifies places where `gsub(/suffix\z/, '')` and `sub(/suffix\z/, '')`
|
# This cop identifies places where `gsub(/suffix\z/, '')` and `sub(/suffix\z/, '')`
|
||||||
# can be replaced by `delete_suffix('suffix')`.
|
# 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
|
# This cop has `SafeMultiline` configuration option that `true` by default because
|
||||||
# `suffix$` is unsafe as it will behave incompatible with `delete_suffix?`
|
# `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/, '')`.
|
# 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
|
# @example
|
||||||
#
|
#
|
||||||
# # bad
|
# # bad
|
||||||
@ -47,9 +49,6 @@ 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
|
||||||
@ -7,6 +7,11 @@ module RuboCop
|
|||||||
# 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.
|
||||||
#
|
#
|
||||||
|
# @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
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
# [].select { |item| true }.first
|
# [].select { |item| true }.first
|
||||||
@ -90,7 +95,7 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
|
|
||||||
def replacement(method, index)
|
def replacement(method, index)
|
||||||
if method == :last || method == :[] && index == -1
|
if method == :last || (method == :[] && index == -1)
|
||||||
"reverse.#{preferred_method}"
|
"reverse.#{preferred_method}"
|
||||||
else
|
else
|
||||||
preferred_method
|
preferred_method
|
||||||
@ -9,6 +9,11 @@ module RuboCop
|
|||||||
# `end$` is unsafe as it will behave incompatible with `end_with?`
|
# `end$` is unsafe as it will behave incompatible with `end_with?`
|
||||||
# for receiver is multiline string.
|
# 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
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
# 'abc'.match?(/bc\Z/)
|
# 'abc'.match?(/bc\Z/)
|
||||||
@ -15,6 +15,9 @@ module RuboCop
|
|||||||
# both perform an O(n) search through all of the values, calling `values`
|
# both perform an O(n) search through all of the values, calling `values`
|
||||||
# allocates a new array while using `value?` does not.
|
# 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
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
# { a: 1, b: 2 }.keys.include?(:a)
|
# { a: 1, b: 2 }.keys.include?(:a)
|
||||||
@ -6,8 +6,10 @@ module RuboCop
|
|||||||
# In Ruby 2.7, `Enumerable#filter_map` has been added.
|
# In Ruby 2.7, `Enumerable#filter_map` has been added.
|
||||||
#
|
#
|
||||||
# This cop identifies places where `map { ... }.compact` can be replaced by `filter_map`.
|
# 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]
|
# [source,ruby]
|
||||||
# ----
|
# ----
|
||||||
@ -11,6 +11,10 @@ module RuboCop
|
|||||||
# especially in case of single-threaded
|
# especially in case of single-threaded
|
||||||
# applications with multiple `OpenStruct` instantiations.
|
# applications with multiple `OpenStruct` instantiations.
|
||||||
#
|
#
|
||||||
|
# @safety
|
||||||
|
# This cop is unsafe because `OpenStruct.new` and `Struct.new`
|
||||||
|
# are not equivalent.
|
||||||
|
#
|
||||||
# @example
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
# class MyClass
|
# class MyClass
|
||||||
@ -9,8 +9,9 @@ module RuboCop
|
|||||||
# 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
|
||||||
# is wanted.
|
# is wanted.
|
||||||
#
|
#
|
||||||
# This cop is `Safe: false` by default because `Range#include?` (or `Range#member?`) and
|
# @safety
|
||||||
# `Range#cover?` are not equivalent behaviour.
|
# This cop is unsafe because `Range#include?` (or `Range#member?`) and `Range#cover?`
|
||||||
|
# are not equivalent behaviour.
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
@ -55,6 +55,7 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
alias on_defs on_def
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
@ -9,8 +9,9 @@ module RuboCop
|
|||||||
# By default, `Object#===` behaves the same as `Object#==`, but this
|
# By default, `Object#===` behaves the same as `Object#==`, but this
|
||||||
# behavior is appropriately overridden in subclass. For example,
|
# behavior is appropriately overridden in subclass. For example,
|
||||||
# `Range#===` returns `true` when argument is within the range.
|
# `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
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
@ -24,9 +25,6 @@ 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.'
|
||||||
|
|
||||||
@ -8,8 +8,9 @@ module RuboCop
|
|||||||
# 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`.
|
||||||
#
|
#
|
||||||
# This cop is marked as unsafe because RuboCop cannot determine if the
|
# @safety
|
||||||
# receiver of `merge!` is actually a hash or not.
|
# This cop is unsafe because RuboCop cannot determine if the
|
||||||
|
# receiver of `merge!` is actually a hash or not.
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
@ -91,7 +92,7 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
|
|
||||||
def non_redundant_pairs?(receiver, pairs)
|
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
|
end
|
||||||
|
|
||||||
def kwsplat_used?(pairs)
|
def kwsplat_used?(pairs)
|
||||||
@ -9,6 +9,11 @@ module RuboCop
|
|||||||
# `^start` is unsafe as it will behave incompatible with `start_with?`
|
# `^start` is unsafe as it will behave incompatible with `start_with?`
|
||||||
# for receiver is multiline string.
|
# 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
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
# 'abc'.match?(/\Aab/)
|
# 'abc'.match?(/\Aab/)
|
||||||
@ -6,7 +6,8 @@ module RuboCop
|
|||||||
# This cop identifies unnecessary use of a regex where
|
# This cop identifies unnecessary use of a regex where
|
||||||
# `String#include?` would suffice.
|
# `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
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
@ -156,7 +156,7 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
|
|
||||||
def sum_method_range(node)
|
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
|
end
|
||||||
|
|
||||||
def sum_map_range(map, sum)
|
def sum_map_range(map, sum)
|
||||||
@ -7,6 +7,18 @@ module RuboCop
|
|||||||
# 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.
|
||||||
#
|
#
|
||||||
|
# @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
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
# 9.times.map do |i|
|
# 9.times.map do |i|
|
||||||
@ -7,11 +7,11 @@ module RuboCop
|
|||||||
# literal instead of `String#dup` and `String.new`.
|
# literal instead of `String#dup` and `String.new`.
|
||||||
# Unary plus operator is faster than `String#dup`.
|
# Unary plus operator is faster than `String#dup`.
|
||||||
#
|
#
|
||||||
# NOTE: `String.new` (without operator) is not exactly the same as `+''`.
|
# @safety
|
||||||
# These differ in encoding. `String.new.encoding` is always `ASCII-8BIT`.
|
# This cop's autocorrection is unsafe because `String.new` (without operator) is not
|
||||||
# However, `(+'').encoding` is the same as script encoding(e.g. `UTF-8`).
|
# exactly the same as `+''`. These differ in encoding. `String.new.encoding` is always
|
||||||
# Therefore, auto-correction is unsafe.
|
# `ASCII-8BIT`. However, `(+'').encoding` is the same as script encoding(e.g. `UTF-8`).
|
||||||
# So, if you expect `ASCII-8BIT` encoding, disable this cop.
|
# if you expect `ASCII-8BIT` encoding, disable this cop.
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
# # bad
|
# # bad
|
||||||
@ -13,6 +13,7 @@ require_relative 'performance/case_when_splat'
|
|||||||
require_relative 'performance/casecmp'
|
require_relative 'performance/casecmp'
|
||||||
require_relative 'performance/collection_literal_in_loop'
|
require_relative 'performance/collection_literal_in_loop'
|
||||||
require_relative 'performance/compare_with_block'
|
require_relative 'performance/compare_with_block'
|
||||||
|
require_relative 'performance/concurrent_monotonic_time'
|
||||||
require_relative 'performance/constant_regexp'
|
require_relative 'performance/constant_regexp'
|
||||||
require_relative 'performance/count'
|
require_relative 'performance/count'
|
||||||
require_relative 'performance/delete_prefix'
|
require_relative 'performance/delete_prefix'
|
||||||
@ -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.11.5'
|
STRING = '1.12.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