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

"Missing new line after {" is reported incorrectly in nested lambda #7286

Open
vast00 opened this issue May 10, 2024 · 0 comments
Open

"Missing new line after {" is reported incorrectly in nested lambda #7286

vast00 opened this issue May 10, 2024 · 0 comments

Comments

@vast00
Copy link

vast00 commented May 10, 2024

Expected Behavior

    fun <T> remember(
        calculation: () -> T
    ): T {
        return calculation()
    }
    
    remember {
        { flag: Boolean ->
            println(flag)
        }
    }

should not have any lint warning.

Observed Behavior

    fun <T> remember(
        calculation: () -> T
    ): T {
        return calculation()
    }
    
    remember {
         // Report "Missing new line after {" now
        { flag: Boolean ->
            println(flag)
        }
    }

It seems that the lambda is not recognized as lambda.

Context

It's a common pattern in android that remembering a lambda in composable functions like this:

remember(scope) {
            // Reporting here
            { action ->
                scope.launch {
                    action.invoke()
                }
            }
        }

Your Environment

  • Version of detekt used: detekt jetbrains plugin 2.4.1 (Based on detekt 1.23.6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants