An empty function is generally considered bad practice and can lead to confusion, readability, and maintenance issues. Empty functions bring no functionality and are misleading to others as they might think the function implementation fulfills a specific and identified requirement.
There are several reasons for a function not to have a body:
public function shouldNotBeEmpty():void { // Noncompliant - method is empty
}
public function notImplemented():void { // Noncompliant - method is empty
}
public override function emptyOnPurpose():void { // Noncompliant - method is empty
}
public function shouldNotBeEmpty():void {
doSomething();
}
public function notImplemented():void {
throw new Error("notImplemented() cannot be performed because ...");
}
public override function emptyOnPurpose():void {
// comment explaining why the method is empty
}