Method body is an empty block

ID

scala.maintainability.empty_function_body

Severity

low

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Dead Code

Language

Scala

Description

Reports a def whose body is an empty block, so calling it has no effect and returns Unit.

Rationale

An empty body reads as unfinished work. A caller cannot tell whether the method is a deliberate no-op, an override that intentionally does nothing, or a stub whose implementation was lost in a refactor - and if it is a stub, every call site quietly does nothing while the code still compiles and the tests still pass.

The following code illustrates the pattern detected by this rule:

class EmptyFunctionBody {
  // FLAGGED: Method body is an empty block
  def flush(): Unit = {}
}

Remediation

Implement the method, or remove it along with its callers if it is genuinely not needed. When an empty override is deliberate - a default hook, a no-op strategy - state that in the body with () plus a comment saying why, so the emptiness reads as a decision.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved