module RubbyCop::Cop::CodeLength

Common functionality for checking length of code segments.

Public Instance Methods

check_code_length(node) click to toggle source
# File lib/rubbycop/cop/mixin/code_length.rb, line 17
def check_code_length(node)
  length = code_length(node)
  return unless length > max_length

  add_offense(node, :expression, message(length, max_length)) do
    self.max = length
  end
end
count_comments?() click to toggle source
# File lib/rubbycop/cop/mixin/code_length.rb, line 13
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/rubbycop/cop/mixin/code_length.rb, line 27
def irrelevant_line(source_line)
  source_line.blank? || !count_comments? && comment_line?(source_line)
end
max_length() click to toggle source
# File lib/rubbycop/cop/mixin/code_length.rb, line 9
def max_length
  cop_config['Max']
end