Fix false positive for UnnecessaryApply with disabled type resolution#2963
Merged
schalkms merged 1 commit intodetekt:masterfrom Aug 11, 2020
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2963 +/- ##
============================================
+ Coverage 80.25% 80.27% +0.02%
- Complexity 2465 2478 +13
============================================
Files 423 424 +1
Lines 7440 7473 +33
Branches 1358 1369 +11
============================================
+ Hits 5971 5999 +28
+ Misses 763 760 -3
- Partials 706 714 +8
Continue to review full report at Codecov.
|
schalkms
approved these changes
Aug 11, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Restricting
UnnecessaryApplyto work only when type resolution is active.Currently the rule is generating false positives for scenarios where the return value of
.apply{}is used. We actually already have the code to handle this scenario (!expression.receiverIsUsed(bindingContext)) but it requires type and symbol resolution to provide a meaningful result.As a rule of thumb, we should also consider avoiding rules with "mixed" inspection if you have type resolution enabled or not.
Fixes #2938