Back to all rules
What this rule checks
Uses else or else-if branching
Configuration
When off, this rule is excluded from pipeline runs. Changes apply immediately.
Code Examples
PASS — this code satisfies the rule
void setup() {
  size(400, 400);
}

void draw() {
  background(255);
  if (mouseX > width / 2) {
    fill(255, 0, 0);
  } else {
    fill(0, 0, 255);
  }
  ellipse(200, 200, 80, 80);
}
FAIL — this code triggers the rule
void setup() {
  size(400, 400);
}

void draw() {
  background(255);
  fill(0, 0, 255);
  if (mouseX > width / 2) {  // no else branch
    fill(255, 0, 0);
  }
  ellipse(200, 200, 80, 80);
}
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.HasNoElseStatementRule
Message template No 'else' statement found in the program.