Sha256: 006557d487f701bc494a8e13ba182b2a8368d36c4e05e1e734eeece3803a0270

Contents?: true

Size: 923 Bytes

Versions: 6878

Compression:

Stored size: 923 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    # Common functionality for checking length of classes and modules.
    module ClassishLength
      include CodeLength

      private

      def code_length(node)
        body_line_numbers = line_range(node).to_a[1...-1]

        target_line_numbers = body_line_numbers -
                              line_numbers_of_inner_nodes(node, :module, :class)

        target_line_numbers.reduce(0) do |length, line_number|
          source_line = processed_source[line_number]
          next length if irrelevant_line(source_line)

          length + 1
        end
      end

      def line_numbers_of_inner_nodes(node, *types)
        line_numbers = Set.new

        node.each_descendant(*types) do |inner_node|
          line_range = line_range(inner_node)
          line_numbers.merge(line_range)
        end

        line_numbers.to_a
      end
    end
  end
end

Version data entries

6,878 entries across 6,853 versions & 29 rubygems

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