Back to all rules
What this rule checks
An array is initialized entirely with hardcoded literal or constructor values
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);
}

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

void draw() {
  background(255);
  ellipse(xs[0], 50, 5, 5);
}
Overview
Category PDPS
Type Custom Zita
Priority 3 (1 = highest, 5 = lowest)
Status Active
PMD Configuration
Java class nl.utwente.processing.pmd.rules.HardcodedArrayRule
Message template Array initializer uses only hardcoded values.