class RuboCop::Cop::Performance::Sum

def on_block(node)

def on_block(node)
  sum_with_block_candidate?(node) do |send, init, var_acc, var_elem, body|
    if acc_plus_elem?(body, var_acc, var_elem) || elem_plus_acc?(body, var_elem, var_acc)
      range = sum_block_range(send, node)
      message = build_block_message(send, init, var_acc, var_elem, body)
      add_offense(range, message: message) do |corrector|
        autocorrect(corrector, init, range)
      end
    end
  end
end