All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.java.rules.squid.S1157.html Maven / Gradle / Ivy

There is a newer version: 8.6.0.37351
Show newest version

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