Class: Roodi::Checks::MethodLineCountCheck

Inherits:
LineCountCheck show all
Defined in:
lib/roodi/checks/method_line_count_check.rb

Overview

Checks a method to make sure the number of lines it has is under the specified limit.

A method getting too large is a code smell that indicates it might be doing more than one thing and becoming hard to test. It should probably be refactored into multiple methods that each do a single thing well.

Constant Summary collapse

DEFAULT_LINE_COUNT =
20

Constants inherited from Check

Check::NODE_TYPES

Instance Attribute Summary

Attributes inherited from LineCountCheck

#line_count

Instance Method Summary collapse

Methods inherited from LineCountCheck

#evaluate_start

Methods inherited from Check

#add_error, #end_file, #errors, #evaluate_end, #evaluate_node, #evaluate_node_end, #evaluate_node_start, #evaluate_start, make, #position, #start_file

Constructor Details

#initializeMethodLineCountCheck

Returns a new instance of MethodLineCountCheck.



14
15
16
17
# File 'lib/roodi/checks/method_line_count_check.rb', line 14

def initialize
  super()
  self.line_count = DEFAULT_LINE_COUNT
end

Instance Method Details

#interesting_nodesObject



19
20
21
# File 'lib/roodi/checks/method_line_count_check.rb', line 19

def interesting_nodes
  [:defn]
end

#message_prefixObject



23
24
25
# File 'lib/roodi/checks/method_line_count_check.rb', line 23

def message_prefix
  'Method'
end