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

The 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);             // Non-Compliant
boolean result2 = foo.equals(bar.toUpperCase());             // Non-Compliant
boolean result3 = foo.toLowerCase().equals(bar.LowerCase()); // Non-Compliant

should be refactored into:

boolean result = foo.equalsIgnoreCase(bar);                  // Compliant




© 2015 - 2025 Weber Informatics LLC | Privacy Policy