Unused local variables should be removed

  • squid : S1481

If a local variable is declared but not used in the program, it can be considered dead code and should therefore be removed. This will improve maintainability because developers will not wonder what the variable is used for.

Noncompliant Code Example

public int compute(int a){
  int foo = 6;
  return a * 4;
}

Compliant Solution

public int compute(int a){
  return a * 4;
}
Close