Back to all rules
What this rule checks
Every user-defined class declares its own constructor
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;
  Ball(float startX) { x = startX; }
}
class Paddle {
  float x;
  Paddle(float startX) { x = startX; }
}
Ball b = new Ball(100);
Paddle p = new Paddle(170);

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

void draw() {
  ellipse(b.x, 200, 20, 20);
  rect(p.x, 380, 60, 10);
}
FAIL — this code triggers the rule
class Ball {
  float x;
  Ball(float startX) { x = startX; }
}
class Paddle {
  float x = 170;  // Paddle has no constructor
}
Ball b = new Ball(100);
Paddle p = new Paddle();

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

void draw() {
  ellipse(b.x, 200, 20, 20);
  rect(p.x, 380, 60, 10);
}
Overview
Category Topic Classes
Level Basic
Type Custom Zita
Priority 3 (1 = highest, 5 = lowest)
Status Active
PMD Configuration
Java class nl.utwente.processing.pmd.rules.HasUserDefinedConstructor
Message template A user-defined class does not have an explicit constructor.