From 3142e7adef991a762727ae4859ee4aa42d549dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Carpenter=E2=84=A2=EF=B8=8F?= Date: Thu, 28 Mar 2024 17:25:52 +0000 Subject: [PATCH] refactor: Common static analysis issues Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.staticanalysis.CommonStaticAnalysis?organizationId=T3BlblJld3JpdGU%3D Co-authored-by: Moderne --- .../kotlin/org/openrewrite/ChangedRecipe.kt | 20 ++++++++++++++----- .../org/openrewrite/MarkdownRecipeArtifact.kt | 8 ++++++-- .../openrewrite/MarkdownRecipeDescriptor.kt | 12 ++++++++--- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/org/openrewrite/ChangedRecipe.kt b/src/main/kotlin/org/openrewrite/ChangedRecipe.kt index a5eff32..4d6491a 100644 --- a/src/main/kotlin/org/openrewrite/ChangedRecipe.kt +++ b/src/main/kotlin/org/openrewrite/ChangedRecipe.kt @@ -11,11 +11,21 @@ data class ChangedRecipe( val oldOptions: TreeSet?, ): Comparable { override fun compareTo(other: ChangedRecipe): Int { - if (this.artifactId != other.artifactId) return this.artifactId.compareTo(other.artifactId) - if (this.name != other.name) return this.name.compareTo(other.name) - if (this.description != other.description) return this.description.compareTo(other.description) - if (this.newOptions != other.newOptions) return -1 - if (this.oldOptions != other.oldOptions) return -1 + if (this.artifactId != other.artifactId) { + return this.artifactId.compareTo(other.artifactId) + } + if (this.name != other.name) { + return this.name.compareTo(other.name) + } + if (this.description != other.description) { + return this.description.compareTo(other.description) + } + if (this.newOptions != other.newOptions) { + return -1 + } + if (this.oldOptions != other.oldOptions) { + return -1 + } return 0 } } diff --git a/src/main/kotlin/org/openrewrite/MarkdownRecipeArtifact.kt b/src/main/kotlin/org/openrewrite/MarkdownRecipeArtifact.kt index 390f410..8738cc9 100644 --- a/src/main/kotlin/org/openrewrite/MarkdownRecipeArtifact.kt +++ b/src/main/kotlin/org/openrewrite/MarkdownRecipeArtifact.kt @@ -8,8 +8,12 @@ data class MarkdownRecipeArtifact ( val markdownRecipeDescriptors: TreeMap, ) : Comparable { override fun compareTo(other: MarkdownRecipeArtifact): Int { - if (this.artifactId != other.artifactId) return this.artifactId.compareTo(other.artifactId) - if (this.markdownRecipeDescriptors != other.markdownRecipeDescriptors) return -1 + if (this.artifactId != other.artifactId) { + return this.artifactId.compareTo(other.artifactId) + } + if (this.markdownRecipeDescriptors != other.markdownRecipeDescriptors) { + return -1 + } return 0 } } \ No newline at end of file diff --git a/src/main/kotlin/org/openrewrite/MarkdownRecipeDescriptor.kt b/src/main/kotlin/org/openrewrite/MarkdownRecipeDescriptor.kt index 84586c1..8bf4b94 100644 --- a/src/main/kotlin/org/openrewrite/MarkdownRecipeDescriptor.kt +++ b/src/main/kotlin/org/openrewrite/MarkdownRecipeDescriptor.kt @@ -11,9 +11,15 @@ data class MarkdownRecipeDescriptor ( val artifactId: String = "", ): Comparable { override fun compareTo(other: MarkdownRecipeDescriptor): Int { - if (this.name != other.name) return this.name.compareTo(other.name) - if (this.description != other.description) return this.description.compareTo(other.description) - if (this.options != other.options) return -1 + if (this.name != other.name) { + return this.name.compareTo(other.name) + } + if (this.description != other.description) { + return this.description.compareTo(other.description) + } + if (this.options != other.options) { + return -1 + } return 0 } } \ No newline at end of file