Redundant operation on empty container
Reports redundant operations on empty collections, maps or arrays.
Iterating, removing elements, sorting, and some other operations on empty collections have no effect and can be removed. Also, they may be a signal of a bug.
Example:
if (numbers.isEmpty()){
//error due to the missed negation
int max = numbers.stream().max(Comparator.naturalOrder()).get();
...
}
New in 2019.1
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023