-
-
Notifications
You must be signed in to change notification settings - Fork 784
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
ExplicitCollectionElementAccessMethod: fix false positive for get operators with type parameters #4803
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4803 +/- ##
============================================
- Coverage 84.70% 84.70% -0.01%
Complexity 3426 3426
============================================
Files 491 491
Lines 11253 11258 +5
Branches 2069 2071 +2
============================================
+ Hits 9532 9536 +4
Misses 676 676
- Partials 1045 1046 +1
Continue to review full report at Codecov.
|
…rators with type parameters
@@ -57,8 +57,11 @@ class ExplicitCollectionElementAccessMethod(config: Config = Config.empty) : Rul | |||
} | |||
} | |||
|
|||
private fun isIndexableGetter(expression: KtCallExpression): Boolean = | |||
expression.calleeExpression?.text == "get" && expression.getFunctionDescriptor()?.isOperator == true | |||
private fun isIndexableGetter(expression: KtCallExpression): Boolean { |
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.
nit: Maybe change the function name here as IndexableGetter
is not really clear. I'm not able to come up with a better name though
This also provides a less strict and universal implementation for the previous type parameters bugfix: detekt#4803 As commented in the code, it does this by doing a lazy attempt at whether type inference is possible. If needed, this can be extended on later.
…collections (#4994) * Refactor: clear separation between "can" and "recommended" replace This also provides a less strict and universal implementation for the previous type parameters bugfix: #4803 As commented in the code, it does this by doing a lazy attempt at whether type inference is possible. If needed, this can be extended on later. * Fix: non-sensical index accessor recommendations for java classes Closes #4918 * Refactor: use default Java sources for ExplicitCollectionElementAccess test
Fix for #4791