Back to all rules
What this rule checks
An attribute of a user-defined class is read somewhere in the sketch (in the class or through an object)
Configuration
When off, this rule is excluded from pipeline runs. Changes apply immediately.
Code Examples
PASS — this code satisfies the rule
class Ball {
  float x;
  void follow() { x = mouseX; }
  void show() { ellipse(x, 200, 20, 20); }
}
Ball b = new Ball();

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

void draw() {
  b.follow();
  b.show();
}
FAIL — this code triggers the rule
class Ball {
  float x;
  void follow() { x = mouseX; }  // x is set but never read
}
Ball b = new Ball();

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

void draw() {
  b.follow();
  ellipse(mouseX, 200, 20, 20);
}
Overview
Category Topic Classes
Level Intermediate
Type Custom Zita
Priority 3 (1 = highest, 5 = lowest)
Status Active
PMD Configuration
Java class nl.utwente.processing.pmd.rules.ClassAttrUseRule
Message template No class method reads one of its own attributes.