Skip to content

Prefer String::equalsToIgnoreCase - "foo".equals("Foo".toLowercase()) -> "foo".equalsToIgnoreCase("Foo") #274

Open
@timo-abele

Description

@timo-abele

What problem are you trying to solve?

Just came across this finding from IntelliJ:

String upperFoo = "FoO"
"foo".equals(upperFoo.toLowercase())

can be

String upperFoo = "FoO"
"foo".equalsToIgnoreCase(upperFoo)

Condition: the first string is all lowercase

Would be nice to have that automated.
I've considered posting this in rewrite-migrate-java, but as there is no "since" in the API I guess it has been around forever and was never a new language feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Recipes Wanted

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions