-
-
Notifications
You must be signed in to change notification settings - Fork 760
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
UnnecessaryApply: fix false positive when lambda has multiple member references #3564
Conversation
Codecov Report
@@ Coverage Diff @@
## main #3564 +/- ##
============================================
- Coverage 78.22% 78.19% -0.04%
- Complexity 2826 2834 +8
============================================
Files 466 466
Lines 9136 9137 +1
Branches 1724 1726 +2
============================================
- Hits 7147 7145 -2
Misses 1059 1059
- Partials 930 933 +3
Continue to review full report at Codecov.
|
Can we wait a bit to merge this, I'm not so sure about this issue. It seems like a true positive to me. |
What do you think about what I said in the issue? |
class Foo {
fun bar(f: () -> Unit) {}
var baz = 1
}
fun test(foo: Foo) {
// case 1
foo.apply {
println(baz)
println(baz)
}
// case 2
foo.apply {
bar {
println(baz)
println(baz)
}
}
} Since it's not flagged in case 1, I don't think it should be flagged in case 2 as well. I understand that this rule does not flag when lambda has multiple member references. |
Maybe we should update it and make it flag the first case too. Promoting |
790d486
to
08505d0
Compare
I don't think so. The first case can be replaced with |
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.
Since it's not flagged in case 1, I don't think it should be flagged in case 2 as well. I understand that this rule does not flag when lambda has multiple member references.
I agree with you here. The problem that I'm talking about is already in the rule so this PR just make it more consistent so we should merge this. I think that we need to rethink a bit this rule but that's another topic 👍.
Fixes #3561