Back to all rules
What this rule checks
Uses an explicit type cast
Configuration
When off, this rule is excluded from pipeline runs. Changes apply immediately.
Code Examples
PASS — this code satisfies the rule
void setup() {
  size(400, 400);
}

void draw() {
  background(255);
  int roll = floor(random(1, 7));  // floor() rounds down to a whole number
  fill(0);
  text("You rolled " + roll, 150, 200);
}
FAIL — this code triggers the rule
void setup() {
  size(400, 400);
}

void draw() {
  background(255);
  int roll = (int) random(1, 7);  // an explicit (int) cast
  fill(0);
  text("You rolled " + roll, 150, 200);
}
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.HasCastRule
Message template Explicit type cast used.