openrewrite / rewrite-static-analysis

OpenRewrite recipes for identifying and fixing static analysis issues.
Apache License 2.0
31 stars 46 forks source link

UseAsBuilder fails without details #90

Closed koppor closed 1 year ago

koppor commented 1 year ago
> Configure project :
Project : => 'org.jabref' Java module

> Task :rewriteRun
Validating active recipes
Parsing sources from project JabRef
All sources parsed, running active recipes: org.jabref.config.rewrite.cleanup
line 1:0 mismatched input '<EOF>' expecting {'.', '!', '*', '..', Identifier}
The recipe produced an error. Please report this to the recipe author.

> Task :rewriteRun FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':rewriteRun'.
> java.lang.NullPointerException: Cannot invoke "String.isEmpty()" because "this.pattern" is null

Codebase: https://github.com/JabRef/jabref/

knutwannheden commented 1 year ago

@koppor Thanks for the report!

The UseAsBuilder recipe requires a builderType option, which currently lacks documentation: https://github.com/openrewrite/rewrite/blob/7059e059b7d055b35741442f3530af2268fe2b5d/rewrite-java/src/main/java/org/openrewrite/java/cleanup/UseAsBuilder.java#L37-L38

Also, it would be good if the recipe would implement the validate() method to validate this and other options.

knutwannheden commented 1 year ago

@srmalkan Thanks for the contribution! 🙏 It would be great if could also complete the @Option annotation for builderType with some details.

srmalkan commented 1 year ago

@srmalkan Thanks for the contribution! 🙏 It would be great if could also complete the @Option annotation for builderType with some details.

@knutwannheden I have added the details. Could you have a look at it?