Use Kotlin number extensions instead of java.lang.Integer/Long/Double/Float/Boolean
ProprietaryReplaces 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$KtRecipemod 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.
- Use
String.toInt()instead ofInteger.parseInt(s) - Use
String.toInt(radix)instead ofInteger.parseInt(s, radix) - Use
Int.toString()instead ofInteger.toString(i) - Use
Int.toString(radix)instead ofInteger.toString(i, radix) - Use
Int.toString(2)instead ofInteger.toBinaryString - Use
Int.toString(16)instead ofInteger.toHexString - Use
Int.toString(8)instead ofInteger.toOctalString - Use
Int.countOneBits()instead ofjava.lang.Integer.bitCount - Use
Int.countLeadingZeroBits()instead ofInteger.numberOfLeadingZeros - Use
Int.countTrailingZeroBits()instead ofInteger.numberOfTrailingZeros - Use
Int.rotateLeft(n)instead ofInteger.rotateLeft(i, n) - Use
Int.rotateRight(n)instead ofInteger.rotateRight(i, n) - Use
Int.MIN_VALUEinstead ofjava.lang.Integer.MIN_VALUE - Use
Int.MAX_VALUEinstead ofjava.lang.Integer.MAX_VALUE - Use
Int.compareToinstead ofjava.lang.Integer.compare - Use
String.toLong()instead ofjava.lang.Long.parseLong(s) - Use
String.toLong(radix)instead ofLong.parseLong(s, radix) - Use
Long.toString()instead ofLong.toString(l) - Use
Long.toString(radix)instead ofLong.toString(l, radix) - Use
Long.countOneBits()instead ofjava.lang.Long.bitCount - Use
Long.rotateLeft(n)instead ofLong.rotateLeft(l, n) - Use
Long.rotateRight(n)instead ofLong.rotateRight(l, n) - Use
String.toDouble()instead ofjava.lang.Double.parseDouble(s) - Use
String.toFloat()instead ofjava.lang.Float.parseFloat(s) - Use
String.toBoolean()instead ofjava.lang.Boolean.parseBoolean(s)