Find if (x == null) throw IllegalArgumentException(...) patterns

Proprietary

Kotlin's requireNotNull(x) { "…" } is the idiomatic precondition check: it throws IllegalArgumentException when x is null, smart-casts x to its non-nullable type after the call, and reads as the assertion it is. The if/throw form does the same thing without the smart-cast.

org.openrewrite.kotlin.functional.FindUseRequireForPrecondition$KtRecipe
mod run . --recipe='org.openrewrite.kotlin.functional.FindUseRequireForPrecondition$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.