Find DateTimeFormatter.ofPattern allocations inside loops

Proprietary

DateTimeFormatter.ofPattern(...) parses the pattern up-front. Doing that on every loop iteration burns CPU repeatedly — hoist the formatter into a top-level property. Unlike SimpleDateFormat, DateTimeFormatter is thread-safe, so the hoisted instance can be shared.

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