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

org.sonar.l10n.squidjava.rules.squid.StringEqualityComparisonCheck.html Maven / Gradle / Ivy

String literals, just like any other Object, should be compared using the equals() method. Using == and != does not work in general.

The following code:

if (variable == "foo") { /* ... */ }         // Non-Compliant
if (variable != "foo") { /* ... */ }         // Non-Compliant

should be refactored into:

if ("foo".equals(variable)) { /* ... */ }    // Compliant
if (!"foo".equals(variable)) { /* ... */ }   // Compliant




© 2015 - 2025 Weber Informatics LLC | Privacy Policy