We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Don't throw an issue for OptionalUnit when used with suspendCoroutines that return nothing
In the following code, I can't remove Unit from the return because suspendCoroutine needs to known the function return type.
override suspend fun doAction(): Unit = suspendCoroutine { cont -> Integration.signOut() { it.fold( { cont.resume(Unit) }, { error -> cont.resumeWithException(error as Exception) } ) } }
Detekt is complaining with a OptionalUnit rule.
Detekt is not passing in this particular case in my project.
The text was updated successfully, but these errors were encountered:
A workaround for this would be to specify the type in the generic bracket, e.g.
override suspend fun doAction() = suspendCoroutine<Unit> { cont -> Integration.signOut() { it.fold( { cont.resume(Unit) }, { error -> cont.resumeWithException(error as Exception) } ) } }
Sorry, something went wrong.
Hi @severn-everett, it worked like you suggested!
But I think it's nice to address this on the other way around too.
Thank you for helping and opening a PR to adjust this.
Thanks for the report @panoramix360. Closing because @severn-everett fixed it in #4371
No branches or pull requests
Expected Behavior
Don't throw an issue for OptionalUnit when used with suspendCoroutines that return nothing
In the following code, I can't remove Unit from the return because suspendCoroutine needs to known the function return type.
Observed Behavior
Detekt is complaining with a OptionalUnit rule.
Steps to Reproduce
Context
Detekt is not passing in this particular case in my project.
Your Environment
The text was updated successfully, but these errors were encountered: