A function has an empty body without a comment that says why
What it finds
func (s *Store) Flush() {}: an empty body may be a method that must exist to satisfy an interface, or work that was never written. A comment inside says which, so readers need not guess, and a body that was meant to be written does not go unnoticed.
Functions and methods with a body that has no statements and no comment are reported. Function declarations without a body, which are implemented elsewhere, are not.
From the rule's source, empty_function.rs.
package p type store struct{} func (store) Flush() {}tx0 reports: Flush has an empty body func (store) Close() { // Nothing to release: the store keeps no handles.} func (store) Len() int { return 0 } Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/go:empty-function" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/go:empty-function] reason="..."tx0 explain tx0/go:empty-function shows the same in the terminal. Found a false positive? Report it.