Skip to content

Commit

Permalink
Handle recipes that have recipe in their name
Browse files Browse the repository at this point in the history
Fixes: #139
  • Loading branch information
mike-solomon committed Oct 30, 2024
1 parent 70eb432 commit 0e061d1
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/main/kotlin/org/openrewrite/RecipeOrigin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,27 @@ class RecipeOrigin(
*/
fun isFromCoreLibrary() = groupId == "org.openrewrite" && coreLibs.contains(artifactId)

private fun convertNameToJavaPath(recipeName: String): String =
recipeName
.replace('.', '/')
.replace(Regex("\\$.*"), "")
.replace(Regex("Recipes?$"), "") + ".java"
private fun convertNameToJavaPath(recipeName: String): String {
// These recipes are not Refaster recipes and should keep
// Recipe or Recipes in their name when linking to them.
val recipesToNotReplace = listOf(
"org.openrewrite.config.CompositeRecipe",
"org.openrewrite.java.migrate.util.OptionalStreamRecipe",
"org.openrewrite.java.recipes.FindRecipes",
"org.openrewrite.java.recipes.NoMutableStaticFieldsInRecipes",
"org.openrewrite.java.spring.boot2.search.IntegrationSchedulerPoolRecipe"
)

val updatedRecipeName = recipeName.replace('.', '/')

return if (recipesToNotReplace.contains(recipeName)) {
"$updatedRecipeName.java"
} else {
updatedRecipeName
.replace(Regex("\\$.*"), "")
.replace(Regex("Recipes?$"), "") + ".java"
}
}

fun githubUrl(): String {
return if (isFromCoreLibrary()) {
Expand Down

0 comments on commit 0e061d1

Please sign in to comment.