openrewrite / rewrite

Automated mass refactoring of source code.
https://docs.openrewrite.org
Apache License 2.0
2.19k stars 329 forks source link

Validation error messages can be ambigious #4455

Open Bananeweizen opened 1 month ago

Bananeweizen commented 1 month ago

What is the smallest, simplest way to reproduce the problem?

Enable these rules, all without parameters

org.openrewrite.java.logging.log4j.ParameterizedLogging
org.openrewrite.java.logging.ParameterizedLogging
org.openrewrite.java.logging.slf4j.ParameterizedLogging

What did you see?

[ERROR] Recipe validation error in ParameterizedLogging.methodPattern: is required

This can be very confusing, when looking up the recipe by (short) name. Only 1 of 3 has parameters. Therefore the user may end up adding the parameters to the wrong recipe, reading the wrong documentation etc.

Even though avoiding the full qualified names is generally a nice idea, it can lead to additional trouble.

Are you interested in contributing a fix to OpenRewrite?

Maybe. Depends on which direction a fix would go.

timtebeek commented 1 month ago

Hmm; that's a bit unfortunate indeed, but hopefully rare; In this case it's the shortest one that's missing its options; glad at least that we correctly reject that in the validation.

Indeed not sure what to do specifically here, but fully qualifying the recipe name would only help if there are more such identical class names, which I think is reasonably rare, especially not expecting those to be used together (folks use one or the other).

timtebeek commented 1 month ago

I could see a case though to always fully qualify; especially with a Spring Boot 3.x best practices containing 2556 recipes, it might make sense to always fully qualify the recipe name.