Merge pull request #10750 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-performance-1.10.0
build(deps): bump rubocop-performance from 1.9.2 to 1.10.0 in /Library/Homebrew
This commit is contained in:
commit
37f7b9ee73
@ -77,7 +77,7 @@ GEM
|
|||||||
rack (2.2.3)
|
rack (2.2.3)
|
||||||
rainbow (3.0.0)
|
rainbow (3.0.0)
|
||||||
rdiscount (2.2.0.2)
|
rdiscount (2.2.0.2)
|
||||||
regexp_parser (2.0.3)
|
regexp_parser (2.1.1)
|
||||||
rexml (3.2.4)
|
rexml (3.2.4)
|
||||||
ronn (0.7.3)
|
ronn (0.7.3)
|
||||||
hpricot (>= 0.8.2)
|
hpricot (>= 0.8.2)
|
||||||
@ -119,7 +119,7 @@ GEM
|
|||||||
unicode-display_width (>= 1.4.0, < 3.0)
|
unicode-display_width (>= 1.4.0, < 3.0)
|
||||||
rubocop-ast (1.4.1)
|
rubocop-ast (1.4.1)
|
||||||
parser (>= 2.7.1.5)
|
parser (>= 2.7.1.5)
|
||||||
rubocop-performance (1.9.2)
|
rubocop-performance (1.10.0)
|
||||||
rubocop (>= 0.90.0, < 2.0)
|
rubocop (>= 0.90.0, < 2.0)
|
||||||
rubocop-ast (>= 0.4.0)
|
rubocop-ast (>= 0.4.0)
|
||||||
rubocop-rails (2.9.1)
|
rubocop-rails (2.9.1)
|
||||||
|
|||||||
@ -165,7 +165,7 @@ module Cask
|
|||||||
odebug "Auditing stanzas which require an uninstall"
|
odebug "Auditing stanzas which require an uninstall"
|
||||||
|
|
||||||
return if cask.artifacts.none? { |k| k.is_a?(Artifact::Pkg) || k.is_a?(Artifact::Installer) }
|
return if cask.artifacts.none? { |k| k.is_a?(Artifact::Pkg) || k.is_a?(Artifact::Installer) }
|
||||||
return if cask.artifacts.any? { |k| k.is_a?(Artifact::Uninstall) }
|
return if cask.artifacts.any?(Artifact::Uninstall)
|
||||||
|
|
||||||
add_error "installer and pkg stanzas require an uninstall stanza"
|
add_error "installer and pkg stanzas require an uninstall stanza"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -474,7 +474,7 @@ module Homebrew
|
|||||||
|
|
||||||
"<#{type}>"
|
"<#{type}>"
|
||||||
end.compact
|
end.compact
|
||||||
types << "<subcommand>" if @named_args_type.any? { |type| type.is_a? String }
|
types << "<subcommand>" if @named_args_type.any?(String)
|
||||||
types.join("|")
|
types.join("|")
|
||||||
elsif SYMBOL_TO_USAGE_MAPPING.key? @named_args_type
|
elsif SYMBOL_TO_USAGE_MAPPING.key? @named_args_type
|
||||||
SYMBOL_TO_USAGE_MAPPING[@named_args_type]
|
SYMBOL_TO_USAGE_MAPPING[@named_args_type]
|
||||||
|
|||||||
@ -166,11 +166,11 @@ module Homebrew
|
|||||||
|
|
||||||
requirements = f.recursive_requirements
|
requirements = f.recursive_requirements
|
||||||
if @bottle_tag.to_s.end_with?("_linux")
|
if @bottle_tag.to_s.end_with?("_linux")
|
||||||
if requirements.any? { |r| r.is_a?(MacOSRequirement) }
|
if requirements.any?(MacOSRequirement)
|
||||||
puts "#{Tty.bold}#{Tty.red}#{name}#{Tty.reset}: requires macOS" if any_named_args
|
puts "#{Tty.bold}#{Tty.red}#{name}#{Tty.reset}: requires macOS" if any_named_args
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
elsif requirements.any? { |r| r.is_a?(LinuxRequirement) }
|
elsif requirements.any?(LinuxRequirement)
|
||||||
puts "#{Tty.bold}#{Tty.red}#{name}#{Tty.reset}: requires Linux" if any_named_args
|
puts "#{Tty.bold}#{Tty.red}#{name}#{Tty.reset}: requires Linux" if any_named_args
|
||||||
next
|
next
|
||||||
else
|
else
|
||||||
|
|||||||
@ -1052,7 +1052,7 @@ class CVSDownloadStrategy < VCSDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def split_url(in_url)
|
def split_url(in_url)
|
||||||
parts = in_url.split(/:/)
|
parts = in_url.split(":")
|
||||||
mod = parts.pop
|
mod = parts.pop
|
||||||
url = parts.join(":")
|
url = parts.join(":")
|
||||||
[mod, url]
|
[mod, url]
|
||||||
|
|||||||
@ -84,6 +84,10 @@ class Regexp::Expression::Backreference::Base < ::Regexp::Expression::Base
|
|||||||
def match_length; end
|
def match_length; end
|
||||||
def referenced_expression; end
|
def referenced_expression; end
|
||||||
def referenced_expression=(_arg0); end
|
def referenced_expression=(_arg0); end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def initialize_copy(orig); end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Regexp::Expression::Backreference::Name < ::Regexp::Expression::Backreference::Base
|
class Regexp::Expression::Backreference::Name < ::Regexp::Expression::Backreference::Base
|
||||||
@ -198,7 +202,7 @@ class Regexp::Expression::Base
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def initialize_clone(orig); end
|
def initialize_copy(orig); end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Regexp::Expression::CharacterSet < ::Regexp::Expression::Subexpression
|
class Regexp::Expression::CharacterSet < ::Regexp::Expression::Subexpression
|
||||||
@ -292,6 +296,10 @@ class Regexp::Expression::Conditional::Condition < ::Regexp::Expression::Base
|
|||||||
def reference; end
|
def reference; end
|
||||||
def referenced_expression; end
|
def referenced_expression; end
|
||||||
def referenced_expression=(_arg0); end
|
def referenced_expression=(_arg0); end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def initialize_copy(orig); end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Regexp::Expression::Conditional::Expression < ::Regexp::Expression::Subexpression
|
class Regexp::Expression::Conditional::Expression < ::Regexp::Expression::Subexpression
|
||||||
@ -306,9 +314,13 @@ class Regexp::Expression::Conditional::Expression < ::Regexp::Expression::Subexp
|
|||||||
def referenced_expression; end
|
def referenced_expression; end
|
||||||
def referenced_expression=(_arg0); end
|
def referenced_expression=(_arg0); end
|
||||||
def to_s(format = T.unsafe(nil)); end
|
def to_s(format = T.unsafe(nil)); end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def initialize_copy(orig); end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Regexp::Expression::Conditional::TooManyBranches < ::StandardError
|
class Regexp::Expression::Conditional::TooManyBranches < ::Regexp::Parser::Error
|
||||||
def initialize; end
|
def initialize; end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -431,12 +443,16 @@ class Regexp::Expression::Group::Named < ::Regexp::Expression::Group::Capture
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def initialize_clone(orig); end
|
def initialize_copy(orig); end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Regexp::Expression::Group::Options < ::Regexp::Expression::Group::Base
|
class Regexp::Expression::Group::Options < ::Regexp::Expression::Group::Base
|
||||||
def option_changes; end
|
def option_changes; end
|
||||||
def option_changes=(_arg0); end
|
def option_changes=(_arg0); end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def initialize_copy(orig); end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Regexp::Expression::Group::Passive < ::Regexp::Expression::Group::Base
|
class Regexp::Expression::Group::Passive < ::Regexp::Expression::Group::Base
|
||||||
@ -486,7 +502,7 @@ class Regexp::Expression::Quantifier
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def initialize_clone(orig); end
|
def initialize_copy(orig); end
|
||||||
end
|
end
|
||||||
|
|
||||||
Regexp::Expression::Quantifier::MODES = T.let(T.unsafe(nil), Array)
|
Regexp::Expression::Quantifier::MODES = T.let(T.unsafe(nil), Array)
|
||||||
@ -553,7 +569,7 @@ class Regexp::Expression::Subexpression < ::Regexp::Expression::Base
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def initialize_clone(orig); end
|
def initialize_copy(orig); end
|
||||||
end
|
end
|
||||||
|
|
||||||
module Regexp::Expression::UnicodeProperty
|
module Regexp::Expression::UnicodeProperty
|
||||||
@ -867,7 +883,6 @@ end
|
|||||||
|
|
||||||
class Regexp::Parser
|
class Regexp::Parser
|
||||||
include(::Regexp::Expression)
|
include(::Regexp::Expression)
|
||||||
include(::Regexp::Syntax)
|
|
||||||
include(::Regexp::Expression::UnicodeProperty)
|
include(::Regexp::Expression::UnicodeProperty)
|
||||||
|
|
||||||
def parse(input, syntax = T.unsafe(nil), options: T.unsafe(nil), &block); end
|
def parse(input, syntax = T.unsafe(nil), options: T.unsafe(nil), &block); end
|
||||||
@ -898,6 +913,7 @@ class Regexp::Parser
|
|||||||
def intersection(token); end
|
def intersection(token); end
|
||||||
def interval(target_node, token); end
|
def interval(target_node, token); end
|
||||||
def keep(token); end
|
def keep(token); end
|
||||||
|
def literal(token); end
|
||||||
def meta(token); end
|
def meta(token); end
|
||||||
def negate_set; end
|
def negate_set; end
|
||||||
def nest(exp); end
|
def nest(exp); end
|
||||||
@ -933,11 +949,16 @@ end
|
|||||||
|
|
||||||
Regexp::Parser::ENC_FLAGS = T.let(T.unsafe(nil), Array)
|
Regexp::Parser::ENC_FLAGS = T.let(T.unsafe(nil), Array)
|
||||||
|
|
||||||
|
class Regexp::Parser::Error < ::StandardError
|
||||||
|
end
|
||||||
|
|
||||||
Regexp::Parser::MOD_FLAGS = T.let(T.unsafe(nil), Array)
|
Regexp::Parser::MOD_FLAGS = T.let(T.unsafe(nil), Array)
|
||||||
|
|
||||||
class Regexp::Parser::ParserError < ::StandardError
|
class Regexp::Parser::ParserError < ::Regexp::Parser::Error
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Regexp::Parser::UPTokens = Regexp::Syntax::Token::UnicodeProperty
|
||||||
|
|
||||||
class Regexp::Parser::UnknownTokenError < ::Regexp::Parser::ParserError
|
class Regexp::Parser::UnknownTokenError < ::Regexp::Parser::ParserError
|
||||||
def initialize(type, token); end
|
def initialize(type, token); end
|
||||||
end
|
end
|
||||||
@ -1005,20 +1026,18 @@ class Regexp::Scanner::InvalidSequenceError < ::Regexp::Scanner::ValidationError
|
|||||||
def initialize(what = T.unsafe(nil), where = T.unsafe(nil)); end
|
def initialize(what = T.unsafe(nil), where = T.unsafe(nil)); end
|
||||||
end
|
end
|
||||||
|
|
||||||
Regexp::Scanner::PROP_MAPS_DIR = T.let(T.unsafe(nil), String)
|
|
||||||
|
|
||||||
class Regexp::Scanner::PrematureEndError < ::Regexp::Scanner::ScannerError
|
class Regexp::Scanner::PrematureEndError < ::Regexp::Scanner::ScannerError
|
||||||
def initialize(where = T.unsafe(nil)); end
|
def initialize(where = T.unsafe(nil)); end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Regexp::Scanner::ScannerError < ::StandardError
|
class Regexp::Scanner::ScannerError < ::Regexp::Parser::Error
|
||||||
end
|
end
|
||||||
|
|
||||||
class Regexp::Scanner::UnknownUnicodePropertyError < ::Regexp::Scanner::ValidationError
|
class Regexp::Scanner::UnknownUnicodePropertyError < ::Regexp::Scanner::ValidationError
|
||||||
def initialize(name); end
|
def initialize(name); end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Regexp::Scanner::ValidationError < ::StandardError
|
class Regexp::Scanner::ValidationError < ::Regexp::Parser::Error
|
||||||
def initialize(reason); end
|
def initialize(reason); end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1088,7 +1107,7 @@ class Regexp::Syntax::NotImplementedError < ::Regexp::Syntax::SyntaxError
|
|||||||
def initialize(syntax, type, token); end
|
def initialize(syntax, type, token); end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Regexp::Syntax::SyntaxError < ::StandardError
|
class Regexp::Syntax::SyntaxError < ::Regexp::Parser::Error
|
||||||
end
|
end
|
||||||
|
|
||||||
module Regexp::Syntax::Token
|
module Regexp::Syntax::Token
|
||||||
@ -238,7 +238,7 @@ class RuboCop::Cop::Performance::ConstantRegexp < ::RuboCop::Cop::Base
|
|||||||
private
|
private
|
||||||
|
|
||||||
def include_interpolated_const?(node); end
|
def include_interpolated_const?(node); end
|
||||||
def within_const_assignment?(node); end
|
def within_allowed_assignment?(node); end
|
||||||
end
|
end
|
||||||
|
|
||||||
RuboCop::Cop::Performance::ConstantRegexp::MSG = T.let(T.unsafe(nil), String)
|
RuboCop::Cop::Performance::ConstantRegexp::MSG = T.let(T.unsafe(nil), String)
|
||||||
@ -482,6 +482,25 @@ RuboCop::Cop::Performance::RedundantBlockCall::SPACE = T.let(T.unsafe(nil), Stri
|
|||||||
|
|
||||||
RuboCop::Cop::Performance::RedundantBlockCall::YIELD = T.let(T.unsafe(nil), String)
|
RuboCop::Cop::Performance::RedundantBlockCall::YIELD = T.let(T.unsafe(nil), String)
|
||||||
|
|
||||||
|
class RuboCop::Cop::Performance::RedundantEqualityComparisonBlock < ::RuboCop::Cop::Base
|
||||||
|
extend(::RuboCop::Cop::AutoCorrector)
|
||||||
|
extend(::RuboCop::Cop::TargetRubyVersion)
|
||||||
|
|
||||||
|
def on_block(node); end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def new_argument(block_argument, block_body); end
|
||||||
|
def offense_range(node); end
|
||||||
|
def use_equality_comparison_block?(block_body); end
|
||||||
|
end
|
||||||
|
|
||||||
|
RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::COMPARISON_METHODS = T.let(T.unsafe(nil), Array)
|
||||||
|
|
||||||
|
RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::MSG = T.let(T.unsafe(nil), String)
|
||||||
|
|
||||||
|
RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::TARGET_METHODS = T.let(T.unsafe(nil), Array)
|
||||||
|
|
||||||
class RuboCop::Cop::Performance::RedundantMatch < ::RuboCop::Cop::Base
|
class RuboCop::Cop::Performance::RedundantMatch < ::RuboCop::Cop::Base
|
||||||
extend(::RuboCop::Cop::AutoCorrector)
|
extend(::RuboCop::Cop::AutoCorrector)
|
||||||
|
|
||||||
@ -561,6 +580,27 @@ end
|
|||||||
|
|
||||||
RuboCop::Cop::Performance::RedundantSortBlock::MSG = T.let(T.unsafe(nil), String)
|
RuboCop::Cop::Performance::RedundantSortBlock::MSG = T.let(T.unsafe(nil), String)
|
||||||
|
|
||||||
|
class RuboCop::Cop::Performance::RedundantSplitRegexpArgument < ::RuboCop::Cop::Base
|
||||||
|
extend(::RuboCop::Cop::AutoCorrector)
|
||||||
|
|
||||||
|
def on_send(node); end
|
||||||
|
def split_call_with_regexp?(param0 = T.unsafe(nil)); end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def autocorrect(corrector, node); end
|
||||||
|
def determinist_regexp?(first_argument); end
|
||||||
|
def replacement(node); end
|
||||||
|
end
|
||||||
|
|
||||||
|
RuboCop::Cop::Performance::RedundantSplitRegexpArgument::DETERMINISTIC_REGEX = T.let(T.unsafe(nil), Regexp)
|
||||||
|
|
||||||
|
RuboCop::Cop::Performance::RedundantSplitRegexpArgument::MSG = T.let(T.unsafe(nil), String)
|
||||||
|
|
||||||
|
RuboCop::Cop::Performance::RedundantSplitRegexpArgument::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||||
|
|
||||||
|
RuboCop::Cop::Performance::RedundantSplitRegexpArgument::STR_SPECIAL_CHARS = T.let(T.unsafe(nil), Array)
|
||||||
|
|
||||||
class RuboCop::Cop::Performance::RedundantStringChars < ::RuboCop::Cop::Base
|
class RuboCop::Cop::Performance::RedundantStringChars < ::RuboCop::Cop::Base
|
||||||
include(::RuboCop::Cop::RangeHelp)
|
include(::RuboCop::Cop::RangeHelp)
|
||||||
extend(::RuboCop::Cop::AutoCorrector)
|
extend(::RuboCop::Cop::AutoCorrector)
|
||||||
@ -63,7 +63,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/pry-0.14.0/lib"
|
|||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rack-2.2.3/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rack-2.2.3/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/x86_64-darwin-14/2.6.0-static/rdiscount-2.2.0.2"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/x86_64-darwin-14/2.6.0-static/rdiscount-2.2.0.2"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rdiscount-2.2.0.2/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rdiscount-2.2.0.2/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/regexp_parser-2.0.3/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/regexp_parser-2.1.1/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rexml-3.2.4/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rexml-3.2.4/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ronn-0.7.3/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ronn-0.7.3/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-support-3.10.2/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-support-3.10.2/lib"
|
||||||
@ -82,7 +82,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-ast-1.4.1/lib
|
|||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.11.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.11.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-2.0.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-2.0.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.10.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.10.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.9.2/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.10.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.9.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.9.1/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.2.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.2.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.5.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.5.1/lib"
|
||||||
|
|||||||
@ -10,7 +10,7 @@ Performance/AncestorsInclude:
|
|||||||
Performance/ArraySemiInfiniteRangeSlice:
|
Performance/ArraySemiInfiniteRangeSlice:
|
||||||
Description: 'Identifies places where slicing arrays with semi-infinite ranges can be replaced by `Array#take` and `Array#drop`.'
|
Description: 'Identifies places where slicing arrays with semi-infinite ranges can be replaced by `Array#take` and `Array#drop`.'
|
||||||
# This cop was created due to a mistake in microbenchmark.
|
# This cop was created due to a mistake in microbenchmark.
|
||||||
# Refer https://github.com/rubocop-hq/rubocop-performance/pull/175#issuecomment-731892717
|
# Refer https://github.com/rubocop/rubocop-performance/pull/175#issuecomment-731892717
|
||||||
Enabled: false
|
Enabled: false
|
||||||
# Unsafe for string slices because strings do not have `#take` and `#drop` methods.
|
# Unsafe for string slices because strings do not have `#take` and `#drop` methods.
|
||||||
Safe: false
|
Safe: false
|
||||||
@ -80,6 +80,7 @@ Performance/ConstantRegexp:
|
|||||||
Description: 'Finds regular expressions with dynamic components that are all constants.'
|
Description: 'Finds regular expressions with dynamic components that are all constants.'
|
||||||
Enabled: pending
|
Enabled: pending
|
||||||
VersionAdded: '1.9'
|
VersionAdded: '1.9'
|
||||||
|
VersionChanged: '1.10'
|
||||||
|
|
||||||
Performance/Count:
|
Performance/Count:
|
||||||
Description: >-
|
Description: >-
|
||||||
@ -136,11 +137,10 @@ Performance/EndWith:
|
|||||||
# object. Switching these methods has to be done with knowledge of the types
|
# object. Switching these methods has to be done with knowledge of the types
|
||||||
# of the variables which rubocop doesn't have.
|
# of the variables which rubocop doesn't have.
|
||||||
SafeAutoCorrect: false
|
SafeAutoCorrect: false
|
||||||
AutoCorrect: false
|
|
||||||
Enabled: true
|
Enabled: true
|
||||||
SafeMultiline: true
|
SafeMultiline: true
|
||||||
VersionAdded: '0.36'
|
VersionAdded: '0.36'
|
||||||
VersionChanged: '1.6'
|
VersionChanged: '1.10'
|
||||||
|
|
||||||
Performance/FixedSize:
|
Performance/FixedSize:
|
||||||
Description: 'Do not compute the size of statically sized objects except in constants.'
|
Description: 'Do not compute the size of statically sized objects except in constants.'
|
||||||
@ -200,6 +200,15 @@ Performance/RedundantBlockCall:
|
|||||||
Enabled: true
|
Enabled: true
|
||||||
VersionAdded: '0.36'
|
VersionAdded: '0.36'
|
||||||
|
|
||||||
|
Performance/RedundantEqualityComparisonBlock:
|
||||||
|
Description: >-
|
||||||
|
Checks for uses `Enumerable#all?`, `Enumerable#any?`, `Enumerable#one?`,
|
||||||
|
or `Enumerable#none?` are compared with `===` or similar methods in block.
|
||||||
|
Reference: 'https://github.com/rails/rails/pull/41363'
|
||||||
|
Enabled: pending
|
||||||
|
Safe: false
|
||||||
|
VersionAdded: '1.10'
|
||||||
|
|
||||||
Performance/RedundantMatch:
|
Performance/RedundantMatch:
|
||||||
Description: >-
|
Description: >-
|
||||||
Use `=~` instead of `String#match` or `Regexp#match` in a context where the
|
Use `=~` instead of `String#match` or `Regexp#match` in a context where the
|
||||||
@ -220,6 +229,11 @@ Performance/RedundantSortBlock:
|
|||||||
Enabled: 'pending'
|
Enabled: 'pending'
|
||||||
VersionAdded: '1.7'
|
VersionAdded: '1.7'
|
||||||
|
|
||||||
|
Performance/RedundantSplitRegexpArgument:
|
||||||
|
Description: 'This cop identifies places where `split` argument can be replaced from a deterministic regexp to a string.'
|
||||||
|
Enabled: pending
|
||||||
|
VersionAdded: '1.10'
|
||||||
|
|
||||||
Performance/RedundantStringChars:
|
Performance/RedundantStringChars:
|
||||||
Description: 'Checks for redundant `String#chars`.'
|
Description: 'Checks for redundant `String#chars`.'
|
||||||
Enabled: 'pending'
|
Enabled: 'pending'
|
||||||
@ -270,11 +284,10 @@ Performance/StartWith:
|
|||||||
# object. Switching these methods has to be done with knowledge of the types
|
# object. Switching these methods has to be done with knowledge of the types
|
||||||
# of the variables which rubocop doesn't have.
|
# of the variables which rubocop doesn't have.
|
||||||
SafeAutoCorrect: false
|
SafeAutoCorrect: false
|
||||||
AutoCorrect: false
|
|
||||||
Enabled: true
|
Enabled: true
|
||||||
SafeMultiline: true
|
SafeMultiline: true
|
||||||
VersionAdded: '0.36'
|
VersionAdded: '0.36'
|
||||||
VersionChanged: '1.6'
|
VersionChanged: '1.10'
|
||||||
|
|
||||||
Performance/StringInclude:
|
Performance/StringInclude:
|
||||||
Description: 'Use `String#include?` instead of a regex match with literal-only pattern.'
|
Description: 'Use `String#include?` instead of a regex match with literal-only pattern.'
|
||||||
@ -304,7 +317,7 @@ Performance/TimesMap:
|
|||||||
Enabled: true
|
Enabled: true
|
||||||
VersionAdded: '0.36'
|
VersionAdded: '0.36'
|
||||||
VersionChanged: '0.50'
|
VersionChanged: '0.50'
|
||||||
SafeAutoCorrect: false # see https://github.com/rubocop-hq/rubocop/issues/4658
|
SafeAutoCorrect: false # see https://github.com/rubocop/rubocop/issues/4658
|
||||||
|
|
||||||
Performance/UnfreezeString:
|
Performance/UnfreezeString:
|
||||||
Description: 'Use unary plus to get an unfrozen string literal.'
|
Description: 'Use unary plus to get an unfrozen string literal.'
|
||||||
@ -6,7 +6,7 @@ module RuboCop
|
|||||||
# This cop identifies places where slicing arrays with semi-infinite ranges
|
# This cop identifies places where slicing arrays with semi-infinite ranges
|
||||||
# can be replaced by `Array#take` and `Array#drop`.
|
# can be replaced by `Array#take` and `Array#drop`.
|
||||||
# This cop was created due to a mistake in microbenchmark and hence is disabled by default.
|
# This cop was created due to a mistake in microbenchmark and hence is disabled by default.
|
||||||
# Refer https://github.com/rubocop-hq/rubocop-performance/pull/175#issuecomment-731892717
|
# Refer https://github.com/rubocop/rubocop-performance/pull/175#issuecomment-731892717
|
||||||
# This cop is also unsafe for string slices because strings do not have `#take` and `#drop` methods.
|
# This cop is also unsafe for string slices because strings do not have `#take` and `#drop` methods.
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
@ -33,7 +33,7 @@ module RuboCop
|
|||||||
def_node_matcher :bind_with_call_method?, <<~PATTERN
|
def_node_matcher :bind_with_call_method?, <<~PATTERN
|
||||||
(send
|
(send
|
||||||
$(send
|
$(send
|
||||||
(send nil? _) :bind
|
_ :bind
|
||||||
$(...)) :call
|
$(...)) :call
|
||||||
$...)
|
$...)
|
||||||
PATTERN
|
PATTERN
|
||||||
@ -64,7 +64,7 @@ module RuboCop
|
|||||||
|
|
||||||
def correction_range(receiver, node)
|
def correction_range(receiver, node)
|
||||||
location_of_bind = receiver.loc.selector.begin_pos
|
location_of_bind = receiver.loc.selector.begin_pos
|
||||||
location_of_call = node.loc.end.end_pos
|
location_of_call = node.source_range.end.end_pos
|
||||||
|
|
||||||
range_between(location_of_bind, location_of_call)
|
range_between(location_of_bind, location_of_call)
|
||||||
end
|
end
|
||||||
@ -6,9 +6,9 @@ module RuboCop
|
|||||||
# This cop finds regular expressions with dynamic components that are all constants.
|
# This cop finds regular expressions with dynamic components that are all constants.
|
||||||
#
|
#
|
||||||
# Ruby allocates a new Regexp object every time it executes a code containing such
|
# Ruby allocates a new Regexp object every time it executes a code containing such
|
||||||
# a regular expression. It is more efficient to extract it into a constant
|
# a regular expression. It is more efficient to extract it into a constant,
|
||||||
# or add an `/o` option to perform `#{}` interpolation only once and reuse that
|
# memoize it, or add an `/o` option to perform `#{}` interpolation only once and
|
||||||
# Regexp object.
|
# reuse that Regexp object.
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
#
|
#
|
||||||
@ -28,13 +28,18 @@ module RuboCop
|
|||||||
# pattern.scan(TOKEN).reject { |token| token.match?(/\A#{SEPARATORS}\Z/o) }
|
# pattern.scan(TOKEN).reject { |token| token.match?(/\A#{SEPARATORS}\Z/o) }
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
|
# # good
|
||||||
|
# def separators
|
||||||
|
# @separators ||= /\A#{SEPARATORS}\Z/
|
||||||
|
# end
|
||||||
|
#
|
||||||
class ConstantRegexp < Base
|
class ConstantRegexp < Base
|
||||||
extend AutoCorrector
|
extend AutoCorrector
|
||||||
|
|
||||||
MSG = 'Extract this regexp into a constant or append an `/o` option to its options.'
|
MSG = 'Extract this regexp into a constant, memoize it, or append an `/o` option to its options.'
|
||||||
|
|
||||||
def on_regexp(node)
|
def on_regexp(node)
|
||||||
return if within_const_assignment?(node) ||
|
return if within_allowed_assignment?(node) ||
|
||||||
!include_interpolated_const?(node) ||
|
!include_interpolated_const?(node) ||
|
||||||
node.single_interpolation?
|
node.single_interpolation?
|
||||||
|
|
||||||
@ -45,8 +50,8 @@ module RuboCop
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def within_const_assignment?(node)
|
def within_allowed_assignment?(node)
|
||||||
node.each_ancestor(:casgn).any?
|
node.each_ancestor(:casgn, :or_asgn).any?
|
||||||
end
|
end
|
||||||
|
|
||||||
def_node_matcher :regexp_escape?, <<~PATTERN
|
def_node_matcher :regexp_escape?, <<~PATTERN
|
||||||
@ -0,0 +1,72 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module RuboCop
|
||||||
|
module Cop
|
||||||
|
module Performance
|
||||||
|
# This cop checks for uses `Enumerable#all?`, `Enumerable#any?`, `Enumerable#one?`,
|
||||||
|
# and `Enumerable#none?` are compared with `===` or similar methods in block.
|
||||||
|
#
|
||||||
|
# By default, `Object#===` behaves the same as `Object#==`, but this
|
||||||
|
# behavior is appropriately overridden in subclass. For example,
|
||||||
|
# `Range#===` returns `true` when argument is within the range.
|
||||||
|
# Therefore, It is marked as unsafe by default because `===` and `==`
|
||||||
|
# do not always behave the same.
|
||||||
|
#
|
||||||
|
# @example
|
||||||
|
# # bad
|
||||||
|
# items.all? { |item| pattern === item }
|
||||||
|
# items.all? { |item| item == other }
|
||||||
|
# items.all? { |item| item.is_a?(Klass) }
|
||||||
|
# items.all? { |item| item.kind_of?(Klass) }
|
||||||
|
#
|
||||||
|
# # good
|
||||||
|
# items.all?(pattern)
|
||||||
|
#
|
||||||
|
class RedundantEqualityComparisonBlock < Base
|
||||||
|
extend AutoCorrector
|
||||||
|
extend TargetRubyVersion
|
||||||
|
|
||||||
|
minimum_target_ruby_version 2.5
|
||||||
|
|
||||||
|
MSG = 'Use `%<prefer>s` instead of block.'
|
||||||
|
|
||||||
|
TARGET_METHODS = %i[all? any? one? none?].freeze
|
||||||
|
COMPARISON_METHODS = %i[== === is_a? kind_of?].freeze
|
||||||
|
|
||||||
|
def on_block(node)
|
||||||
|
return unless TARGET_METHODS.include?(node.method_name)
|
||||||
|
|
||||||
|
block_argument = node.arguments.first
|
||||||
|
block_body = node.body
|
||||||
|
return unless use_equality_comparison_block?(block_body)
|
||||||
|
return unless (new_argument = new_argument(block_argument, block_body))
|
||||||
|
|
||||||
|
range = offense_range(node)
|
||||||
|
prefer = "#{node.method_name}(#{new_argument})"
|
||||||
|
|
||||||
|
add_offense(range, message: format(MSG, prefer: prefer)) do |corrector|
|
||||||
|
corrector.replace(range, prefer)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def use_equality_comparison_block?(block_body)
|
||||||
|
block_body.send_type? && COMPARISON_METHODS.include?(block_body.method_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def new_argument(block_argument, block_body)
|
||||||
|
if block_argument.source == block_body.receiver.source
|
||||||
|
block_body.first_argument.source
|
||||||
|
elsif block_argument.source == block_body.first_argument.source
|
||||||
|
block_body.receiver.source
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def offense_range(node)
|
||||||
|
node.send_node.loc.selector.join(node.source_range.end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module RuboCop
|
||||||
|
module Cop
|
||||||
|
module Performance
|
||||||
|
# This cop identifies places where `split` argument can be replaced from
|
||||||
|
# a deterministic regexp to a string.
|
||||||
|
#
|
||||||
|
# @example
|
||||||
|
# # bad
|
||||||
|
# 'a,b,c'.split(/,/)
|
||||||
|
#
|
||||||
|
# # good
|
||||||
|
# 'a,b,c'.split(',')
|
||||||
|
class RedundantSplitRegexpArgument < Base
|
||||||
|
extend AutoCorrector
|
||||||
|
|
||||||
|
MSG = 'Use string as argument instead of regexp.'
|
||||||
|
RESTRICT_ON_SEND = %i[split].freeze
|
||||||
|
DETERMINISTIC_REGEX = /\A(?:#{LITERAL_REGEX})+\Z/.freeze
|
||||||
|
STR_SPECIAL_CHARS = %w[\n \" \' \\\\ \t \b \f \r].freeze
|
||||||
|
|
||||||
|
def_node_matcher :split_call_with_regexp?, <<~PATTERN
|
||||||
|
{(send !nil? :split {regexp})}
|
||||||
|
PATTERN
|
||||||
|
|
||||||
|
def on_send(node)
|
||||||
|
return unless split_call_with_regexp?(node)
|
||||||
|
return unless determinist_regexp?(node.first_argument)
|
||||||
|
|
||||||
|
add_offense(node.first_argument) do |corrector|
|
||||||
|
autocorrect(corrector, node)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def determinist_regexp?(first_argument)
|
||||||
|
DETERMINISTIC_REGEX.match?(first_argument.source)
|
||||||
|
end
|
||||||
|
|
||||||
|
def autocorrect(corrector, node)
|
||||||
|
new_argument = replacement(node)
|
||||||
|
|
||||||
|
corrector.replace(node.first_argument, "\"#{new_argument}\"")
|
||||||
|
end
|
||||||
|
|
||||||
|
def replacement(node)
|
||||||
|
regexp_content = node.first_argument.content
|
||||||
|
stack = []
|
||||||
|
chars = regexp_content.chars.each_with_object([]) do |char, strings|
|
||||||
|
if stack.empty? && char == '\\'
|
||||||
|
stack.push(char)
|
||||||
|
else
|
||||||
|
strings << "#{stack.pop}#{char}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
chars.map do |char|
|
||||||
|
char = char.dup
|
||||||
|
char.delete!('\\') unless STR_SPECIAL_CHARS.include?(char)
|
||||||
|
char
|
||||||
|
end.join
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -150,7 +150,9 @@ module RuboCop
|
|||||||
replacement = build_good_method(init, block_pass)
|
replacement = build_good_method(init, block_pass)
|
||||||
|
|
||||||
corrector.remove(sum_range)
|
corrector.remove(sum_range)
|
||||||
corrector.replace(map_range, ".#{replacement}")
|
|
||||||
|
dot = '.' if map.receiver
|
||||||
|
corrector.replace(map_range, "#{dot}#{replacement}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def sum_method_range(node)
|
def sum_method_range(node)
|
||||||
@ -228,7 +230,11 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
|
|
||||||
def method_call_with_args_range(node)
|
def method_call_with_args_range(node)
|
||||||
node.receiver.source_range.end.join(node.source_range.end)
|
if (receiver = node.receiver)
|
||||||
|
receiver.source_range.end.join(node.source_range.end)
|
||||||
|
else
|
||||||
|
node.source_range
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -28,9 +28,11 @@ require_relative 'performance/open_struct'
|
|||||||
require_relative 'performance/range_include'
|
require_relative 'performance/range_include'
|
||||||
require_relative 'performance/io_readlines'
|
require_relative 'performance/io_readlines'
|
||||||
require_relative 'performance/redundant_block_call'
|
require_relative 'performance/redundant_block_call'
|
||||||
|
require_relative 'performance/redundant_equality_comparison_block'
|
||||||
require_relative 'performance/redundant_match'
|
require_relative 'performance/redundant_match'
|
||||||
require_relative 'performance/redundant_merge'
|
require_relative 'performance/redundant_merge'
|
||||||
require_relative 'performance/redundant_sort_block'
|
require_relative 'performance/redundant_sort_block'
|
||||||
|
require_relative 'performance/redundant_split_regexp_argument'
|
||||||
require_relative 'performance/redundant_string_chars'
|
require_relative 'performance/redundant_string_chars'
|
||||||
require_relative 'performance/regexp_match'
|
require_relative 'performance/regexp_match'
|
||||||
require_relative 'performance/reverse_each'
|
require_relative 'performance/reverse_each'
|
||||||
@ -4,7 +4,7 @@ module RuboCop
|
|||||||
module Performance
|
module Performance
|
||||||
# This module holds the RuboCop Performance version information.
|
# This module holds the RuboCop Performance version information.
|
||||||
module Version
|
module Version
|
||||||
STRING = '1.9.2'
|
STRING = '1.10.0'
|
||||||
|
|
||||||
def self.document_version
|
def self.document_version
|
||||||
STRING.match('\d+\.\d+').to_s
|
STRING.match('\d+\.\d+').to_s
|
||||||
Loading…
x
Reference in New Issue
Block a user