Sha256: f152e5369d1ce8c6795798aa58810e51a334e1640c221ffb77dd6e5db899f9df
Contents?: true
Size: 963 Bytes
Versions: 4
Compression:
Stored size: 963 Bytes
Contents
# frozen_string_literal: true module RuboCop module Cop # Common functionality for checking length of code segments. module CodeLength include ConfigurableMax private def max_length cop_config['Max'] end def count_comments? cop_config['CountComments'] end def count_as_one Array(cop_config['CountAsOne']).map(&:to_sym) end 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 # Returns true for lines that shall not be included in the count. def irrelevant_line(source_line) source_line.blank? || !count_comments? && comment_line?(source_line) end end end end
Version data entries
4 entries across 4 versions & 2 rubygems