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

NullableToStringCall: fix false negative in lambda #6352

Merged
merged 2 commits into from Aug 13, 2023

Conversation

t-kameyama
Copy link
Contributor

@t-kameyama t-kameyama commented Aug 1, 2023

Fixes #6349
Fixes #6378

@detekt-ci detekt-ci added the rules label Aug 1, 2023
@codecov
Copy link

codecov bot commented Aug 1, 2023

Codecov Report

Merging #6352 (e256278) into main (d1b3e53) will increase coverage by 0.03%.
Report is 34 commits behind head on main.
The diff coverage is 76.92%.

@@             Coverage Diff              @@
##               main    #6352      +/-   ##
============================================
+ Coverage     85.13%   85.17%   +0.03%     
+ Complexity     4032     4005      -27     
============================================
  Files           571      570       -1     
  Lines         13432    13387      -45     
  Branches       2373     2354      -19     
============================================
- Hits          11436    11403      -33     
+ Misses          837      834       -3     
+ Partials       1159     1150       -9     
Files Changed Coverage Δ
...turbosch/detekt/rules/bugs/NullableToStringCall.kt 89.65% <76.92%> (+0.46%) ⬆️

... and 25 files with indirect coverage changes

@atulgpt
Copy link
Contributor

atulgpt commented Aug 1, 2023

HI @t-kameyama you beat me in fixing this issue 🤣

in my fix(at commit) I changed your method as below

private fun KtExpression.targetExpression(): KtExpression? {
    val qualifiedExpression = getStrictParentOfType<KtQualifiedExpression>()
    return if (this.parent is KtStringTemplateEntry) {
        this
    } else if (qualifiedExpression != null) {
        qualifiedExpression.takeIf { it.selectorExpression == this } ?: return null
    } else {
        null
    }
}

@cortinico cortinico added the pick request Marker for PRs that should be ported to the 1.0 release branch label Aug 1, 2023
@BraisGabin BraisGabin added this to the 2.0.0 milestone Aug 13, 2023
@BraisGabin BraisGabin merged commit 2717a67 into detekt:main Aug 13, 2023
22 of 23 checks passed
@t-kameyama t-kameyama deleted the issue_6349 branch August 13, 2023 07:08
cortinico pushed a commit that referenced this pull request Oct 30, 2023
* NullableToStringCall: fix false negative in lambda

* Add a test for #6378
mgroth0 pushed a commit to mgroth0/detekt that referenced this pull request Feb 11, 2024
* NullableToStringCall: fix false negative in lambda

* Add a test for detekt#6378
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pick request Marker for PRs that should be ported to the 1.0 release branch rules
Projects
None yet
5 participants