Sha256: 047ec1b0ed5ecdd23e9f81193c8a07afc2c59a3ef017adfb5c7f22f921fb5252

Contents?: true

Size: 794 Bytes

Versions: 5

Compression:

Stored size: 794 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    # Common functionality for checking length of code segments.
    module CodeLength
      include ConfigurableMax

      def max_length
        cop_config['Max']
      end

      def count_comments?
        cop_config['CountComments']
      end

      def check(node, *_)
        length = code_length(node)
        if length > max_length
          add_offense(node, :keyword, format(message, length,
                                             max_length)) do
            self.max = length
          end
        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

5 entries across 5 versions & 1 rubygems

Version Path
rubocop-0.21.0 lib/rubocop/cop/mixin/code_length.rb
rubocop-0.20.1 lib/rubocop/cop/mixin/code_length.rb
rubocop-0.20.0 lib/rubocop/cop/mixin/code_length.rb
rubocop-0.19.1 lib/rubocop/cop/mixin/code_length.rb
rubocop-0.19.0 lib/rubocop/cop/mixin/code_length.rb