lib/rubocop/cop/performance/compare_with_block.rb in rubocop-0.49.1 vs lib/rubocop/cop/performance/compare_with_block.rb in rubocop-0.50.0

- old
+ new

@@ -25,22 +25,22 @@ # array.sort_by { |a| a[:foo] } class CompareWithBlock < Cop MSG = 'Use `%s_by%s` instead of ' \ '`%s { |%s, %s| %s <=> %s }`.'.freeze - def_node_matcher :compare?, <<-END + def_node_matcher :compare?, <<-PATTERN (block $(send _ {:sort :min :max}) (args (arg $_a) (arg $_b)) $send) - END + PATTERN - def_node_matcher :replaceable_body?, <<-END + def_node_matcher :replaceable_body?, <<-PATTERN (send (send (lvar %1) $_method $...) :<=> (send (lvar %2) _method $...)) - END + PATTERN def on_block(node) compare?(node) do |send, var_a, var_b, body| replaceable_body?(body, var_a, var_b) do |method, args_a, args_b| return unless slow_compare?(method, args_a, args_b)