-
Notifications
You must be signed in to change notification settings - Fork 93
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
What version of OpenRewrite are you using?
- org.openrewrite:rewrite-core:8.58.0
- org.openrewrite.recipe:rewrite-static-analysis:2.12.0
What is the smallest, simplest way to reproduce the problem?
In some boolean expressions, the output of CompareEnumsWithEqualityOperator needs to be wrapped in parentheses to ensure that the code produced is valid. #3 is another example of this, and here another one found in our code base.
@Test
public void enumEqual() {
rewriteRun(
spec -> spec.recipe(new CompareEnumsWithEqualityOperator()),
java(
"""
package com.helloworld;
import java.time.DayOfWeek;
public static class Foo {
boolean foo = true == DayOfWeek.MONDAY.equals(DayOfWeek.TUESDAY);
}
""", """
package com.helloworld;
import java.time.DayOfWeek;
public static class Foo {
boolean foo = true == (DayOfWeek.MONDAY == DayOfWeek.TUESDAY);
}
"""));
}org.opentest4j.AssertionFailedError: [Unexpected result in "com/helloworld/Foo.java":
diff --git a/com/helloworld/Foo.java b/com/helloworld/Foo.java
index daf2906..11a6884 100644
--- a/com/helloworld/Foo.java
+++ b/com/helloworld/Foo.java
@@ -3,5 +3,5 @@
import java.time.DayOfWeek;
public static class Foo {
- boolean foo = true == (DayOfWeek.MONDAY == DayOfWeek.TUESDAY);
+ boolean foo = true == DayOfWeek.MONDAY == DayOfWeek.TUESDAY;
}
\ No newline at end of file
]
expected:
"package com.helloworld;
import java.time.DayOfWeek;
public static class Foo {
boolean foo = true == (DayOfWeek.MONDAY == DayOfWeek.TUESDAY);
}"
but was:
"package com.helloworld;
import java.time.DayOfWeek;
public static class Foo {
boolean foo = true == DayOfWeek.MONDAY == DayOfWeek.TUESDAY;
}"
at org.openrewrite.test.RewriteTest.assertContentEquals(RewriteTest.java:622)
at org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:511)
at org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:130)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done