realm / realm/SwiftLint

Add `inconsistent_default_argument` rule

Open
#6,668 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

rule-request
Dominant language
Swift
Stars
19.7k
Forks
2.3k
Avg merge
1d 1h
Merged PRs (30d)
11

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.