Find class-declaration smells
Recipe ID
org.openrewrite.kotlin.bestpractices.FindClassStructureSmells$KtRecipeArtifact
io.moderne.recipe:recipes-kotlinSearch-only bundle: flags class-level structural smells (empty companion, empty class body, redundant : Any(), manual toString/equals/hashCode trio, named companion of constants, multiple secondary constructors, sealed-class-without-state, marker-object-without-data, empty init, all-val classes that could be data class, mutable data class/object state, abstract classes without abstract members, and open classes with no overridable members).
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.bestpractices.FindClassStructureSmells$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.
- Find marker
objectdeclarations that could bedata objectorg.openrewrite.kotlin.bestpractices.FindDataObjectCandidates$KtRecipe - Find
sealed classdeclarations that could besealed interfaceorg.openrewrite.kotlin.bestpractices.FindSealedClassWithoutStateCandidates$KtRecipe - Find empty
companion objectdeclarationsorg.openrewrite.kotlin.bestpractices.FindEmptyCompanionObject$KtRecipe - Find named
companion object Constantspatternsorg.openrewrite.kotlin.bestpractices.FindNamedCompanionObjectOfConstants$KtRecipe - Find
class Foo : Any()declarationsorg.openrewrite.kotlin.bestpractices.FindClassExtendsAny$KtRecipe - Find
class Foo {}declarations with an empty bodyorg.openrewrite.kotlin.bestpractices.FindEmptyClassBody$KtRecipe - Find empty
init { }blocksorg.openrewrite.kotlin.bestpractices.FindEmptyInitBlock$KtRecipe - Find classes with manual
toString/equals/hashCodeoverridesorg.openrewrite.kotlin.bestpractices.FindManualToStringEqualsHashCode$KtRecipe - Find classes with multiple overloaded secondary constructors
org.openrewrite.kotlin.bestpractices.FindMultipleSecondaryConstructors$KtRecipe - Find classes that could be
data classorg.openrewrite.kotlin.bestpractices.FindClassWithoutDataAnnotation$KtRecipe - Find
data classdeclarations withvarpropertiesorg.openrewrite.kotlin.bestpractices.FindDataClassWithMutableProperty$KtRecipe - Find
objectdeclarations withvarpropertiesorg.openrewrite.kotlin.bestpractices.FindObjectWithMutableState$KtRecipe - Find
abstract classdeclarations without abstract membersorg.openrewrite.kotlin.bestpractices.FindAbstractClassWithoutMembers$KtRecipe - Find
open classdeclarations without overridable membersorg.openrewrite.kotlin.bestpractices.FindOpenClassWithoutOverrides$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