Back to all rules
What this rule checks
Iterates an array with an index-based for loop (alias of HasArrayIndexForLoop, copied post-Zita)
Configuration
When off, this rule is excluded from pipeline runs. Changes apply immediately.
Code Examples
PASS — this code satisfies the rule
float[] ys = {50, 120, 200, 280};

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

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

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

void draw() {
  background(255);
  ellipse(200, ys[0], 20, 20);  // each element by hand, no loop
  ellipse(200, ys[1], 20, 20);
  ellipse(200, ys[2], 20, 20);
}
Overview
Category Topic Arrays
Level Basic
Type Custom Zita
Priority 1 (1 = highest, 5 = lowest)
Status Active
PMD Configuration
Message template No index-based for loop found for array iteration.