module RuboCop::Cop::TooManyLines

Common functionality for checking for too many lines.

Constants

MSG

Private Instance Methods

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

  lines.count { |line| !irrelevant_line(line) }
end
extract_body(node) click to toggle source
# File lib/rubocop/cop/mixin/too_many_lines.rb, line 25
def extract_body(node)
  case node.type
  when :block, :def, :defs
    node.body
  else
    node
  end
end
message(length, max_length) click to toggle source
# File lib/rubocop/cop/mixin/too_many_lines.rb, line 14
def message(length, max_length)
  format(MSG, label: cop_label, length: length, max: max_length)
end