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 positive raise escape warning when calling lazy logger within computation #6

Open
tKe opened this issue Jun 18, 2024 · 1 comment

Comments

@tKe
Copy link

tKe commented Jun 18, 2024

For the following code, the plugin highlights the call to logger.info as "Raise context may escape through this lambda". This is unexpected as the lambda doesn't capture the raise context.

import arrow.core.raise.nullable // io.arrow-kt:arrow-core:1.2.4
import io.github.oshai.kotlinlogging.KotlinLogging // io.github.oshai:kotlin-logging-jvm:7.0.0

val logger = KotlinLogging.logger {}

fun main() {
    nullable {
        logger.info { "hello" }
    }
}

I would however expect the warning if raise was captured by the lambda (by a call to raise(null) or ensure(bool) etc).

@serras
Copy link
Member

serras commented Oct 2, 2024

As of 69c4fd2 the heuristic for detecting potentially escaped lambdas has been improved with your suggestion, and cases like that are indeed not marked.

This is part of release 0.2.1, which is currently in approval.

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

No branches or pull requests

2 participants