Clean up Scala code

Proprietary

Applies the Scala cleanup and collection rewrites that are safe on any Scala version: removes tail-position return, redundant toString and unused _ bindings, turns never-reassigned local vars into vals, uses None instead of null for Option, replaces Option matches and getOrElse(null) with combinators, simplifies boolean comparisons, and replaces collection chains such as filter(f).size, map(f).flatten and size == 0 with count, flatMap and isEmpty. Rewrites that need Scala 2.13, such as CollectionConverters, are part of the Scala 2.13 migration instead.

org.openrewrite.scala.cleanup.CodeCleanup
mod run . --recipe=org.openrewrite.scala.cleanup.CodeCleanup

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