module RubbyCop::Cop::TooManyLines

Common functionality for checking for too many lines.

Constants

MSG

Private Instance Methods

code_length(node) click to toggle source
# File lib/rubbycop/cop/mixin/too_many_lines.rb, line 18
def code_length(node)
  body = extract_body(node)
  lines = body && body.source.lines || []

  lines.count { |line| !irrelevant_line(line) }
end
extract_body(node) click to toggle source
# File lib/rubbycop/cop/mixin/too_many_lines.rb, line 25
def extract_body(node)
  case node.type
  when :block, :def
    _receiver_or_method, _args, body = *node
  when :defs
    _self, _method, _args, body = *node
  else
    body = node
  end

  body
end
message(length, max_length) click to toggle source
# File lib/rubbycop/cop/mixin/too_many_lines.rb, line 14
def message(length, max_length)
  format(MSG, cop_label, length, max_length)
end