mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
brew vendor-gems: commit updates.
This commit is contained in:
parent
9c693d7dc8
commit
c3f7b7f94c
@ -62,7 +62,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-wait-0.0.9/lib"
|
|||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.10.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.10.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-1.6.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-1.6.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-0.69.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-0.69.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.2.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.3.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-1.33.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-1.33.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.2.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.2.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-cobertura-1.3.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-cobertura-1.3.1/lib"
|
||||||
|
209
Library/Homebrew/vendor/bundle/ruby/2.3.0/gems/rubocop-performance-1.3.0/config/default.yml
vendored
Normal file
209
Library/Homebrew/vendor/bundle/ruby/2.3.0/gems/rubocop-performance-1.3.0/config/default.yml
vendored
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
# This is the default configuration file.
|
||||||
|
|
||||||
|
Performance/Caller:
|
||||||
|
Description: >-
|
||||||
|
Use `caller(n..n)` instead of `caller`.
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.49'
|
||||||
|
|
||||||
|
Performance/CaseWhenSplat:
|
||||||
|
Description: >-
|
||||||
|
Reordering `when` conditions with a splat to the end
|
||||||
|
of the `when` branches can improve performance.
|
||||||
|
Enabled: false
|
||||||
|
AutoCorrect: false
|
||||||
|
SafeAutoCorrect: false
|
||||||
|
VersionAdded: '0.34'
|
||||||
|
VersionChanged: '0.59'
|
||||||
|
|
||||||
|
Performance/Casecmp:
|
||||||
|
Description: >-
|
||||||
|
Use `casecmp` rather than `downcase ==`, `upcase ==`, `== downcase`, or `== upcase`..
|
||||||
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringcasecmp-vs-stringdowncase---code'
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.36'
|
||||||
|
|
||||||
|
Performance/ChainArrayAllocation:
|
||||||
|
Description: >-
|
||||||
|
Instead of chaining array methods that allocate new arrays, mutate an
|
||||||
|
existing array.
|
||||||
|
Reference: 'https://twitter.com/schneems/status/1034123879978029057'
|
||||||
|
Enabled: false
|
||||||
|
VersionAdded: '0.59'
|
||||||
|
|
||||||
|
Performance/CompareWithBlock:
|
||||||
|
Description: 'Use `sort_by(&:foo)` instead of `sort { |a, b| a.foo <=> b.foo }`.'
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.46'
|
||||||
|
|
||||||
|
Performance/Count:
|
||||||
|
Description: >-
|
||||||
|
Use `count` instead of `select...size`, `reject...size`,
|
||||||
|
`select...count`, `reject...count`, `select...length`,
|
||||||
|
and `reject...length`.
|
||||||
|
# This cop has known compatibility issues with `ActiveRecord` and other
|
||||||
|
# frameworks. ActiveRecord's `count` ignores the block that is passed to it.
|
||||||
|
# For more information, see the documentation in the cop itself.
|
||||||
|
# If you understand the known risk, you can disable `SafeMode`.
|
||||||
|
SafeMode: true
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.31'
|
||||||
|
VersionChanged: '0.39'
|
||||||
|
|
||||||
|
Performance/Detect:
|
||||||
|
Description: >-
|
||||||
|
Use `detect` instead of `select.first`, `find_all.first`,
|
||||||
|
`select.last`, and `find_all.last`.
|
||||||
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code'
|
||||||
|
# This cop 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.
|
||||||
|
SafeMode: true
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.30'
|
||||||
|
VersionChanged: '0.39'
|
||||||
|
|
||||||
|
Performance/DoubleStartEndWith:
|
||||||
|
Description: >-
|
||||||
|
Use `str.{start,end}_with?(x, ..., y, ...)`
|
||||||
|
instead of `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`.
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.36'
|
||||||
|
VersionChanged: '0.48'
|
||||||
|
# Used to check for `starts_with?` and `ends_with?`.
|
||||||
|
# These methods are defined by `ActiveSupport`.
|
||||||
|
IncludeActiveSupportAliases: false
|
||||||
|
|
||||||
|
Performance/EndWith:
|
||||||
|
Description: 'Use `end_with?` instead of a regex match anchored to the end of a string.'
|
||||||
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringmatch-vs-stringstart_withstringend_with-code-start-code-end'
|
||||||
|
# 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.
|
||||||
|
SafeAutoCorrect: false
|
||||||
|
AutoCorrect: false
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.36'
|
||||||
|
VersionChanged: '0.44'
|
||||||
|
|
||||||
|
Performance/FixedSize:
|
||||||
|
Description: 'Do not compute the size of statically sized objects except in constants'
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.35'
|
||||||
|
|
||||||
|
Performance/FlatMap:
|
||||||
|
Description: >-
|
||||||
|
Use `Enumerable#flat_map`
|
||||||
|
instead of `Enumerable#map...Array#flatten(1)`
|
||||||
|
or `Enumberable#collect..Array#flatten(1)`
|
||||||
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablemaparrayflatten-vs-enumerableflat_map-code'
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.30'
|
||||||
|
EnabledForFlattenWithoutParams: false
|
||||||
|
# If enabled, this cop will warn about usages of
|
||||||
|
# `flatten` being called without any parameters.
|
||||||
|
# This can be dangerous since `flat_map` will only flatten 1 level, and
|
||||||
|
# `flatten` without any parameters can flatten multiple levels.
|
||||||
|
|
||||||
|
Performance/InefficientHashSearch:
|
||||||
|
Description: 'Use `key?` or `value?` instead of `keys.include?` or `values.include?`'
|
||||||
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#hashkey-instead-of-hashkeysinclude-code'
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.56'
|
||||||
|
Safe: false
|
||||||
|
|
||||||
|
Performance/OpenStruct:
|
||||||
|
Description: 'Use `Struct` instead of `OpenStruct`.'
|
||||||
|
Enabled: false
|
||||||
|
VersionAdded: '0.61'
|
||||||
|
Safe: false
|
||||||
|
|
||||||
|
Performance/RangeInclude:
|
||||||
|
Description: 'Use `Range#cover?` instead of `Range#include?`.'
|
||||||
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#cover-vs-include-code'
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.36'
|
||||||
|
Safe: false
|
||||||
|
|
||||||
|
Performance/RedundantBlockCall:
|
||||||
|
Description: 'Use `yield` instead of `block.call`.'
|
||||||
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#proccall-and-block-arguments-vs-yieldcode'
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.36'
|
||||||
|
|
||||||
|
Performance/RedundantMatch:
|
||||||
|
Description: >-
|
||||||
|
Use `=~` instead of `String#match` or `Regexp#match` in a context where the
|
||||||
|
returned `MatchData` is not needed.
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.36'
|
||||||
|
|
||||||
|
Performance/RedundantMerge:
|
||||||
|
Description: 'Use Hash#[]=, rather than Hash#merge! with a single key-value pair.'
|
||||||
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#hashmerge-vs-hash-code'
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.36'
|
||||||
|
# Max number of key-value pairs to consider an offense
|
||||||
|
MaxKeyValuePairs: 2
|
||||||
|
|
||||||
|
Performance/RegexpMatch:
|
||||||
|
Description: >-
|
||||||
|
Use `match?` instead of `Regexp#match`, `String#match`, `Symbol#match`,
|
||||||
|
`Regexp#===`, or `=~` when `MatchData` is not used.
|
||||||
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#regexp-vs-stringmatch-vs-string-vs-stringmatch-code-'
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.47'
|
||||||
|
|
||||||
|
Performance/ReverseEach:
|
||||||
|
Description: 'Use `reverse_each` instead of `reverse.each`.'
|
||||||
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code'
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.30'
|
||||||
|
|
||||||
|
Performance/Size:
|
||||||
|
Description: >-
|
||||||
|
Use `size` instead of `count` for counting
|
||||||
|
the number of elements in `Array` and `Hash`.
|
||||||
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#arraylength-vs-arraysize-vs-arraycount-code'
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.30'
|
||||||
|
|
||||||
|
Performance/StartWith:
|
||||||
|
Description: 'Use `start_with?` instead of a regex match anchored to the beginning of a string.'
|
||||||
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringmatch-vs-stringstart_withstringend_with-code-start-code-end'
|
||||||
|
# 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.
|
||||||
|
SafeAutoCorrect: false
|
||||||
|
AutoCorrect: false
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.36'
|
||||||
|
VersionChanged: '0.44'
|
||||||
|
|
||||||
|
Performance/StringReplacement:
|
||||||
|
Description: >-
|
||||||
|
Use `tr` instead of `gsub` when you are replacing the same
|
||||||
|
number of characters. Use `delete` instead of `gsub` when
|
||||||
|
you are deleting characters.
|
||||||
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code'
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.33'
|
||||||
|
|
||||||
|
Performance/TimesMap:
|
||||||
|
Description: 'Checks for .times.map calls.'
|
||||||
|
AutoCorrect: false
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.36'
|
||||||
|
VersionChanged: '0.50'
|
||||||
|
SafeAutoCorrect: false # see https://github.com/rubocop-hq/rubocop/issues/4658
|
||||||
|
|
||||||
|
Performance/UnfreezeString:
|
||||||
|
Description: 'Use unary plus to get an unfrozen string literal.'
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.50'
|
||||||
|
|
||||||
|
Performance/UriDefaultParser:
|
||||||
|
Description: 'Use `URI::DEFAULT_PARSER` instead of `URI::Parser.new`.'
|
||||||
|
Enabled: true
|
||||||
|
VersionAdded: '0.50'
|
@ -20,9 +20,9 @@ module RuboCop
|
|||||||
# caller_locations(1..1).first
|
# caller_locations(1..1).first
|
||||||
class Caller < Cop
|
class Caller < Cop
|
||||||
MSG_BRACE = 'Use `%<method>s(%<n>d..%<n>d).first`' \
|
MSG_BRACE = 'Use `%<method>s(%<n>d..%<n>d).first`' \
|
||||||
' instead of `%<method>s[%<m>d]`.'.freeze
|
' instead of `%<method>s[%<m>d]`.'
|
||||||
MSG_FIRST = 'Use `%<method>s(%<n>d..%<n>d).first`' \
|
MSG_FIRST = 'Use `%<method>s(%<n>d..%<n>d).first`' \
|
||||||
' instead of `%<method>s.first`.'.freeze
|
' instead of `%<method>s.first`.'
|
||||||
|
|
||||||
def_node_matcher :slow_caller?, <<-PATTERN
|
def_node_matcher :slow_caller?, <<-PATTERN
|
||||||
{
|
{
|
@ -58,9 +58,9 @@ module RuboCop
|
|||||||
include RangeHelp
|
include RangeHelp
|
||||||
|
|
||||||
MSG = 'Reordering `when` conditions with a splat to the end ' \
|
MSG = 'Reordering `when` conditions with a splat to the end ' \
|
||||||
'of the `when` branches can improve performance.'.freeze
|
'of the `when` branches can improve performance.'
|
||||||
ARRAY_MSG = 'Pass the contents of array literals ' \
|
ARRAY_MSG = 'Pass the contents of array literals ' \
|
||||||
'directly to `when` conditions.'.freeze
|
'directly to `when` conditions.'
|
||||||
|
|
||||||
def on_case(case_node)
|
def on_case(case_node)
|
||||||
when_conditions = case_node.when_branches.flat_map(&:conditions)
|
when_conditions = case_node.when_branches.flat_map(&:conditions)
|
@ -18,7 +18,7 @@ module RuboCop
|
|||||||
# str.casecmp('ABC').zero?
|
# str.casecmp('ABC').zero?
|
||||||
# 'abc'.casecmp(str).zero?
|
# 'abc'.casecmp(str).zero?
|
||||||
class Casecmp < Cop
|
class Casecmp < Cop
|
||||||
MSG = 'Use `%<good>s` instead of `%<bad>s`.'.freeze
|
MSG = 'Use `%<good>s` instead of `%<bad>s`.'
|
||||||
CASE_METHODS = %i[downcase upcase].freeze
|
CASE_METHODS = %i[downcase upcase].freeze
|
||||||
|
|
||||||
def_node_matcher :downcase_eq, <<-PATTERN
|
def_node_matcher :downcase_eq, <<-PATTERN
|
@ -29,10 +29,10 @@ module RuboCop
|
|||||||
# [1,2].first # => 1
|
# [1,2].first # => 1
|
||||||
# [1,2].first(1) # => [1]
|
# [1,2].first(1) # => [1]
|
||||||
#
|
#
|
||||||
RETURN_NEW_ARRAY_WHEN_ARGS = ':first :last :pop :sample :shift '.freeze
|
RETURN_NEW_ARRAY_WHEN_ARGS = ':first :last :pop :sample :shift '
|
||||||
|
|
||||||
# These methods return a new array only when called without a block.
|
# These methods return a new array only when called without a block.
|
||||||
RETURNS_NEW_ARRAY_WHEN_NO_BLOCK = ':zip :product '.freeze
|
RETURNS_NEW_ARRAY_WHEN_NO_BLOCK = ':zip :product '
|
||||||
|
|
||||||
# These methods ALWAYS return a new array
|
# These methods ALWAYS return a new array
|
||||||
# after they're called it's safe to mutate the the resulting array
|
# after they're called it's safe to mutate the the resulting array
|
||||||
@ -40,16 +40,16 @@ module RuboCop
|
|||||||
':drop_while :flatten :map :reject ' \
|
':drop_while :flatten :map :reject ' \
|
||||||
':reverse :rotate :select :shuffle :sort ' \
|
':reverse :rotate :select :shuffle :sort ' \
|
||||||
':take :take_while :transpose :uniq ' \
|
':take :take_while :transpose :uniq ' \
|
||||||
':values_at :| '.freeze
|
':values_at :| '
|
||||||
|
|
||||||
# These methods have a mutation alternative. For example :collect
|
# These methods have a mutation alternative. For example :collect
|
||||||
# can be called as :collect!
|
# can be called as :collect!
|
||||||
HAS_MUTATION_ALTERNATIVE = ':collect :compact :flatten :map :reject '\
|
HAS_MUTATION_ALTERNATIVE = ':collect :compact :flatten :map :reject '\
|
||||||
':reverse :rotate :select :shuffle :sort '\
|
':reverse :rotate :select :shuffle :sort '\
|
||||||
':uniq '.freeze
|
':uniq '
|
||||||
MSG = 'Use unchained `%<method>s!` and `%<second_method>s!` '\
|
MSG = 'Use unchained `%<method>s!` and `%<second_method>s!` '\
|
||||||
'(followed by `return array` if required) instead of chaining '\
|
'(followed by `return array` if required) instead of chaining '\
|
||||||
'`%<method>s...%<second_method>s`.'.freeze
|
'`%<method>s...%<second_method>s`.'
|
||||||
|
|
||||||
def_node_matcher :flat_map_candidate?, <<-PATTERN
|
def_node_matcher :flat_map_candidate?, <<-PATTERN
|
||||||
{
|
{
|
@ -28,7 +28,7 @@ module RuboCop
|
|||||||
|
|
||||||
MSG = 'Use `%<compare_method>s_by%<instead>s` instead of ' \
|
MSG = 'Use `%<compare_method>s_by%<instead>s` instead of ' \
|
||||||
'`%<compare_method>s { |%<var_a>s, %<var_b>s| %<str_a>s ' \
|
'`%<compare_method>s { |%<var_a>s, %<var_b>s| %<str_a>s ' \
|
||||||
'<=> %<str_b>s }`.'.freeze
|
'<=> %<str_b>s }`.'
|
||||||
|
|
||||||
def_node_matcher :compare?, <<-PATTERN
|
def_node_matcher :compare?, <<-PATTERN
|
||||||
(block
|
(block
|
@ -41,7 +41,7 @@ module RuboCop
|
|||||||
include SafeMode
|
include SafeMode
|
||||||
include RangeHelp
|
include RangeHelp
|
||||||
|
|
||||||
MSG = 'Use `count` instead of `%<selector>s...%<counter>s`.'.freeze
|
MSG = 'Use `count` instead of `%<selector>s...%<counter>s`.'
|
||||||
|
|
||||||
def_node_matcher :count_candidate?, <<-PATTERN
|
def_node_matcher :count_candidate?, <<-PATTERN
|
||||||
{
|
{
|
@ -26,9 +26,9 @@ module RuboCop
|
|||||||
include SafeMode
|
include SafeMode
|
||||||
|
|
||||||
MSG = 'Use `%<prefer>s` instead of ' \
|
MSG = 'Use `%<prefer>s` instead of ' \
|
||||||
'`%<first_method>s.%<second_method>s`.'.freeze
|
'`%<first_method>s.%<second_method>s`.'
|
||||||
REVERSE_MSG = 'Use `reverse.%<prefer>s` instead of ' \
|
REVERSE_MSG = 'Use `reverse.%<prefer>s` instead of ' \
|
||||||
'`%<first_method>s.%<second_method>s`.'.freeze
|
'`%<first_method>s.%<second_method>s`.'
|
||||||
|
|
||||||
def_node_matcher :detect_candidate?, <<-PATTERN
|
def_node_matcher :detect_candidate?, <<-PATTERN
|
||||||
{
|
{
|
@ -19,7 +19,7 @@ module RuboCop
|
|||||||
# str.end_with?(var1, var2)
|
# str.end_with?(var1, var2)
|
||||||
class DoubleStartEndWith < Cop
|
class DoubleStartEndWith < Cop
|
||||||
MSG = 'Use `%<receiver>s.%<method>s(%<combined_args>s)` ' \
|
MSG = 'Use `%<receiver>s.%<method>s(%<combined_args>s)` ' \
|
||||||
'instead of `%<original_code>s`.'.freeze
|
'instead of `%<original_code>s`.'
|
||||||
|
|
||||||
def on_or(node)
|
def on_or(node)
|
||||||
receiver,
|
receiver,
|
@ -16,8 +16,8 @@ module RuboCop
|
|||||||
# 'abc'.end_with?('bc')
|
# 'abc'.end_with?('bc')
|
||||||
class EndWith < Cop
|
class EndWith < Cop
|
||||||
MSG = 'Use `String#end_with?` instead of a regex match anchored to ' \
|
MSG = 'Use `String#end_with?` instead of a regex match anchored to ' \
|
||||||
'the end of the string.'.freeze
|
'the end of the string.'
|
||||||
SINGLE_QUOTE = "'".freeze
|
SINGLE_QUOTE = "'"
|
||||||
|
|
||||||
def_node_matcher :redundant_regex?, <<-PATTERN
|
def_node_matcher :redundant_regex?, <<-PATTERN
|
||||||
{(send $!nil? {:match :=~ :match?} (regexp (str $#literal_at_end?) (regopt)))
|
{(send $!nil? {:match :=~ :match?} (regexp (str $#literal_at_end?) (regopt)))
|
@ -46,7 +46,7 @@ module RuboCop
|
|||||||
# waldo.size
|
# waldo.size
|
||||||
#
|
#
|
||||||
class FixedSize < Cop
|
class FixedSize < Cop
|
||||||
MSG = 'Do not compute the size of statically sized objects.'.freeze
|
MSG = 'Do not compute the size of statically sized objects.'
|
||||||
|
|
||||||
def_node_matcher :counter, <<-MATCHER
|
def_node_matcher :counter, <<-MATCHER
|
||||||
(send ${array hash str sym} {:count :length :size} $...)
|
(send ${array hash str sym} {:count :length :size} $...)
|
@ -17,10 +17,10 @@ module RuboCop
|
|||||||
class FlatMap < Cop
|
class FlatMap < Cop
|
||||||
include RangeHelp
|
include RangeHelp
|
||||||
|
|
||||||
MSG = 'Use `flat_map` instead of `%<method>s...%<flatten>s`.'.freeze
|
MSG = 'Use `flat_map` instead of `%<method>s...%<flatten>s`.'
|
||||||
FLATTEN_MULTIPLE_LEVELS = ' Beware, `flat_map` only flattens 1 level ' \
|
FLATTEN_MULTIPLE_LEVELS = ' Beware, `flat_map` only flattens 1 level ' \
|
||||||
'and `flatten` can be used to flatten ' \
|
'and `flatten` can be used to flatten ' \
|
||||||
'multiple levels.'.freeze
|
'multiple levels.'
|
||||||
|
|
||||||
def_node_matcher :flat_map_candidate?, <<-PATTERN
|
def_node_matcher :flat_map_candidate?, <<-PATTERN
|
||||||
(send (block $(send _ ${:collect :map}) ...) ${:flatten :flatten!} $...)
|
(send (block $(send _ ${:collect :map}) ...) ${:flatten :flatten!} $...)
|
@ -29,7 +29,7 @@ module RuboCop
|
|||||||
#
|
#
|
||||||
class OpenStruct < Cop
|
class OpenStruct < Cop
|
||||||
MSG = 'Consider using `Struct` over `OpenStruct` ' \
|
MSG = 'Consider using `Struct` over `OpenStruct` ' \
|
||||||
'to optimize the performance.'.freeze
|
'to optimize the performance.'
|
||||||
|
|
||||||
def_node_matcher :open_struct, <<-PATTERN
|
def_node_matcher :open_struct, <<-PATTERN
|
||||||
(send (const {nil? cbase} :OpenStruct) :new ...)
|
(send (const {nil? cbase} :OpenStruct) :new ...)
|
@ -24,7 +24,7 @@ module RuboCop
|
|||||||
#
|
#
|
||||||
# ('a'..'z').cover?('yellow') # => true
|
# ('a'..'z').cover?('yellow') # => true
|
||||||
class RangeInclude < Cop
|
class RangeInclude < Cop
|
||||||
MSG = 'Use `Range#cover?` instead of `Range#include?`.'.freeze
|
MSG = 'Use `Range#cover?` instead of `Range#include?`.'
|
||||||
|
|
||||||
# TODO: If we traced out assignments of variables to their uses, we
|
# TODO: If we traced out assignments of variables to their uses, we
|
||||||
# might pick up on a few more instances of this issue
|
# might pick up on a few more instances of this issue
|
@ -23,11 +23,11 @@ module RuboCop
|
|||||||
# yield 1, 2, 3
|
# yield 1, 2, 3
|
||||||
# end
|
# end
|
||||||
class RedundantBlockCall < Cop
|
class RedundantBlockCall < Cop
|
||||||
MSG = 'Use `yield` instead of `%<argname>s.call`.'.freeze
|
MSG = 'Use `yield` instead of `%<argname>s.call`.'
|
||||||
YIELD = 'yield'.freeze
|
YIELD = 'yield'
|
||||||
OPEN_PAREN = '('.freeze
|
OPEN_PAREN = '('
|
||||||
CLOSE_PAREN = ')'.freeze
|
CLOSE_PAREN = ')'
|
||||||
SPACE = ' '.freeze
|
SPACE = ' '
|
||||||
|
|
||||||
def_node_matcher :blockarg_def, <<-PATTERN
|
def_node_matcher :blockarg_def, <<-PATTERN
|
||||||
{(def _ (args ... (blockarg $_)) $_)
|
{(def _ (args ... (blockarg $_)) $_)
|
@ -19,7 +19,7 @@ module RuboCop
|
|||||||
# return value unless regex =~ 'str'
|
# return value unless regex =~ 'str'
|
||||||
class RedundantMatch < Cop
|
class RedundantMatch < Cop
|
||||||
MSG = 'Use `=~` in places where the `MatchData` returned by ' \
|
MSG = 'Use `=~` in places where the `MatchData` returned by ' \
|
||||||
'`#match` will not be used.'.freeze
|
'`#match` will not be used.'
|
||||||
|
|
||||||
# 'match' is a fairly generic name, so we don't flag it unless we see
|
# 'match' is a fairly generic name, so we don't flag it unless we see
|
||||||
# a string or regexp literal on one side or the other
|
# a string or regexp literal on one side or the other
|
@ -11,10 +11,10 @@ module RuboCop
|
|||||||
# hash.merge!({'key' => 'value'})
|
# hash.merge!({'key' => 'value'})
|
||||||
# hash.merge!(a: 1, b: 2)
|
# hash.merge!(a: 1, b: 2)
|
||||||
class RedundantMerge < Cop
|
class RedundantMerge < Cop
|
||||||
AREF_ASGN = '%<receiver>s[%<key>s] = %<value>s'.freeze
|
AREF_ASGN = '%<receiver>s[%<key>s] = %<value>s'
|
||||||
MSG = 'Use `%<prefer>s` instead of `%<current>s`.'.freeze
|
MSG = 'Use `%<prefer>s` instead of `%<current>s`.'
|
||||||
|
|
||||||
WITH_MODIFIER_CORRECTION = <<-RUBY.strip_indent
|
WITH_MODIFIER_CORRECTION = <<~RUBY
|
||||||
%<keyword>s %<condition>s
|
%<keyword>s %<condition>s
|
||||||
%<leading_space>s%<indent>s%<body>s
|
%<leading_space>s%<indent>s%<body>s
|
||||||
%<leading_space>send
|
%<leading_space>send
|
@ -80,14 +80,14 @@ module RuboCop
|
|||||||
# Constants are included in this list because it is unlikely that
|
# Constants are included in this list because it is unlikely that
|
||||||
# someone will store `nil` as a constant and then use it for comparison
|
# someone will store `nil` as a constant and then use it for comparison
|
||||||
TYPES_IMPLEMENTING_MATCH = %i[const regexp str sym].freeze
|
TYPES_IMPLEMENTING_MATCH = %i[const regexp str sym].freeze
|
||||||
MSG =
|
MSG = 'Use `match?` instead of `%<current>s` when `MatchData` ' \
|
||||||
'Use `match?` instead of `%<current>s` when `MatchData` ' \
|
'is not used.'
|
||||||
'is not used.'.freeze
|
|
||||||
|
|
||||||
def_node_matcher :match_method?, <<-PATTERN
|
def_node_matcher :match_method?, <<-PATTERN
|
||||||
{
|
{
|
||||||
(send _recv :match _ <int ...>)
|
(send _recv :match _ <int ...>)
|
||||||
(send _recv :match _)
|
(send _recv :match {regexp str sym})
|
||||||
|
(send {regexp str sym} :match _)
|
||||||
}
|
}
|
||||||
PATTERN
|
PATTERN
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ module RuboCop
|
|||||||
regexp.to_regexp.named_captures.empty?
|
regexp.to_regexp.named_captures.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
MATCH_NODE_PATTERN = <<-PATTERN.freeze
|
MATCH_NODE_PATTERN = <<-PATTERN
|
||||||
{
|
{
|
||||||
#match_method?
|
#match_method?
|
||||||
#match_operator?
|
#match_operator?
|
@ -15,8 +15,8 @@ module RuboCop
|
|||||||
class ReverseEach < Cop
|
class ReverseEach < Cop
|
||||||
include RangeHelp
|
include RangeHelp
|
||||||
|
|
||||||
MSG = 'Use `reverse_each` instead of `reverse.each`.'.freeze
|
MSG = 'Use `reverse_each` instead of `reverse.each`.'
|
||||||
UNDERSCORE = '_'.freeze
|
UNDERSCORE = '_'
|
||||||
|
|
||||||
def_node_matcher :reverse_each?, <<-MATCHER
|
def_node_matcher :reverse_each?, <<-MATCHER
|
||||||
(send $(send _ :reverse) :each)
|
(send $(send _ :reverse) :each)
|
@ -24,7 +24,7 @@ module RuboCop
|
|||||||
# TODO: Add advanced detection of variables that could
|
# TODO: Add advanced detection of variables that could
|
||||||
# have been assigned to an array or a hash.
|
# have been assigned to an array or a hash.
|
||||||
class Size < Cop
|
class Size < Cop
|
||||||
MSG = 'Use `size` instead of `count`.'.freeze
|
MSG = 'Use `size` instead of `count`.'
|
||||||
|
|
||||||
def on_send(node)
|
def on_send(node)
|
||||||
return unless eligible_node?(node)
|
return unless eligible_node?(node)
|
||||||
@ -51,7 +51,7 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
|
|
||||||
def allowed_parent?(node)
|
def allowed_parent?(node)
|
||||||
node && node.block_type?
|
node&.block_type?
|
||||||
end
|
end
|
||||||
|
|
||||||
def array?(node)
|
def array?(node)
|
@ -16,8 +16,8 @@ module RuboCop
|
|||||||
# 'abc'.start_with?('ab')
|
# 'abc'.start_with?('ab')
|
||||||
class StartWith < Cop
|
class StartWith < Cop
|
||||||
MSG = 'Use `String#start_with?` instead of a regex match anchored to ' \
|
MSG = 'Use `String#start_with?` instead of a regex match anchored to ' \
|
||||||
'the beginning of the string.'.freeze
|
'the beginning of the string.'
|
||||||
SINGLE_QUOTE = "'".freeze
|
SINGLE_QUOTE = "'"
|
||||||
|
|
||||||
def_node_matcher :redundant_regex?, <<-PATTERN
|
def_node_matcher :redundant_regex?, <<-PATTERN
|
||||||
{(send $!nil? {:match :=~ :match?} (regexp (str $#literal_at_start?) (regopt)))
|
{(send $!nil? {:match :=~ :match?} (regexp (str $#literal_at_start?) (regopt)))
|
@ -21,12 +21,12 @@ module RuboCop
|
|||||||
class StringReplacement < Cop
|
class StringReplacement < Cop
|
||||||
include RangeHelp
|
include RangeHelp
|
||||||
|
|
||||||
MSG = 'Use `%<prefer>s` instead of `%<current>s`.'.freeze
|
MSG = 'Use `%<prefer>s` instead of `%<current>s`.'
|
||||||
DETERMINISTIC_REGEX = /\A(?:#{LITERAL_REGEX})+\Z/.freeze
|
DETERMINISTIC_REGEX = /\A(?:#{LITERAL_REGEX})+\Z/.freeze
|
||||||
DELETE = 'delete'.freeze
|
DELETE = 'delete'
|
||||||
TR = 'tr'.freeze
|
TR = 'tr'
|
||||||
BANG = '!'.freeze
|
BANG = '!'
|
||||||
SINGLE_QUOTE = "'".freeze
|
SINGLE_QUOTE = "'"
|
||||||
|
|
||||||
def_node_matcher :string_replacement?, <<-PATTERN
|
def_node_matcher :string_replacement?, <<-PATTERN
|
||||||
(send _ {:gsub :gsub!}
|
(send _ {:gsub :gsub!}
|
@ -19,8 +19,8 @@ module RuboCop
|
|||||||
# end
|
# end
|
||||||
class TimesMap < Cop
|
class TimesMap < Cop
|
||||||
MESSAGE = 'Use `Array.new(%<count>s)` with a block ' \
|
MESSAGE = 'Use `Array.new(%<count>s)` with a block ' \
|
||||||
'instead of `.times.%<map_or_collect>s`'.freeze
|
'instead of `.times.%<map_or_collect>s`'
|
||||||
MESSAGE_ONLY_IF = 'only if `%<count>s` is always 0 or more'.freeze
|
MESSAGE_ONLY_IF = 'only if `%<count>s` is always 0 or more'
|
||||||
|
|
||||||
def on_send(node)
|
def on_send(node)
|
||||||
check(node)
|
check(node)
|
@ -28,7 +28,7 @@ module RuboCop
|
|||||||
|
|
||||||
minimum_target_ruby_version 2.3
|
minimum_target_ruby_version 2.3
|
||||||
|
|
||||||
MSG = 'Use unary plus to get an unfrozen string literal.'.freeze
|
MSG = 'Use unary plus to get an unfrozen string literal.'
|
||||||
|
|
||||||
def_node_matcher :dup_string?, <<-PATTERN
|
def_node_matcher :dup_string?, <<-PATTERN
|
||||||
(send {str dstr} :dup)
|
(send {str dstr} :dup)
|
@ -15,7 +15,7 @@ module RuboCop
|
|||||||
#
|
#
|
||||||
class UriDefaultParser < Cop
|
class UriDefaultParser < Cop
|
||||||
MSG = 'Use `%<double_colon>sURI::DEFAULT_PARSER` instead of ' \
|
MSG = 'Use `%<double_colon>sURI::DEFAULT_PARSER` instead of ' \
|
||||||
'`%<double_colon>sURI::Parser.new`.'.freeze
|
'`%<double_colon>sURI::Parser.new`.'
|
||||||
|
|
||||||
def_node_matcher :uri_parser_new?, <<-PATTERN
|
def_node_matcher :uri_parser_new?, <<-PATTERN
|
||||||
(send
|
(send
|
@ -3,7 +3,7 @@
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Performance
|
module Performance
|
||||||
module Version
|
module Version
|
||||||
STRING = '1.2.0'.freeze
|
STRING = '1.3.0'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
x
Reference in New Issue
Block a user