We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 901ba81 commit 1b97fadCopy full SHA for 1b97fad
1 file changed
src/test/java/org/openrewrite/staticanalysis/SimplifyBooleanExpressionTest.java
@@ -418,6 +418,29 @@ boolean notOne(A a) {
418
);
419
}
420
421
+ @Issue("https://github.com/openrewrite/rewrite-static-analysis/issues/276")
422
+ @Test
423
+ void doNotNegateConditionOfTernaryWhenBranchesAreNotSwapped() {
424
+ rewriteRun(
425
+ java(
426
+ """
427
+ class A {
428
+ boolean foo(String name) {
429
+ return !(name != null ? !name.equals(System.out.toString()) : false);
430
+ }
431
432
+ """,
433
434
435
436
+ return name != null ? name.equals(System.out.toString()) : true;
437
438
439
440
+ )
441
+ );
442
443
+
444
@Test
445
void correctlySimplifyNegatedTernaryEqualsNull() {
446
rewriteRun(
0 commit comments