This demonstrates some issues that are currently tripping up OpenRewrite (as of 2024-07-13), version 5.35.0 (and rewrite-static-analysis version 1.11.0).
- Build it
./mvnw clean package
- Run it
./mvnw clean package exec:java --projects source-problems -Dexec.mainClass="ch.vingolds.testopenrewrite.Main"
- Rewrite it
./mvnw --activate-profiles openrewrite org.openrewrite.maven:rewrite-maven-plugin:run
- Run it again: does it fail?
./mvnw clean package exec:java --projects source-problems -Dexec.mainClass="ch.vingolds.testopenrewrite.Main"
You will see output like this:
Hello and welcome!
This line should not be executed!
[WARNING]
java.lang.RuntimeException: code should not reach here! if you see this, rewrite has messed up.
at ch.vingolds.testopenrewrite.WithEmptyBlock.shouldNotFlipCondition (WithEmptyBlock.java:33)
- See the issue:
git diff source-problems/src/main/java/ch/vingolds/testopenrewrite/WithEmptyBlock.java
The NormalizeLineBreaks
and NormalizeTabsOrSpaces
don't normalize \r\n\
Windows style
line breaks to \n
Unix style line breaks at all.
After rewrite, the comments in WithCommentPlacingInBraces are messed up in several ways. Please examine diff:
git diff source-problems/src/main/java/ch/vingolds/testopenrewrite/WithCommentPlacingInBraces.java