Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Max Function Arity #286

Closed
elbrujohalcon opened this issue Feb 28, 2023 · 3 comments
Closed

Max Function Arity #286

elbrujohalcon opened this issue Feb 28, 2023 · 3 comments
Assignees
Labels
Milestone

Comments

@elbrujohalcon
Copy link
Member

elbrujohalcon commented Feb 28, 2023

Max Function Arity

Brief Description

Warn if a function has too many arguments.

Should be on by default?

YES

Options

  • max_arity :: pos_integer() (default: 5)

Note: I picked 5 as the default basically randomly. If the implementor can do a proper analysis of some public Erlang codebases to determine what a reasonable default should be, much better.

Reasoning

Quoting from Credo docs:

A function can take as many parameters as needed, but even in a functional language, there can be too many parameters.

Origin (#281)

Inspired by the Refactor.FunctionArity rule from Credo

@elbrujohalcon elbrujohalcon added this to the 3.0.0 milestone Feb 28, 2023
@maco
Copy link
Collaborator

maco commented Feb 28, 2023

Credo's default is 8. I don't really see why not have the same default.

@paulo-ferraz-oliveira
Copy link
Collaborator

8 sounds reasonable as a default. In a team I used to work in we had 7 as a "rule of thumb" 👍 Then you had to use maps or records, or otherwise work around it :) Most of the initial cases it was just people adding options as new arguments :)

@elbrujohalcon
Copy link
Member Author

8 is a great number, yes!

@elbrujohalcon elbrujohalcon self-assigned this Mar 1, 2023
elbrujohalcon added a commit that referenced this issue Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants