Back to all rules
What this rule checks
Reads an element of a user-defined-class array (e.g. balls[0].show())
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 = random(400);
  void show() { ellipse(x, 200, 20, 20); }
}
Ball[] balls = new Ball[2];

void setup() {
  size(400, 400);
  balls[0] = new Ball();
}

void draw() {
  balls[0].show();
}
FAIL — this code triggers the rule
class Ball {
  float x = random(400);
  void show() { ellipse(x, 200, 20, 20); }
}
Ball[] balls = new Ball[2];

void setup() {
  size(400, 400);
  balls[0] = new Ball();  // stored, but never read back
}

void draw() {
  ellipse(200, 200, 20, 20);
}
Overview
Category Topic Arrays
Level Advanced
Type Custom Zita
Priority 3 (1 = highest, 5 = lowest)
Status Active
PMD Configuration
Java class nl.utwente.processing.pmd.rules.ArrayUserUseRule
Message template No element of a user-defined-class array is read.