Class: RuboCop::Cop::Kaizo::KeywordArguments

Inherits:
Base
  • Object
show all
Includes:
ArgumentCounting
Defined in:
lib/rubocop/cop/kaizo/keyword_arguments.rb

Overview

Checks that a method does not declare too many keyword arguments.

Keyword arguments are self-documenting, but a long list of them is still a sign that the related values want to be modeled as an object. Required (kwarg) and optional (kwoptarg) parameters are counted; **rest is not.

Examples:

Max: 2

# bad
def calculate_volume(width:, length:, height:)
end

# good
def calculate_volume(shape)
end

Constant Summary collapse

KIND =
"keyword arguments".freeze

Constants included from ArgumentCounting

ArgumentCounting::DEFINE_METHODS, ArgumentCounting::KEYWORD_TYPES, ArgumentCounting::MSG, ArgumentCounting::POSITIONAL_TYPES, ArgumentCounting::STRUCT_OR_DATA

Method Summary

Methods included from ArgumentCounting

#on_block, #on_def