Back to all rules
What this rule checks
A for loop writes to an array element indexed by its counter (e.g. a[i] = 10)
Configuration
When off, this rule is excluded from pipeline runs. Changes apply immediately.
Code Examples
PASS — this code satisfies the rule
int[] xs = new int[5];
void setup() {
  size(400, 400);
  for (int i = 0; i < xs.length; i++) { xs[i] = 10; }
}

void draw() {
  background(255);
}
FAIL — this code triggers the rule
int[] xs = new int[5];
void setup() {
  size(400, 400);
  xs[0] = 10;
}

void draw() {
  background(255);
  for (int i = 0; i < xs.length; i++) { println(xs[i]); }
}
Overview
Category Topic Arrays
Level Intermediate
Type Custom Zita
Priority 3 (1 = highest, 5 = lowest)
Status Active
PMD Configuration
Java class nl.utwente.processing.pmd.rules.ArrayLoopUpdateRule
Message template No for loop writes to an array element indexed by its counter (e.g. a[i] = 10).