class RuboCop::Cop::Layout::EmptyLineAfterMagicComment

def last_magic_comment(source)

Returns:
  • (nil) - otherwise
  • (Parser::Source::Comment) - if magic comments exist before code
def last_magic_comment(source)
  comments_before_code(source)
    .reverse
    .find { |comment| MagicComment.parse(comment.text).any? }
end