Merge pull request #6335 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-performance-1.4.1

build: bump rubocop-performance from 1.4.0 to 1.4.1 in /Library/Homebrew
This commit is contained in:
Mike McQuaid 2019-07-29 10:50:42 +01:00 committed by GitHub
commit 3dab11263c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 31 additions and 22 deletions

View File

@ -87,7 +87,7 @@ GEM
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7)
rubocop-performance (1.4.0)
rubocop-performance (1.4.1)
rubocop (>= 0.71.0)
rubocop-rspec (1.34.0)
rubocop (>= 0.60.0)

View File

@ -35,7 +35,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/jaro_winkler-1.5.3/li
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/mime-types-data-3.2019.0331/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/mime-types-3.2.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/net-http-digest_auth-1.4.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/net-http-persistent-3.0.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/net-http-persistent-3.1.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/mini_portile2-2.4.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/universal-darwin-18/2.3.0/nokogiri-1.10.3"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/nokogiri-1.10.3/lib"
@ -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.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-1.6.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-0.73.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.4.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.4.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-1.34.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"

View File

@ -132,7 +132,7 @@ module RuboCop
end
def max_key_value_pairs
Integer(cop_config['MaxKeyValuePairs'])
Integer(cop_config['MaxKeyValuePairs']) || 2
end
# A utility class for checking the use of values within an

View File

@ -177,25 +177,42 @@ module RuboCop
scope_root = scope_root(match_node)
body = scope_root ? scope_body(scope_root) : match_node.ancestors.last
return true if match_node.parent.if_type? &&
match_node.parent.modifier_form?
match_node_pos = match_node.loc.expression.begin_pos
next_match_pos = next_match_pos(body, match_node_pos, scope_root)
range = match_node_pos..next_match_pos
range = range_to_search_for_last_matches(match_node, body, scope_root)
find_last_match(body, range, scope_root)
end
def range_to_search_for_last_matches(match_node, body, scope_root)
expression = if modifier_form?(match_node)
match_node.parent.if_branch.loc.expression
else
match_node.loc.expression
end
match_node_pos = expression.begin_pos
next_match_pos = next_match_pos(body, match_node_pos, scope_root)
match_node_pos..next_match_pos
end
def next_match_pos(body, match_node_pos, scope_root)
node = search_match_nodes(body).find do |match|
match.loc.expression.begin_pos > match_node_pos &&
scope_root(match) == scope_root
begin_pos = if modifier_form?(match)
match.parent.if_branch.loc.expression.begin_pos
else
match.loc.expression.begin_pos
end
begin_pos > match_node_pos && scope_root(match) == scope_root
end
node ? node.loc.expression.begin_pos : Float::INFINITY
end
def modifier_form?(match_node)
match_node.parent.if_type? && match_node.parent.modifier_form?
end
def find_last_match(body, range, scope_root)
last_matches(body).find do |ref|
ref_pos = ref.loc.expression.begin_pos

View File

@ -1,13 +1,5 @@
# frozen_string_literal: true
module RuboCop
# RuboCop included the performance cops directly before version 1.0.0.
# We can remove them to avoid warnings about redefining constants.
module Cop
remove_const('Performance') if const_defined?('Performance')
end
end
require_relative 'performance/caller'
require_relative 'performance/case_when_splat'
require_relative 'performance/casecmp'