Skip to content

Commit

Permalink
Add regression guard for combination of SimplifyBooleanExpression and…
Browse files Browse the repository at this point in the history
… SimplifyBooleanReturn
  • Loading branch information
sambsnyd committed Aug 29, 2024
1 parent 397e325 commit fe4ba63
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public String getDescription() {

@Override
public Set<String> getTags() {
return Collections.singleton("RSPEC-S1125");
return Collections.singleton("RSPEC-1125");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
"""
)
);
}
}

0 comments on commit fe4ba63

Please sign in to comment.