java:S1157 .toUpperCase and .equalsIgnoreCase


The rule states the following, only the case for result3 seems to be functional equivalent.

Noncompliant Code Example
boolean result1 = foo.toUpperCase().equals(bar); // Noncompliant
boolean result2 = foo.equals(bar.toUpperCase()); // Noncompliant
boolean result3 = foo.toLowerCase().equals(bar.LowerCase()); // Noncompliant

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

1 Like

Thanks for your feedback, ticket SONARJAVA-3649 created.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.