class RuboCop::Cop::Metrics::ClassLength

NOTE: This cop also applies for ‘Struct` definitions.
end # 6 points
)
2
1,
foo( # +1
HEREDOC
content.
Heredoc
MSG = <<~HEREDOC # +1
}
key: ’value’
HASH = { # +3
]
2
1,
ARRAY = [ # +1
class Foo
@example CountAsOne: [‘array’, ‘heredoc’, ‘method_call’]
will be counted as one line regardless of its actual size.
Available are: ‘array’, ‘hash’, ‘heredoc’, and ‘method_call’. Each construct
You can set constructs you want to fold with ‘CountAsOne`.
The maximum allowed length is configurable.
Comment lines can optionally be ignored.
Checks if the length of a class exceeds some maximum value.

def message(length, max_length)

def message(length, max_length)
  format('Class has too many lines. [%<length>d/%<max>d]', length: length, max: max_length)
end

def on_casgn(node)

def on_casgn(node)
  parent = node.parent
  if parent&.assignment?
    block_node = parent.children[1]
  elsif parent&.parent&.masgn_type?
    block_node = parent.parent.children[1]
  else
    _scope, _name, block_node = *node
  end
  return unless block_node.respond_to?(:class_definition?) && block_node.class_definition?
  check_code_length(block_node)
end

def on_class(node)

def on_class(node)
  check_code_length(node)
end