Back to all rules
What this rule checks
Boolean expressions can be simplified
Configuration
When off, this rule is excluded from pipeline runs. Changes apply immediately.
Code Examples
PASS — this code satisfies the rule
boolean paused = false;
float x = 0;

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

void draw() {
  background(255);
  if (!paused) {
    x = x + 2;
  }
  ellipse(x, 200, 20, 20);
}
FAIL — this code triggers the rule
boolean paused = false;
float x = 0;

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

void draw() {
  background(255);
  if (paused == false) {  // just write !paused
    x = x + 2;
  }
  ellipse(x, 200, 20, 20);
}
Overview
Category Topic Conditionals
Level Intermediate
Type Built-in PMD
Priority 3 (1 = highest, 5 = lowest)
Status Active
PMD Configuration
PMD reference category/java/design.xml/SimplifyBooleanExpressions