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

Detekt should detect multiple line ?. operator for nullable items to be merged into one #6222

Closed
tusharaina opened this issue Jun 15, 2023 · 1 comment
Labels

Comments

@tusharaina
Copy link

Expected Behavior of the rule

dialog?.let { 
            it.window?.let { 
                //do something with window
            }
        }

Here both dialog and window are nullable. So detekt should give error/warning to merge these two into one statement. Currently detekt does not detect this and we could add new rule to detect this behaviour to merge these two into one statement like below:

dialog?.window?.let { 
                //do something with window
            }
        }

Context

This would improve code readability as well as maintainability.

@BraisGabin
Copy link
Member

Closing in favor of #6373. I agree that this should be flagged by detekt but it should be handled by UnnecessaryLet.

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

No branches or pull requests

2 participants