Class UnusedLocalVariableCheck

All Implemented Interfaces:
Configurable, Contextualizable

Checks that a local variable is declared and/or assigned, but not used. Doesn't support pattern variables yet. Doesn't check array components as array components are classified as different kind of variables by JLS.
  • Property allowUnnamedVariables - Allow variables named with a single underscore (known as unnamed variables in Java 21+). Type is boolean. Default value is true.

Parent is com.puppycrawl.tools.checkstyle.TreeWalker

Violation Message Keys:

  • unused.local.var
  • unused.named.local.var
Since:
9.3