Use Kotlin number extensions instead of java.lang.Integer/Long/Double/Float/Boolean

Proprietary

Replaces JVM-only static helpers on boxed primitive types with their multiplatform Kotlin counterparts: parsing (s.toInt(), s.toLong(radix), s.toDouble(), s.toBoolean()), formatting (i.toString(2), l.toString(16)), bit operations (i.countOneBits(), l.rotateLeft(n)), constants (Int.MIN_VALUE), and compareTo.

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

Recipe list

It runs these recipes, in this order.

  1. Use String.toInt() instead of Integer.parseInt(s)
  2. Use String.toInt(radix) instead of Integer.parseInt(s, radix)
  3. Use Int.toString() instead of Integer.toString(i)
  4. Use Int.toString(radix) instead of Integer.toString(i, radix)
  5. Use Int.toString(2) instead of Integer.toBinaryString
  6. Use Int.toString(16) instead of Integer.toHexString
  7. Use Int.toString(8) instead of Integer.toOctalString
  8. Use Int.countOneBits() instead of java.lang.Integer.bitCount
  9. Use Int.countLeadingZeroBits() instead of Integer.numberOfLeadingZeros
  10. Use Int.countTrailingZeroBits() instead of Integer.numberOfTrailingZeros
  11. Use Int.rotateLeft(n) instead of Integer.rotateLeft(i, n)
  12. Use Int.rotateRight(n) instead of Integer.rotateRight(i, n)
  13. Use Int.MIN_VALUE instead of java.lang.Integer.MIN_VALUE
  14. Use Int.MAX_VALUE instead of java.lang.Integer.MAX_VALUE
  15. Use Int.compareTo instead of java.lang.Integer.compare
  16. Use String.toLong() instead of java.lang.Long.parseLong(s)
  17. Use String.toLong(radix) instead of Long.parseLong(s, radix)
  18. Use Long.toString() instead of Long.toString(l)
  19. Use Long.toString(radix) instead of Long.toString(l, radix)
  20. Use Long.countOneBits() instead of java.lang.Long.bitCount
  21. Use Long.rotateLeft(n) instead of Long.rotateLeft(l, n)
  22. Use Long.rotateRight(n) instead of Long.rotateRight(l, n)
  23. Use String.toDouble() instead of java.lang.Double.parseDouble(s)
  24. Use String.toFloat() instead of java.lang.Float.parseFloat(s)
  25. Use String.toBoolean() instead of java.lang.Boolean.parseBoolean(s)