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