Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
Root.Smell.MethodSmell.ParameterListLength Parent Index
Sibling aspects MethodLength

ParameterListLength

Number of parameter a function or method has.

In the book "Code Complete", ISBN 0735619670 it is suggested that the maximum number of parameter per function or method is 7; rubocop suggests 5.

Tastes

Taste Meaning Values
max_parameters Represents the max number of parameters for a function or a method. 7, 5

* bold denotes default value

Subaspects

This aspect does not have any sub aspects.

Example

def func(a, b, c, d, e, f, g, h, i, j, k):
    pass

Importance

Methods that take too many parameters are difficult to read, maintain and work with, and callers of those method often have an awkward time assembling all of the data and the resulting code is usually not pretty.

How to fix this

This can be fixed by:

Instead of passing a group of data received from an object as parameters, pass the object itself to the method. Sometimes you can merge several parameters into a single object etc.