A function without results ends with a bare return, which it would do anyway
What it finds
func reset() { ...; return }: a function without results returns when it reaches its closing brace, so a return as its last statement adds nothing.
The return must have no values, be the last statement of the body of a function or function literal without results. The fix deletes it and is safe.
From the rule's source, redundant_return.rs.
package p func reset(m map[string]int) { clear(m) returntx0 reports: this return at the end of a function without results does nothing} func early(m map[string]int) { if m == nil { return } clear(m)} func count(m map[string]int) int { n := len(m) return n} 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:redundant-return" = "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:redundant-return] reason="..."tx0 explain tx0/go:redundant-return shows the same in the terminal. Found a false positive? Report it.