Skip to content
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

Merged
merged 1 commit into from May 21, 2022

Conversation

t-kameyama
Copy link
Contributor

Fix for #4791

@codecov
Copy link

codecov bot commented May 3, 2022

Codecov Report

Merging #4803 (a1ec8c5) into main (16bbc16) will decrease coverage by 0.00%.
The diff coverage is 33.33%.

@@             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     
Impacted Files Coverage Δ
...les/style/ExplicitCollectionElementAccessMethod.kt 65.71% <33.33%> (-0.96%) ⬇️
...n/io/github/detekt/report/html/HtmlOutputReport.kt 95.65% <0.00%> (+0.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 16bbc16...a1ec8c5. Read the comment docs.

@@ -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 {
Copy link
Member

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

@cortinico cortinico added this to the 1.21.0 milestone May 4, 2022
@schalkms schalkms merged commit 5f491f1 into detekt:main May 21, 2022
@t-kameyama t-kameyama deleted the issue_4791 branch May 21, 2022 09:46
Whathecode added a commit to Whathecode/detekt that referenced this pull request Jun 24, 2022
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.
BraisGabin pushed a commit that referenced this pull request Jul 6, 2022
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants