Back to all rules
What this rule checks
A for loop updates an array element from its own array (e.g. a[i] = a[i] + 1, a[i] += 5, a[i]++)
Configuration
When off, this rule is excluded from pipeline runs. Changes apply immediately.
Code Examples
PASS — this code satisfies the rule
int[] xs = {1, 2, 3};
void setup() {
  size(400, 400);
}

void draw() {
  background(255);
  for (int i = 0; i < xs.length; i++) { xs[i] = xs[i] + 1; }
}
FAIL — this code triggers the rule
int[] xs = {1, 2, 3};
void setup() {
  size(400, 400);
}

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