Add `inconsistent_default_argument` rule
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
New Issue Checklist
- Updated SwiftLint to the latest version
- I searched for existing GitHub issues
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files, tests, or entry points. Start by reviewing SwiftLint's existing rule architecture and deciding which circumstances and options are in scope; the work is done when the rule's behavior, defaults, and violations are defined and implemented with appropriate coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100