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 = {}
}