Back to all rules
What this rule checks
Uses at least two if statements (else-if counts)
Configuration
When off, this rule is excluded from pipeline runs. Changes apply immediately.
Code Examples
PASS — this code satisfies the rule
float x = 200;
float speed = 3;

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

void draw() {
  background(255);
  x = x + speed;
  if (x > width) {
    speed = -3;
  }
  if (x < 0) {
    speed = 3;
  }
  ellipse(x, 200, 20, 20);
}
FAIL — this code triggers the rule
float x = 200;
float speed = 3;

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

void draw() {
  background(255);
  x = x + speed;
  if (x > width) {  // only one if statement
    speed = -3;
  }
  ellipse(x, 200, 20, 20);
}
Overview
Category Topic Conditionals
Level Basic
Type Custom Zita
Priority 3 (1 = highest, 5 = lowest)
Status Active
PMD Configuration
Java class nl.utwente.processing.pmd.rules.HasConditionsRule
Message template Few or no conditional statements found.