Back to Intellij Community

SuspiciousMethodCalls

java/java-impl/resources/inspectionDescriptions/SuspiciousMethodCalls.html

2025.3-rc-2456 B
Original Source

Reports method calls on parameterized collections, where the actual argument type does not correspond to the collection's elements type.

Example:

List<Integer> list = getListOfElements();
  list.remove(""); // remove is highlighted

In the inspection settings, you can disable warnings for potentially correct code like the following:

public boolean accept(Map<Integer, String> map, Object key) {
    return map.containsKey(key);
  }