Skip to content

Add inconsistent_default_argument rule #6668

@rgoldberg

Description

@rgoldberg

New Issue Checklist

New Rule Request

Please add a inconsistent_default_argument rule (it could be named coordinate_default_arguments if you want an imperative name for the fix instead of a descriptive name for the problem, or something else).

In certain circumstances, it would ensure that parameters with the same label & type that have a default argument use the same default argument.

It could have a few options to specify the applicable circumstances. I'll leave it to you to decide what circumstances (& if the whole rule) should be enabled by default (also, you can rename any options, add options, etc.) (I'd prefer the rule & all options to be enabled by default, but I don't know how much code would violate the maximal rule, so I don't want to cause a tsunami of violations). Boolean options:

  • call_default_arguments: If functions F & G both have a default argument for parameter P, if F calls G passing its value of P to to G's P, then it is an error if the default arguments for P for both F & G are not the same.
  • overload_default_arguments: If methods F & G for the same type with the same name but with different signatures both have a default argument for parameter P, then it is an error if the default arguments for P for both F & G are not the same.
  • override_default_arguments: If method F exists for type T, and overrides a method G from some type/protocol, S, that T extends / conforms to, and both F & G have a default argument for parameter P, then it is an error if the default arguments for P for both F & G are not the same.
  • etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions