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

Fix #2021 #2032

Merged
merged 4 commits into from
Oct 28, 2019
Merged

Fix #2021 #2032

merged 4 commits into from
Oct 28, 2019

Conversation

3flex
Copy link
Member

@3flex 3flex commented Oct 17, 2019

Fixes #2021

This feels slightly hacky but I can't think of any better way at the moment :/

val returnExpressionsInBlock = bodyExpression.getChildrenOfType<KtReturnExpression>()
val returnExpressionsInBlock = bodyExpression.collectDescendantsOfType<KtReturnExpression> {
it.parent == bodyExpression || it.parent is KtAnnotatedExpression && it.parent.parent == bodyExpression
}
val lastValidReturnExpression = returnExpressionsInBlock.first().returnedExpression
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm is the bodyExpression the Annotation itself?
That could explain why getChildrenOfType is empty and first crashes.
We should also use firstOrNull, don't we?
I'm not sure what happens here, but will try to debug it too.

@arturbosch arturbosch added this to the 1.2.0 milestone Oct 24, 2019
@codecov-io
Copy link

codecov-io commented Oct 28, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@0c24d9e). Click here to learn what that means.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2032   +/-   ##
=========================================
  Coverage          ?   80.35%           
  Complexity        ?     2015           
=========================================
  Files             ?      332           
  Lines             ?     5661           
  Branches          ?     1044           
=========================================
  Hits              ?     4549           
  Misses            ?      559           
  Partials          ?      553
Impacted Files Coverage Δ Complexity Δ
...etekt/rules/bugs/EqualsAlwaysReturnsTrueOrFalse.kt 84.21% <50%> (ø) 13 <10> (?)

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 0c24d9e...2c37551. Read the comment docs.

@arturbosch arturbosch merged commit fc9fdca into detekt:master Oct 28, 2019
@3flex 3flex deleted the 2021-fix branch October 29, 2019 01:35
smyachenkov pushed a commit to smyachenkov/detekt that referenced this pull request Dec 9, 2019
* Fix detekt#2021

* minor refactor

* fix typo
smyachenkov pushed a commit to smyachenkov/detekt that referenced this pull request Dec 9, 2019
* Fix detekt#2021

* minor refactor

* fix typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants