Sha256: 5448bab84498fadf7a480470c3e6c46724b85d0f4e73b94ccc006191b3859d91

Contents?: true

Size: 1.54 KB

Versions: 24

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Naming
      # This cop checks block parameter names for how descriptive they
      # are. It is highly configurable.
      #
      # The `MinNameLength` config option takes an integer. It represents
      # the minimum amount of characters the name must be. Its default is 1.
      # The `AllowNamesEndingInNumbers` config option takes a boolean. When
      # set to false, this cop will register offenses for names ending with
      # numbers. Its default is false. The `AllowedNames` config option
      # takes an array of permitted names that will never register an
      # offense. The `ForbiddenNames` config option takes an array of
      # restricted names that will always register an offense.
      #
      # @example
      #   # bad
      #   bar do |varOne, varTwo|
      #     varOne + varTwo
      #   end
      #
      #   # With `AllowNamesEndingInNumbers` set to false
      #   foo { |num1, num2| num1 * num2 }
      #
      #   # With `MinParamNameLength` set to number greater than 1
      #   baz { |a, b, c| do_stuff(a, b, c) }
      #
      #   # good
      #   bar do |thud, fred|
      #     thud + fred
      #   end
      #
      #   foo { |speed, distance| speed * distance }
      #
      #   baz { |age, height, gender| do_stuff(age, height, gender) }
      class BlockParameterName < Cop
        include UncommunicativeName

        def on_block(node)
          return unless node.arguments?

          check(node, node.arguments)
        end
      end
    end
  end
end

Version data entries

24 entries across 23 versions & 5 rubygems

Version Path
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.79.0/lib/rubocop/cop/naming/block_parameter_name.rb
rubocop-0.88.0 lib/rubocop/cop/naming/block_parameter_name.rb
rbhint-0.87.1.rc1 lib/rubocop/cop/naming/block_parameter_name.rb
rubocop-0.87.1 lib/rubocop/cop/naming/block_parameter_name.rb
rubocop-0.87.0 lib/rubocop/cop/naming/block_parameter_name.rb
rubocop-0.86.0 lib/rubocop/cop/naming/block_parameter_name.rb
files.com-1.0.1 vendor/bundle/ruby/2.5.0/gems/rubocop-0.85.1/lib/rubocop/cop/naming/block_parameter_name.rb
rbhint-0.85.1.rc2 lib/rubocop/cop/naming/block_parameter_name.rb
rbhint-0.85.1.rc1 lib/rubocop/cop/naming/block_parameter_name.rb
rubocop-0.85.1 lib/rubocop/cop/naming/block_parameter_name.rb
rbhint-0.8.5.rc1 lib/rubocop/cop/naming/block_parameter_name.rb
rubocop-0.85.0 lib/rubocop/cop/naming/block_parameter_name.rb
rubocop-0.84.0 lib/rubocop/cop/naming/block_parameter_name.rb
rubocop-0.83.0 lib/rubocop/cop/naming/block_parameter_name.rb
rubocop-0.82.0 lib/rubocop/cop/naming/block_parameter_name.rb
rubocop-0.81.0 lib/rubocop/cop/naming/block_parameter_name.rb
rubocop-0.80.1 lib/rubocop/cop/naming/block_parameter_name.rb
rubocop-0.80.0 lib/rubocop/cop/naming/block_parameter_name.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.79.0/lib/rubocop/cop/naming/block_parameter_name.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/rubocop-0.79.0/lib/rubocop/cop/naming/block_parameter_name.rb