Open timo-abele opened 3 months ago
Thanks for the report! That's indeed a confusing amount of negation best left alone perhaps. 🤔
Also note that a ? b : false
can be simplified to a && b
. So we might want to add that instead.
I also just notice that the current recipe is incorrect, as the method invocation isn't null safe and would end up throwing an NPE. That definitely needs fixing.
Also note that
a ? b : false
can be simplified toa && b
. So we might want to add that instead.
The false
is a simplification on my part, in the original it was an expression. I should have probably used a variable instead of the literal false
in the example.
How are you running OpenRewrite?
I am using the Maven plugin, and my project is a single module project.
What is the smallest, simplest way to reproduce the problem?
This is transformed to
return name == null ? !name.equals(authority.name) : authority.name != null;
if name is null.What did you expect to see?
no change, or negation of the cases instead of the condition:
What did you see instead?
What is the full stack trace of any errors you encountered?
Standard NPE message when name is null