Sha256: 160a2682bcd6cf07eff10610d06e8aaf308d5c8b90b0b809c86218828b98ec43

Contents?: true

Size: 752 Bytes

Versions: 4

Compression:

Stored size: 752 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Metrics
      # This cop checks if the length of a block exceeds some maximum value.
      # Comment lines can optionally be ignored.
      # The maximum allowed length is configurable.
      # The cop can be configured to ignore blocks passed to certain methods.
      class BlockLength < Cop
        include TooManyLines

        LABEL = 'Block'.freeze

        def on_block(node)
          return if excluded_methods.include?(node.method_name.to_s)
          check_code_length(node)
        end

        private

        def excluded_methods
          cop_config['ExcludedMethods'] || []
        end

        def cop_label
          LABEL
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.48.1 lib/rubocop/cop/metrics/block_length.rb
rubocop-0.48.0 lib/rubocop/cop/metrics/block_length.rb
rubocop-0.47.1 lib/rubocop/cop/metrics/block_length.rb
rubocop-0.47.0 lib/rubocop/cop/metrics/block_length.rb