Back to all rules
What this rule checks
Control statements use braces
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 (x > width) {
    x = 0;
  }
  ellipse(x, 200, 20, 20);
}
FAIL — this code triggers the rule
float x = 0;

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

void draw() {
  background(255);
  x = x + 2;
  if (x > width) x = 0;  // no curly braces
  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/codestyle.xml/ControlStatementBraces