diff --git a/src/main/java/org/openrewrite/staticanalysis/SimplifyBooleanExpression.java b/src/main/java/org/openrewrite/staticanalysis/SimplifyBooleanExpression.java index b778f19b1..a8fb898fc 100644 --- a/src/main/java/org/openrewrite/staticanalysis/SimplifyBooleanExpression.java +++ b/src/main/java/org/openrewrite/staticanalysis/SimplifyBooleanExpression.java @@ -42,7 +42,7 @@ public String getDescription() { @Override public Set getTags() { - return Collections.singleton("RSPEC-S1125"); + return Collections.singleton("RSPEC-1125"); } @Override diff --git a/src/test/java/org/openrewrite/staticanalysis/SimplifyBooleanExpressionTest.java b/src/test/java/org/openrewrite/staticanalysis/SimplifyBooleanExpressionTest.java index 8bdbbbb98..d825e8570 100644 --- a/src/test/java/org/openrewrite/staticanalysis/SimplifyBooleanExpressionTest.java +++ b/src/test/java/org/openrewrite/staticanalysis/SimplifyBooleanExpressionTest.java @@ -379,4 +379,34 @@ public class A { ) ); } + + @Test + void nullCheck() { + rewriteRun( + spec -> spec + .recipes( + new SimplifyBooleanReturn(), + new SimplifyBooleanExpression() + ), + //language=java + java(""" + class A { + String name; + boolean notOne(A a) { + if (a != null ? !name.equals(a.name) : a.name != null) return false; + return true; + } + } + """, + """ + class A { + String name; + boolean notOne(A a) { + return a == null ? a.name != null : !name.equals(a.name); + } + } + """ + ) + ); + } }