Back to all rules
What this rule checks
Uses a switch statement
Configuration
When off, this rule is excluded from pipeline runs. Changes apply immediately.
Code Examples
PASS — this code satisfies the rule
int mode = 1;

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

void draw() {
  if (mode == 1) {
    background(255, 0, 0);
  } else if (mode == 2) {
    background(0, 0, 255);
  } else {
    background(255);
  }
}

void keyPressed() {
  mode = mode + 1;
}
FAIL — this code triggers the rule
int mode = 1;

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

void draw() {
  switch (mode) {
    case 1:
      background(255, 0, 0);
      break;
    case 2:
      background(0, 0, 255);
      break;
    default:
      background(255);
  }
}

void keyPressed() {
  mode = mode + 1;
}
Overview
Category Out of Scope
Type Custom Zita
Priority 3 (1 = highest, 5 = lowest)
Status Active
PMD Configuration
Java class nl.utwente.processing.pmd.rules.HasSwitchRule
Message template Switch statement or expression used.