class RuboCop::Cop::Style::NonNilCheck

def on_method_def(_node, name, _args, body)

def on_method_def(_node, name, _args, body)
  # only predicate methods are handled differently
  return unless name.to_s.end_with?('?') && body
  if body.begin_type?
    ignore_node(body.children.last)
  else
    ignore_node(body)
  end
end