class RuboCop::Cop::Performance::CompareWithBlock
def on_block(node)
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) range = compare_range(send, node) add_offense(range, message: message(send, method, var_a, var_b, args_a)) do |corrector| replacement = if method == :[] "#{REPLACEMENT[send.method_name]} { |a| a[#{args_a.first.source}] }" else "#{REPLACEMENT[send.method_name]}(&:#{method})" end corrector.replace(range, replacement) end end end end