class RuboCop::Cop::Metrics::MethodLength

The maximum allowed length is configurable.
Comment lines can optionally be ignored.
This cop checks if the length of a method exceeds some maximum value.

def code_length(node)

def code_length(node)
  lines = node.source.lines.to_a[1..-2] || []
  lines.count { |line| !irrelevant_line(line) }
end

def message(length, max_length)

def message(length, max_length)
  format('Method has too many lines. [%d/%d]', length, max_length)
end

def on_method_def(node, _method_name, _args, _body)

def on_method_def(node, _method_name, _args, _body)
  check_code_length(node)
end