Back to all rules
What this rule checks
Has a top-level function or a class method that both takes a parameter and returns a value (composed post-Zita from Marker-only rule 29 + Marker-only rule 30)
Configuration
When off, this rule is excluded from pipeline runs. Changes apply immediately.
Code Examples
PASS — this code satisfies the rule
float x = 0;

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

void draw() {
  background(255);
  x = x + 2;
  if (isOffScreen(x)) {
    x = 0;
  }
  ellipse(x, 200, 20, 20);
}

boolean isOffScreen(float pos) {
  return pos > width;
}
FAIL — this code triggers the rule
float x = 0;

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

void draw() {
  background(255);
  x = x + 2;
  if (isOffScreen()) {
    x = 0;
  }
  ellipse(x, 200, 20, 20);
}

boolean isOffScreen() {  // returns a value but takes no parameter
  return x > width;
}
Overview
Category Topic Functions
Level Advanced
Type Custom Zita
Priority 3 (1 = highest, 5 = lowest)
Status Active
PMD Configuration
Message template No function or method both takes a parameter and returns a value.