Empty block statements should not be used in conditional statements

  • EMPTY_BLOCK
  • Code Quality
  • Low
  • No tags

This rule applies when block statement of conditional statements is empty.

For code readability and maintainability, empty block statement in if, else, and else if is not recommended.

It is recommended to remove empty blocks or add comments (e.g. TODO et al.) for understanding the code.

Noncompliant Code Example

View with compliant examples side by side
// EMPTY_BLOCK alarm because empty block is used as if branch.

if (foo) {
}

Compliant Code Example

View with noncompliant examples side by side
// Remove alarm by adding TODO comment.

if (foo) {
    // TODO: Not implemented yet
}

Version

This rule was introduced in DeepScan 1.0.0-alpha.

Was this documentation helpful?