Back to all rules
What this rule checks
No redundant operations
Configuration
When off, this rule is excluded from pipeline runs. Changes apply immediately.
Code Examples
PASS — this code satisfies the rule
float ballX = 0;
float speed = 2;

void setup() {
  size(400, 400);
}

void draw() {
  background(255);
  ballX = ballX + speed;
  ellipse(ballX, 200, 30, 30);
}
FAIL — this code triggers the rule
float ballX = 0;
float speed = 2;

void setup() {
  size(400, 400);
}

void draw() {
  background(255);
  ballX = ballX;  // assigns ballX to itself: the ball never moves
  ellipse(ballX, 200, 30, 30);
}
Overview
Category Topic Variables
Level Advanced
Type Built-in PMD
Priority 3 (1 = highest, 5 = lowest)
Status Active
PMD Configuration
PMD reference category/java/errorprone.xml/IdempotentOperations