Back to all rules
What this rule checks
Uses a for-each loop
Configuration
When off, this rule is excluded from pipeline runs. Changes apply immediately.
Code Examples
PASS — this code satisfies the rule
float[] ys = {100, 200, 300};

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

void draw() {
  background(255);
  for (int i = 0; i < ys.length; i++) {
    ellipse(200, ys[i], 30, 30);
  }
}
FAIL — this code triggers the rule
float[] ys = {100, 200, 300};

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

void draw() {
  background(255);
  for (float y : ys) {  // a for-each loop
    ellipse(200, y, 30, 30);
  }
}
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.HasForEachLoopRule
Message template For-each loop is used.