org.sonar.l10n.java.rules.squid.S1157.html Maven / Gradle / Ivy
Using toLowerCase()
or toUpperCase()
to make case insensitive comparisons is inefficient because it requires the creation of temporary, intermediate String
objects.
The following code:
boolean result1 = foo.toUpperCase().equals(bar); // Noncompliant
boolean result2 = foo.equals(bar.toUpperCase()); // Noncompliant
boolean result3 = foo.toLowerCase().equals(bar.LowerCase()); // Noncompliant
should be refactored into:
boolean result = foo.equalsIgnoreCase(bar); // Compliant
© 2015 - 2025 Weber Informatics LLC | Privacy Policy