Conversation
| data class D(val i: Int, val j: Int) | ||
| fun doStuff() { | ||
| val (_, HOLY_GRAIL) = D(5, 4) | ||
| emptyMap<String, String>().forEach { _, V -> println(V) } |
There was a problem hiding this comment.
Why was this here? Should we support this? Is there any documentation that talks about this case?
There was a problem hiding this comment.
Is the problem about why we allow the capital V by default?
It feels like this is a test case that verifying that we do not have any naming requirement for lambda parameters 🙈 . I think your change makes sense.
Codecov Report
@@ Coverage Diff @@
## main #4147 +/- ##
============================================
- Coverage 83.44% 83.44% -0.01%
- Complexity 3177 3185 +8
============================================
Files 465 466 +1
Lines 9104 9128 +24
Branches 1775 1777 +2
============================================
+ Hits 7597 7617 +20
- Misses 572 576 +4
Partials 935 935
Continue to review full report at Codecov.
|
...les-naming/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/naming/LambdaParameterNaming.kt
Outdated
Show resolved
Hide resolved
| override fun visitParameter(parameter: KtParameter) { | ||
| val parameters: List<KtNamedDeclaration> = parameter.destructuringDeclaration?.entries ?: listOf(parameter) |
There was a problem hiding this comment.
As far as I can tell there is nothing restricting this to lambda expressions.
Should this fail or pass?
it("ignores invalid function parameters") {
val code = """
fun foo(BAR: String) = Unit
"""
assertThat(LambdaParameterNaming().compileAndLint(code))
.isEmpty()
}There was a problem hiding this comment.
You are right, there is nothing restrictin this to lambda. But all the naming rules are kind of strange. They aren't called by the normal rule engine. They are called from detekt-rules-naming/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/naming/NamingRules.kt. And it only cal this function when the parameter is from a lambda. You can check my changes in that file.
This implements part of #4131