Reports list.remove(index) calls inside an ascending counted loop. This is suspicious as the list becomes shorter after a remove, and the element after a removed element will not be processed. A simple fix is to decrease the index variable after a removal, but probably removing via an iterator or using the removeIf() method (since Java 8) is a more robust alternative. If you don't expect that remove() will be called more than once in a loop, consider adding a break after it.

Example:


  public static void main(String[] args) {
    process(new ArrayList<>(
      Arrays.asList("1", "2", "|", "3", "4")));
  }

  static void process(List<String> list) {
    for (int i = 0; i < list.size(); i++) {
      if (list.get(i).equals("|")) {
        list.remove(i);
        continue;
      }
      System.out.println(list.get(i));
    }
  }

Here we could expect that '1 2 3 4' will be printed, but 3 will be skipped in the output.

New in 2018.2