Skip to main content

Command Palette

Search for a command to run...

SonarLint : Unused local variables should be removed

Published
1 min read
SonarLint : Unused local variables should be removed
S

I love learning about technology and sharing that with others

If there are some variables that are usually used by the developers for debugging but later those variables are not used. Those variables should be removed since it is a dead code.It will improve the maintainability and other developers will not wonder where this local variable is used.

Example from sonar lint

Noncompliant Code Example

public int numberOfMinutes(int hours) {
  int seconds = 0;   // seconds is never used
  return hours * 60;
}

Compliant Solution

public int numberOfMinutes(int hours) {
  return hours * 60;
}
35 views

More from this blog

H

hashcodehub

271 posts

Consistent, Passionate and Organized :)