Back to all rules
What this rule checks
Performs arithmetic on a local variable
Configuration
When off, this rule is excluded from pipeline runs. Changes apply immediately.
Code Examples
PASS — this code satisfies the rule
void setup() {
  size(400, 400);
}

void draw() {
  background(255);
  float d = dist(mouseX, mouseY, 200, 200);
  ellipse(200, 200, d * 2, d * 2);  // arithmetic on the local d
}
FAIL — this code triggers the rule
void setup() {
  size(400, 400);
}

void draw() {
  background(255);
  float d = dist(mouseX, mouseY, 200, 200);
  ellipse(200, 200, d, d);  // d is used, but never in a calculation
}
Overview
Category Topic Variables
Level Basic
Type Custom Zita
Priority 1 (1 = highest, 5 = lowest)
Status Active
PMD Configuration
Java class nl.utwente.processing.pmd.rules.LocalVarArithmeticRule
Message template No arithmetic operations on local variables found.