Class: Simplabs::Excellent::Checks::ClassLineCountCheck
- Inherits:
-
LineCountCheck
- Object
- Base
- LineCountCheck
- Simplabs::Excellent::Checks::ClassLineCountCheck
- Defined in:
- lib/simplabs/excellent/checks/class_line_count_check.rb
Overview
This check reports classes which have more lines than the threshold. Classes with a large number of lines are hard to read and understand and often an indicator for badly designed code as well.
Applies to
-
classes
Constant Summary collapse
- DEFAULT_THRESHOLD =
300
Instance Attribute Summary
Attributes inherited from Base
#interesting_contexts, #interesting_files, #options, #warnings
Instance Method Summary collapse
- #evaluate(context) ⇒ Object
-
#initialize(options = {}) ⇒ ClassLineCountCheck
constructor
:nodoc:.
Methods inherited from Base
#add_warning, #evaluate_context, #warnings_for
Constructor Details
#initialize(options = {}) ⇒ ClassLineCountCheck
:nodoc:
19 20 21 22 |
# File 'lib/simplabs/excellent/checks/class_line_count_check.rb', line 19 def initialize( = {}) #:nodoc: [:threshold] ||= DEFAULT_THRESHOLD super([Parsing::ClassContext], ) end |
Instance Method Details
#evaluate(context) ⇒ Object
24 25 26 27 |
# File 'lib/simplabs/excellent/checks/class_line_count_check.rb', line 24 def evaluate(context) line_count = context.line_count == 1 ? 1 : context.line_count + 1 add_warning(*warning_args(context, line_count)) unless line_count <= @threshold end |