Find if (result.isSuccess) … else … patterns

Proprietary

Branching on Result.isSuccess / Result.isFailure and then unwrapping with getOrNull() / exceptionOrNull() is the imperative form of result.fold(onSuccess, onFailure). The .fold(...) form is total (the compiler verifies both branches are present) and reads as the value-producing expression it actually is.

org.openrewrite.kotlin.functional.FindResultFoldImperative$KtRecipe
mod run . --recipe='org.openrewrite.kotlin.functional.FindResultFoldImperative$KtRecipe'

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.