Class: RuboCop::Cop::Metz::ClassesTooLong
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Metz::ClassesTooLong
- Extended by:
- Metz::CopMetadata
- Includes:
- CodeLength
- Defined in:
- lib/rubocop/cop/metz/classes_too_long.rb
Overview
Flags classes whose body exceeds the configured Max line count.
Wraps the semantics of core's Metrics/ClassLength with a stricter
default of 100 lines.
Constant Summary collapse
- MSG =
"Class has too many lines. [%<length>d/%<max>d]"
Constants included from Metz::CopMetadata
Metz::CopMetadata::DEFAULT_FIX_SAFETY, Metz::CopMetadata::DEFAULT_SUGGESTED_NEXT_MOVES, Metz::CopMetadata::DEFAULT_WHY_IT_MATTERS
Instance Method Summary collapse
Methods included from Metz::CopMetadata
fix_safety, included, metz_metadata, suggested_next_moves, why_it_matters
Instance Method Details
#on_casgn(node) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/rubocop/cop/metz/classes_too_long.rb', line 36 def on_casgn(node) block_node = node.expression || find_expression_within_parent(node.parent) return unless block_node.respond_to?(:class_definition?) && block_node.class_definition? check_code_length(block_node) end |
#on_class(node) ⇒ Object
26 27 28 |
# File 'lib/rubocop/cop/metz/classes_too_long.rb', line 26 def on_class(node) check_code_length(node) end |
#on_sclass(node) ⇒ Object
30 31 32 33 34 |
# File 'lib/rubocop/cop/metz/classes_too_long.rb', line 30 def on_sclass(node) return if node.each_ancestor(:class).any? on_class(node) end |