class Rubocop::Cop::Style::SingleLineMethods
It can optionally accept single-line methods with no body.
This cop checks for single-line method definitions.
def allow_empty?
def allow_empty? cop_config['AllowIfMethodIsEmpty'] end
def check(node)
def check(node) start_line = node.loc.keyword.line end_line = node.loc.end.line if node.type == :def empty_body = node.children[2].nil? else empty_body = node.children[3].nil? end if start_line == end_line && !(allow_empty? && empty_body) convention(node, :expression) end end
def on_def(node)
def on_def(node) check(node) end
def on_defs(node)
def on_defs(node) check(node) end