class RuboCop::Cop::Style::RedundantSelfAssignment

def on_lvasgn(node)

rubocop:disable Metrics/AbcSize
def on_lvasgn(node)
  return unless (rhs = node.rhs)
  return unless rhs.type?(:any_block, :call) && method_returning_self?(rhs.method_name)
  return unless (receiver = rhs.receiver)
  receiver_type = ASSIGNMENT_TYPE_TO_RECEIVER_TYPE[node.type]
  return unless receiver.type == receiver_type && receiver.children.first == node.lhs
  message = format(MSG, method_name: rhs.method_name)
  add_offense(node.loc.operator, message: message) do |corrector|
    corrector.replace(node, rhs.source)
  end
end