New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add UnnamedParameterUse rule #6055
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #6055 +/- ##
============================================
- Coverage 85.18% 85.17% -0.01%
- Complexity 4037 4061 +24
============================================
Files 564 565 +1
Lines 13273 13318 +45
Branches 2387 2401 +14
============================================
+ Hits 11306 11343 +37
- Misses 773 774 +1
- Partials 1194 1201 +7
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue doesn't treat booleans as any special type, right? I was reading again my initial proposal on the issue and I'm not sure if my initial issue is solved.
Extracted from there:
Noncompliant
User("Brais", false)
getUser(id, true)
Compliant
User("Brais", isActive = false)
getUser(id, forceRefresh = true)
getUser(id, refresh)
...errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnnamedParameterUseSpec.kt
Show resolved
Hide resolved
...errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnnamedParameterUseSpec.kt
Show resolved
Hide resolved
...errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnnamedParameterUseSpec.kt
Show resolved
Hide resolved
...errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnnamedParameterUseSpec.kt
Show resolved
Hide resolved
...errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnnamedParameterUseSpec.kt
Show resolved
Hide resolved
...errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnnamedParameterUseSpec.kt
Show resolved
Hide resolved
...errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnnamedParameterUseSpec.kt
Show resolved
Hide resolved
...errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnnamedParameterUseSpec.kt
Show resolved
Hide resolved
...errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnnamedParameterUseSpec.kt
Show resolved
Hide resolved
...errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnnamedParameterUseSpec.kt
Show resolved
Hide resolved
Is it feasible? Should we have a configuration to say which types should always use name arguments? Should we only consider booleans if they are the literals? |
No @BraisGabin this rule is general to any type and doesn't treat boolean as a special type. I followed from comment at #3534 (comment) |
So basically |
|
This PR is stale because it has been open 90 days with no activity. Please comment or this will be closed in 7 days. |
I'm not sure whether this rule should be included into the default rule set. I have the feeling that this rule ends up way more controversial than we expect. Let's see what others think about. Anyhow, the rule is a good fit for the detekt market place. 🙂 |
Hi, @schalkms I think this can go to |
|
||
val namedArgumentList = valueArgumentList.arguments.map { | ||
// No name parameter if it is vararg | ||
(it.isNamed() || paramDescriptorToArgumentMap[it]?.isVararg == true) to it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move (it.isNamed() || paramDescriptorToArgumentMap[it]?.isVararg == true)
to some new field, like a
val isParametrNamed = . I think it will make code more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use the isNamedOrVararg
variable
Co-authored-by: Brais Gabín <braisgabin@gmail.com>
bd52e1c
to
ce5b1da
Compare
Rebase from the upstream main
ce5b1da
to
7bb86a5
Compare
Co-authored-by: Brais Gabín <braisgabin@gmail.com>
Is this rule going to add to the detekt rules? |
It will, at detekt 2.0 |
Fixes #3534