Back to all rules
What this rule checks
At least one user-defined class has an explicit 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; }
}
Ball b = new Ball(100);

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

void draw() {
  ellipse(b.x, 200, 20, 20);
}
FAIL — this code triggers the rule
class Ball {
  float x = 100;  // no constructor
}
Ball b = new Ball();

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

void draw() {
  ellipse(b.x, 200, 20, 20);
}
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.HasClassWithConstructorRule
Message template Classes should have explicit constructors