Skip to content

Commit

Permalink
refactor: Common static analysis issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kmccarp and TeamModerne committed Mar 28, 2024
1 parent 14bf319 commit 3142e7a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
20 changes: 15 additions & 5 deletions src/main/kotlin/org/openrewrite/ChangedRecipe.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,21 @@ data class ChangedRecipe(
val oldOptions: TreeSet<RecipeOption>?,
): Comparable<ChangedRecipe> {
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
}
}
8 changes: 6 additions & 2 deletions src/main/kotlin/org/openrewrite/MarkdownRecipeArtifact.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ data class MarkdownRecipeArtifact (
val markdownRecipeDescriptors: TreeMap<String, MarkdownRecipeDescriptor>,
) : Comparable<MarkdownRecipeArtifact> {
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
}
}
12 changes: 9 additions & 3 deletions src/main/kotlin/org/openrewrite/MarkdownRecipeDescriptor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ data class MarkdownRecipeDescriptor (
val artifactId: String = "",
): Comparable<MarkdownRecipeDescriptor> {
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
}
}

0 comments on commit 3142e7a

Please sign in to comment.