An interface with a single method is not named after the method with -er
What it finds
type Validation interface { Validate() error }: Go names an interface with one method after the method plus -er, as io.Reader and fmt.Stringer do, so that the name says what a value of it can do. Following the convention lets readers recognize such interfaces at a glance.
Reported are exported interface types with exactly one method and no embedded types whose name does not end in er, or, ar or able, and is not the method name itself.
From the rule's source, single_method_interface_name.rs.
package p type Validation interface {tx0 reports: Validation has the single method Validate Validate() error} type Validator interface { Validate() error} type Closer interface { Close() error} type Store interface { Get(string) string Put(string, string)} type small interface { run()} 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:single-method-interface-name" = "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:single-method-interface-name] reason="..."tx0 explain tx0/go:single-method-interface-name shows the same in the terminal. Found a false positive? Report it.