Replace referential equality operators with Object equals method invocations when the operands both override Object.equals(Object obj)
MSALUsing == or != compares object references, not the equality of two objects. This modifies code where both sides of a binary operation (== or !=) override Object.equals(Object obj) except when the comparison is within an overridden Object.equals(Object obj) method declaration itself. The resulting transformation must be carefully reviewed since any modifications change the program's semantics. When a class defines its own notion of equality through equals, using reference comparison is almost always a bug that causes logically identical objects to be treated as different.
org. openrewrite. staticanalysis. ReferentialEqualityToObjectEqualsmod run . --recipe= org. openrewrite. staticanalysis. ReferentialEqualityToObjectEqualsInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.