Use modern Kotlin stdlib idioms
Recipe ID
org.openrewrite.kotlin.migrate.UseModernKotlinStdlibApis$KtRecipeArtifact
io.moderne.recipe:recipes-kotlinReplaces Kotlin stdlib APIs deprecated between 1.4 and 2.0 with their modern equivalents, and adopts newer language features (open-ended range ..<, enumEntries<T>()) where the older spelling still compiles but reads worse.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.kotlin.migrate.UseModernKotlinStdlibApis$KtRecipeIf the recipe isn’t available locally, install it with:
mod config recipes jar install io.moderne.recipe:recipes-kotlin:0.2.0Definition
This recipe runs the following recipes in order.
- Use
uppercase()instead oftoUpperCase()org.openrewrite.kotlin.migrate.UseUppercase$KtRecipe - Use
lowercase()instead oftoLowerCase()org.openrewrite.kotlin.migrate.UseLowercase$KtRecipe - Use
uppercase(locale)instead oftoUpperCase(locale)org.openrewrite.kotlin.migrate.UseUppercaseWithLocale$KtRecipe - Use
lowercase(locale)instead oftoLowerCase(locale)org.openrewrite.kotlin.migrate.UseLowercaseWithLocale$KtRecipe - Use
replaceFirstChar { … }instead ofcapitalize()org.openrewrite.kotlin.migrate.UseCapitalize$KtRecipe - Use
replaceFirstChar { it.lowercase() }instead ofdecapitalize()org.openrewrite.kotlin.migrate.UseDecapitalize$KtRecipe - Use
appendLine()instead ofappendln()org.openrewrite.kotlin.migrate.UseAppendLine$KtRecipe - Use
appendLine(value)instead ofappendln(value)org.openrewrite.kotlin.migrate.UseAppendLineWithValue$KtRecipe - Use
appendLine(char)instead ofappendln(char)org.openrewrite.kotlin.migrate.UseAppendLineChar$KtRecipe - Use
appendLine(cs)instead ofappendln(cs)(CharSequence)org.openrewrite.kotlin.migrate.UseAppendLineCharSequence$KtRecipe - Use
appendLine(value)instead ofappendln(value)(Any?)org.openrewrite.kotlin.migrate.UseAppendLineAny$KtRecipe - Use
Char.codeinstead ofChar.toInt()org.openrewrite.kotlin.migrate.UseCharCode$KtRecipe - Use
Char.code.toByte()instead ofChar.toByte()org.openrewrite.kotlin.migrate.UseCharCodeAsByte$KtRecipe - Use
Char.code.toShort()instead ofChar.toShort()org.openrewrite.kotlin.migrate.UseCharCodeAsShort$KtRecipe - Use
Char.code.toLong()instead ofChar.toLong()org.openrewrite.kotlin.migrate.UseCharCodeAsLong$KtRecipe - Use
Char.code.toFloat()instead ofChar.toFloat()org.openrewrite.kotlin.migrate.UseCharCodeAsFloat$KtRecipe - Use
Char.code.toDouble()instead ofChar.toDouble()org.openrewrite.kotlin.migrate.UseCharCodeAsDouble$KtRecipe - Use
Char.uppercaseChar()instead ofChar.toUpperCase()org.openrewrite.kotlin.migrate.UseUppercaseChar$KtRecipe - Use
Char.lowercaseChar()instead ofChar.toLowerCase()org.openrewrite.kotlin.migrate.UseLowercaseChar$KtRecipe - Use
Char(int)instead ofInt.toChar()org.openrewrite.kotlin.migrate.UseCharCtor$KtRecipe - Use
readlnOrNull()instead ofreadLine()org.openrewrite.kotlin.migrate.UseReadlnOrNull$KtRecipe - Use
readln()instead ofreadLine()!!org.openrewrite.kotlin.migrate.UseReadln$KtRecipe - Use
sumOfinstead ofsumByorg.openrewrite.kotlin.migrate.UseSumOf$KtRecipe - Use
sumOfinstead ofsumByDoubleorg.openrewrite.kotlin.migrate.UseSumOfDouble$KtRecipe - Use
..<instead ofuntilorg.openrewrite.kotlin.migrate.UseRangeUntilOperator$KtRecipe - Use
enumEntries<T>()instead ofenumValues<T>()org.openrewrite.kotlin.migrate.UseEnumEntries$KtRecipe - Use
removeAt(0)instead ofremoveFirst()org.openrewrite.kotlin.migrate.UseRemoveAtZeroForRemoveFirst$KtRecipe - Use
removeAt(lastIndex)instead ofremoveLast()org.openrewrite.kotlin.migrate.UseRemoveAtLastIndexForRemoveLast$KtRecipe
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats