module RuboCop::Cop::CodeLength
Common functionality for checking length of code segments.
Public Instance Methods
check_code_length(node)
click to toggle source
# File lib/rubocop/cop/mixin/code_length.rb, line 16 def check_code_length(node) length = code_length(node) return unless length > max_length add_offense(node, 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 12 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 26 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 8 def max_length cop_config['Max'] end