Reports the cases in which a variable is redundant as its value is never used after its assignment.

If the variable is not used, it's better to remove it 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++;
  }