Skip to content

New rule: Methods should not have too many default parameters #74

Open
@fourls

Description

@fourls

Prerequisites

  • This rule has not already been suggested.
  • This should be a new rule, not an improvement to an existing rule.
  • This rule would be generally useful, not specific to my code or setup.

Suggested rule title

Methods should not have too many default parameters

Rule description

This rule would identify methods with more than a configured maximum number of default parameters. This would be a user-configurable property.

Rationale

Default parameters can be useful in cases when there is a sensible default value. They can, however, damage API interfaces when used to make a method's behaviour overly configurable - a method with too many default parameters is confusing, unpredictable at a glance, unintuitive to use, and likely overloaded in functionality.

Using multiple methods, method overloads, or configuration objects would be a more maintainable approach and would keep the API cleaner.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or requestgood first issueGood for newcomersruleImprovements or additions to rules

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions