Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump rubocop-performance from 1.13.2 to 1.13.3 in /Library/Homebrew #12971

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Library/Homebrew/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ GEM
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.16.0)
parser (>= 3.1.1.0)
rubocop-performance (1.13.2)
rubocop-performance (1.13.3)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.13.2)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Library/Homebrew/vendor/bundle/bundler/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
$:.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/rubocop-1.25.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.13.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.13.3/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.13.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.9.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.7/lib"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
module RuboCop
module Cop
module Performance
# This cop is used to identify usages of
# This cop is used to identify usages of `array.compact.flatten.map { |x| x.downcase }`.
# Each of these methods (`compact`, `flatten`, `map`) will generate a new intermediate array
# that is promptly thrown away. Instead it is faster to mutate when we know it's safe.
#
# @example
# # bad
# array = ["a", "b", "c"]
# array.compact.flatten.map { |x| x.downcase }
#
# Each of these methods (`compact`, `flatten`, `map`) will generate a
# new intermediate array that is promptly thrown away. Instead it is
# faster to mutate when we know it's safe.
#
# @example
# # good.
# # good
# array = ["a", "b", "c"]
# array.compact!
# array.flatten!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ def on_send(node)

add_offense(range) do |corrector|
corrector.replace(map_node.loc.selector, 'filter_map')
remove_compact_method(corrector, node, node.parent)
remove_compact_method(corrector, map_node, node, node.parent)
end
end

private

def remove_compact_method(corrector, compact_node, chained_method)
def remove_compact_method(corrector, map_node, compact_node, chained_method)
compact_method_range = compact_node.loc.selector

if compact_node.multiline? && chained_method&.loc.respond_to?(:selector) && chained_method.dot? &&
!map_method_and_compact_method_on_same_line?(compact_node) &&
!map_method_and_compact_method_on_same_line?(map_node, compact_node) &&
!invoke_method_after_map_compact_on_same_line?(compact_node, chained_method)
compact_method_range = compact_method_with_final_newline_range(compact_method_range)
else
Expand All @@ -78,11 +78,7 @@ def remove_compact_method(corrector, compact_node, chained_method)
corrector.remove(compact_method_range)
end

def map_method_and_compact_method_on_same_line?(compact_node)
return false unless compact_node.children.first.respond_to?(:send_node)

map_node = compact_node.children.first.send_node

def map_method_and_compact_method_on_same_line?(map_node, compact_node)
compact_node.loc.selector.line == map_node.loc.selector.line
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module RuboCop
module Performance
# This module holds the RuboCop Performance version information.
module Version
STRING = '1.13.2'
STRING = '1.13.3'

def self.document_version
STRING.match('\d+\.\d+').to_s
Expand Down