You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't expect UnnecessaryLet to be reported for the following code:
val y = x.let { (a, b) -> a + b }
That is because, in this case, let is necessary for destructuring. If I really, want to get rid of let I have to destructure in a val (a, b) = x assigment. And to not let a and b leak in the scope, I'd have to replace val y = x.let { (a, b) -> a + b} by val y = run { val (a, b) = x ; a + b }. Not really an improvement in my opinion.
Observed Behavior
An UnnecessaryLet is reported for the code above.
Steps to Reproduce
Enable UnnecessaryLet rule
Write:
funfoo(x:Pair<Int, Int>): Int= x.let { (a, b) -> a + b }
Run detekt
Your Environment
Version of detekt used: 1.11.0-RC2
The text was updated successfully, but these errors were encountered:
Expected Behavior
I don't expect
UnnecessaryLet
to be reported for the following code:That is because, in this case,
let
is necessary for destructuring. If I really, want to get rid oflet
I have to destructure in aval (a, b) = x
assigment. And to not leta
andb
leak in the scope, I'd have to replaceval y = x.let { (a, b) -> a + b}
byval y = run { val (a, b) = x ; a + b }
. Not really an improvement in my opinion.Observed Behavior
An
UnnecessaryLet
is reported for the code above.Steps to Reproduce
UnnecessaryLet
ruleYour Environment
The text was updated successfully, but these errors were encountered: