Back to all rules
What this rule checks
No unused local variables
Configuration
When off, this rule is excluded from pipeline runs. Changes apply immediately.
Code Examples
PASS — this code satisfies the rule
void draw() {
  int x = 100;
  ellipse(x, 200, 50, 50);
}
FAIL — this code triggers the rule
void draw() {
  int x = 100;
  ellipse(200, 200, 50, 50);
  // x is declared but never used
}
Overview
Category Topic Variables
Level Advanced
Type Built-in PMD
Priority 3 (1 = highest, 5 = lowest)
Status Active
PMD Configuration
PMD reference category/java/bestpractices.xml/UnusedLocalVariable