module RuboCop::Cop::CommentsHelp

def find_end_line(node)

rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity, Lint/DuplicateBranch
the line at which the parent node ends.
End line is considered either the line at which another node starts, or
Returns the end line of a node, which might be a comment and not part of the AST
def find_end_line(node)
  if node.if_type? && node.else?
    node.loc.else.line
  elsif node.if_type? && node.ternary?
    node.else_branch.loc.line
  elsif node.if_type? && node.elsif?
    node.each_ancestor(:if).find(&:if?).loc.end.line
  elsif node.block_type? || node.numblock_type?
    node.loc.end.line
  elsif (next_sibling = node.right_sibling) && next_sibling.is_a?(AST::Node)
    next_sibling.loc.line
  elsif (parent = node.parent)
    parent.loc.respond_to?(:end) && parent.loc.end ? parent.loc.end.line : parent.loc.line
  else
    node.loc.end.line
  end
end