Skip to content

NamedArguments: Ignore when argument values are the same as the parameter name#4613

Merged
BraisGabin merged 2 commits into
detekt:mainfrom
t-kameyama:issue_4591
Mar 10, 2022
Merged

NamedArguments: Ignore when argument values are the same as the parameter name#4613
BraisGabin merged 2 commits into
detekt:mainfrom
t-kameyama:issue_4591

Conversation

@t-kameyama

Copy link
Copy Markdown
Contributor

Fixes #4591

@marschwar

marschwar commented Mar 7, 2022

Copy link
Copy Markdown
Contributor

Should those examples below be considered ok or not?

class Baz {
    private var b: Int = 42
    fun foo(a: Int, b: Int, c: Int) {}
    fun bar(a: Int, c: Int) {
        foo(a, this.b, c)
    }
}
data class Baz(val b: Int)
fun foo(a: Int, b: Int, c: Int) {}
fun bar(a: Int, c: Int, baz: Baz?) {
    baz?.let { foo(a, it.b, c) }
}

[edit] To be clear, it think they should be flagged (as it is implemented) but I would like to have a test case that verifies it.

@BraisGabin BraisGabin added this to the 1.20.0 milestone Mar 10, 2022
@BraisGabin BraisGabin merged commit 1269b9b into detekt:main Mar 10, 2022
@t-kameyama t-kameyama deleted the issue_4591 branch March 10, 2022 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NamedArguments: Ignore when argument values are the same as the parameter names

4 participants