Closed jbduncan closed 3 years ago
Thanks for the report @jbduncan. Auto-formatting by recipes like this at most should format the code being changed. We can work to limit it to that.
Great, thanks for tackling this so quickly! I'm looking forward to testing it out in a future version.
Having said that, I wonder if I could use Jitpack or the Maven snapshots repo to try it out earlier... 🤔
@jbduncan Yes, all successful CI builds are published to sonatype's snapshot repo: https://oss.sonatype.org/content/repositories/snapshots/org/openrewrite/rewrite-java/7.4.0-SNAPSHOT/.
@jkschneider Thank you! I can confirm when I apply rewrite-java 7.4.0-SNAPSHOT to my Gradle build like so:
repositories {
...
maven("https://oss.sonatype.org/content/repositories/snapshots")
}
dependencies {
...
rewrite("org.openrewrite:rewrite-java:7.4.0-SNAPSHOT")
...
}
...and then add org.openrewrite.java.cleanup.SimplifyBooleanExpression
to my rewrite.yml
file, and finally run ./gradlew rewriteDryRun
, that it all passes. :tada:
I won't actually commit this snapshot version in my repo to ensure that my build is reproducible, so I'm looking forward to when 7.3.1 or 7.4.0 comes out. :)
I've been experimenting with rewrite for a pet project, but I've noticed that the recipe
org.openrewrite.java.cleanup.SimplifyBooleanExpression
runsAutoFormatVisitor
unconditionally, which causes the formatting of my code to change.This is a problem for me, because my project uses rewrite-gradle-plugin, and I've tweaked the task
rewriteDryRun
to fail the build if it would have applied any refactorings. Therefore, when I useSimplifyBooleanExpression
, my build fails for the wrong reason.How to reproduce
git clone https://github.com/jbduncan/guava-graph-utils.git
cd guava-graph-utils
- org.openrewrite.java.cleanup.SimplifyBooleanExpression
- spaces included - to therecipeList:
section of fileconfig/rewrite.yml
../gradlew rewriteDryRun
with Java 11.Expected result
The source code remains unchanged and the build passes.
Actual result
The build fails with the message:
This is a custom error message that my build produces. The source code can be found at the bottom of
build.gradle.kts
.