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

False negative on UnnecessaryLet in nested nullable property #6373

Open
atulgpt opened this issue Aug 6, 2023 · 6 comments · May be fixed by #7220
Open

False negative on UnnecessaryLet in nested nullable property #6373

atulgpt opened this issue Aug 6, 2023 · 6 comments · May be fixed by #7220

Comments

@atulgpt
Copy link
Contributor

atulgpt commented Aug 6, 2023

Expected Behavior

Following TC should pass

@Test
fun `reports nested nullable property`() {
    val findings = subject.compileAndLintWithContext(
        env,
        """
            class Dialog(val window: Int?)
            val dialog: Dialog? = null
            fun test() {
                dialog?.let {
                    it.window?.let {
                        it++
                        println(it)
                    }
                }
            }
    """.trimIndent()
    )
    assertThat(findings).hasSize(1)
}

Compliant code should be as below

class Dialog(val window: Int?)
val dialog: Dialog? = null
fun test() {
    dialog?.window?.let {
        it++
        println(it)
    }
}

Observed Behavior

Above TC is failing

Context

There is existing issue to create a new rule to detect this but I think this should be handled by the UnnecessaryLet

@atulgpt atulgpt added the bug label Aug 6, 2023
@BraisGabin
Copy link
Member

Agree

@mjovanc
Copy link
Contributor

mjovanc commented Aug 15, 2023

I could try looking into this if someone hasn't already started.

@atulgpt
Copy link
Contributor Author

atulgpt commented Aug 15, 2023

Hi @mjovanc you can go ahead. I am not looking into this

@cortinico
Copy link
Member

I could try looking into this if someone hasn't already started.

That's assigned to you to work on it if you wish @mjovanc 👍

@mjovanc
Copy link
Contributor

mjovanc commented Aug 21, 2023

@cortinico Will do! Thanks!

@atulgpt atulgpt linked a pull request Apr 23, 2024 that will close this issue
@atulgpt
Copy link
Contributor Author

atulgpt commented May 6, 2024

@BraisGabin @cortinico I have raised the PR for fixing the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants