Reports assignment values that are not used after the assignment. If the assignment value is unused, it's better to remove the assignment to shorten the code and avoid redundant allocations.

The following cases are reported:

Configure the inspection:

Use the Report redundant initializers option to report redundant initializers:


  int getI() {
    int i = 0; // redundant initialization
    i = 2;
    return i;
  }

Use the Report ++i when may be replaced with (i + 1) option to report the cases when ++i expression may be replaced with i + 1:


  int preInc(int i) {
    int res = i;
    return ++res;
  }

Use the Report i++ when changed value is not used afterwards option to report the cases when the result of i++ expression is not used later:


  int postInc(int i) {
    int res = i;
    return res++;
  }