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

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

The newest version!

A couple Collection methods can be called with arguments of an incorrect type, but doing so is pointless and likely the result of using the wrong argument. This rule will raise an issue when the type of the argument to List.contains or List.remove is unrelated to the type used for the list declaration.

Noncompliant Code Example

List<String> list = new ArrayList<String>();
Integer integer = Integer.valueOf(1);

if (list.contains(integer)) {  // Noncompliant. Always false.
  list.remove(integer); // Noncompliant. list.add(iger) doesn't compile, so this will always return false
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy