Reports assignment to, or modification of for statement parameters inside the for loop body. While occasionally intended, this construct can be extremely confusing, and is often the result of a typo.

Assignments in basic for loops without an update statement are not reported. In these cases the assignment is probably intended and can't be easily moved to the update part of the for loop. For example:


  for (int i = 0; i < list.size(); ) {
    if (element.equals(list.get(i))) {
      list.remove(i);
    } else {
      i++; // modification of for loop parameter
    }
  }