Sha256: 5e145cb0529d926bbe64ff648561e4c8a8a9b0e8e26057cd1ceed40d9004bd23

Contents?: true

Size: 875 Bytes

Versions: 6876

Compression:

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

        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

6,876 entries across 6,851 versions & 29 rubygems

Version Path
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/mixin/code_length.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rubocop-0.76.0/lib/rubocop/cop/mixin/code_length.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rubocop-0.77.0/lib/rubocop/cop/mixin/code_length.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/cop/mixin/code_length.rb
rubocop-0.77.0 lib/rubocop/cop/mixin/code_length.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/rubocop-0.75.0/lib/rubocop/cop/mixin/code_length.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/mixin/code_length.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/rubocop-0.74.0/lib/rubocop/cop/mixin/code_length.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/rubocop-0.76.0/lib/rubocop/cop/mixin/code_length.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/cop/mixin/code_length.rb
rubocop-0.76.0 lib/rubocop/cop/mixin/code_length.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/rubocop-0.75.0/lib/rubocop/cop/mixin/code_length.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/mixin/code_length.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/rubocop-0.74.0/lib/rubocop/cop/mixin/code_length.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/cop/mixin/code_length.rb
rubocop-0.75.1 lib/rubocop/cop/mixin/code_length.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/rubocop-0.75.0/lib/rubocop/cop/mixin/code_length.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/cop/mixin/code_length.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/rubocop-0.74.0/lib/rubocop/cop/mixin/code_length.rb
rubocop-0.75.0 lib/rubocop/cop/mixin/code_length.rb