Sha256: 86b17e57c60da3f1e03ce84024c54c513b122cd665fe90d3da4d97c04eb6691d

Contents?: true

Size: 769 Bytes

Versions: 14

Compression:

Stored size: 769 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 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

      # 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

14 entries across 14 versions & 2 rubygems

Version Path
rubocop-0.59.1 lib/rubocop/cop/mixin/code_length.rb
rubocop-0.59.0 lib/rubocop/cop/mixin/code_length.rb
rubocop-0.58.2 lib/rubocop/cop/mixin/code_length.rb
rubocop-0.58.1 lib/rubocop/cop/mixin/code_length.rb
rubocop-0.58.0 lib/rubocop/cop/mixin/code_length.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/rubocop-0.57.2/lib/rubocop/cop/mixin/code_length.rb
rubocop-0.57.2 lib/rubocop/cop/mixin/code_length.rb
rubocop-0.57.1 lib/rubocop/cop/mixin/code_length.rb
rubocop-0.57.0 lib/rubocop/cop/mixin/code_length.rb
rubocop-0.56.0 lib/rubocop/cop/mixin/code_length.rb
rubocop-0.55.0 lib/rubocop/cop/mixin/code_length.rb
rubocop-0.54.0 lib/rubocop/cop/mixin/code_length.rb
rubocop-0.53.0 lib/rubocop/cop/mixin/code_length.rb
rubocop-0.52.1 lib/rubocop/cop/mixin/code_length.rb