Sha256: 30b9e547f863b9a297dd12b10465c3608979ebc74938ffddf2cf60ce0249bf45

Contents?: true

Size: 1.66 KB

Versions: 191

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Naming
      # Checks method 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 3.
      # 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
      #   def bar(varOne, varTwo)
      #     varOne + varTwo
      #   end
      #
      #   # With `AllowNamesEndingInNumbers` set to false
      #   def foo(num1, num2)
      #     num1 * num2
      #   end
      #
      #   # With `MinNameLength` set to number greater than 1
      #   def baz(a, b, c)
      #     do_stuff(a, b, c)
      #   end
      #
      #   # good
      #   def bar(thud, fred)
      #     thud + fred
      #   end
      #
      #   def foo(speed, distance)
      #     speed * distance
      #   end
      #
      #   def baz(age_a, height_b, gender_c)
      #     do_stuff(age_a, height_b, gender_c)
      #   end
      class MethodParameterName < Base
        include UncommunicativeName

        def on_def(node)
          return unless node.arguments?

          check(node, node.arguments)
        end
        alias on_defs on_def
      end
    end
  end
end

Version data entries

191 entries across 184 versions & 18 rubygems

Version Path
rubocop-1.70.0 lib/rubocop/cop/naming/method_parameter_name.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/rubocop-1.64.1/lib/rubocop/cop/naming/method_parameter_name.rb
rubocop-1.69.2 lib/rubocop/cop/naming/method_parameter_name.rb
rubocop-1.69.1 lib/rubocop/cop/naming/method_parameter_name.rb
rubocop-1.69.0 lib/rubocop/cop/naming/method_parameter_name.rb
rubocop-1.68.0 lib/rubocop/cop/naming/method_parameter_name.rb
rubocop-1.67.0 lib/rubocop/cop/naming/method_parameter_name.rb
rubocop-1.66.1 lib/rubocop/cop/naming/method_parameter_name.rb
rubocop-1.66.0 lib/rubocop/cop/naming/method_parameter_name.rb
rubocop-1.65.1 lib/rubocop/cop/naming/method_parameter_name.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rubocop-1.64.1/lib/rubocop/cop/naming/method_parameter_name.rb
rubocop-1.65.0 lib/rubocop/cop/naming/method_parameter_name.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/cop/naming/method_parameter_name.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/cop/naming/method_parameter_name.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/cop/naming/method_parameter_name.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/rubocop-1.64.1/lib/rubocop/cop/naming/method_parameter_name.rb
rubocop-1.64.1 lib/rubocop/cop/naming/method_parameter_name.rb
rubocop-1.63.4 lib/rubocop/cop/naming/method_parameter_name.rb
rubocop-1.63.3 lib/rubocop/cop/naming/method_parameter_name.rb
rubocop-1.63.2 lib/rubocop/cop/naming/method_parameter_name.rb