Why is this an issue?

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:

How to fix it

Code examples

Noncompliant code example

func shouldNotBeEmpty() {  // Noncompliant - method is empty
}

func notImplemented() {  // Noncompliant - method is empty
}

func emptyOnPurpose() {  // Noncompliant - method is empty
}

Compliant solution

func shouldNotBeEmpty() {
  doSomething();
}

func notImplemented() {
  return "", errors.New("notImplemented() cannot be performed because ...")
}

func emptyOnPurpose() {
  // comment explaining why the method is empty
}