Class: RuboCop::Cop::Kaizo::TotalArguments

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

Overview

Checks that a method does not declare too many arguments in total (positional plus keyword).

The goal is to apply pressure toward good domain modeling: a long argument list is often a sign of primitive obsession, and bundling the related values into an object usually expresses the intent better.

*rest, **keyword-rest, and &block arguments are not counted. The initialize of a Struct.new/Data.define block is exempt, since those parameters mirror the value object's attributes.

Examples:

Max: 3

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

# good
def calculate_volume(shape)
end

Constant Summary collapse

KIND =
"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