module RuboCop::Cop::CodeLength
Common functionality for checking length of code segments.
Private Instance Methods
check_code_length(node)
click to toggle source
# File lib/rubocop/cop/mixin/code_length.rb, line 19 def check_code_length(node) length = code_length(node) return unless length > max_length location = node.casgn_type? ? :name : :expression add_offense(node, location: location, message: message(length, max_length)) do self.max = length end end
count_comments?()
click to toggle source
# File lib/rubocop/cop/mixin/code_length.rb, line 15 def count_comments? cop_config['CountComments'] end
irrelevant_line(source_line)
click to toggle source
Returns true for lines that shall not be included in the count.
# File lib/rubocop/cop/mixin/code_length.rb, line 33 def irrelevant_line(source_line) source_line.blank? || !count_comments? && comment_line?(source_line) end
max_length()
click to toggle source
# File lib/rubocop/cop/mixin/code_length.rb, line 11 def max_length cop_config['Max'] end