@@ -185,8 +185,8 @@ public class SimplifyBooleanReturns {
185185 <expected-problems >2</expected-problems >
186186 <expected-linenumbers >3,8</expected-linenumbers >
187187 <expected-messages >
188- <message >This if statement can be replaced by `return !{condition} && {thenBranch};`</message >
189- <message >This if statement can be replaced by `return !{condition} && {thenBranch};`</message >
188+ <message >This if statement can be replaced by `return !{condition} || {thenBranch};`</message >
189+ <message >This if statement can be replaced by `return !{condition} || {thenBranch};`</message >
190190 </expected-messages >
191191 <code ><![CDATA[
192192 public class Foo {
@@ -248,7 +248,7 @@ public class SimplifyBooleanReturns {
248248 <expected-problems >1</expected-problems >
249249 <expected-linenumbers >6</expected-linenumbers >
250250 <expected-messages >
251- <message >This if statement can be replaced by `return !{condition} && {thenBranch};`</message >
251+ <message >This if statement can be replaced by `return !{condition} || {thenBranch};`</message >
252252 </expected-messages >
253253 <code ><![CDATA[
254254 public class Foo {
@@ -265,7 +265,7 @@ public class SimplifyBooleanReturns {
265265 }
266266 ]]> </code >
267267 </test-code >
268-
268+
269269 <test-code >
270270 <description >[java] SimplifyBooleanReturns should consider literal expression #3852</description >
271271 <expected-problems >1</expected-problems >
@@ -282,4 +282,31 @@ class Tester {
282282}
283283]]> </code >
284284 </test-code >
285+
286+ <test-code >
287+ <description > [java] SimplifyBooleanReturns - wrong suggested solution #4763 </description >
288+ <expected-problems >2</expected-problems >
289+ <expected-messages >
290+ <message >This if statement can be replaced by `return !{condition} && {elseBranch};`</message >
291+ <message >This if statement can be replaced by `return !{condition} && {elseBranch};`</message >
292+ </expected-messages >
293+ <code ><![CDATA[
294+ public class Foo {
295+
296+ public boolean foo(Object a) {
297+ if (a == null) {
298+ return false;
299+ }
300+ return "FOO".equals(a.toString());
301+ }
302+
303+ public boolean bar(String stringA, String stringB) {
304+ if (StringUtils.isAnyBlank(stringA, stringB)) {
305+ return false;
306+ }
307+ return Objects.equals(stringA, stringB);
308+ }
309+ }
310+ ]]> </code >
311+ </test-code >
285312</test-data >
0 commit comments