Skip to content

interface-method-limit

Detect interfaces with more than ten methods.

Updated View as Markdown

Default severity: warning

Counts explicit and embedded methods after completing the interface. More than ten suggests an abstraction that may be easier to implement and test when split by responsibility.

Bad

type Service interface {
	Start()
	Stop()
	Pause()
	Resume()
	Reload()
	Status()
	Health()
	Metrics()
	Configure()
	Validate()
	Reset()
}

Good

type Reader interface {
	Read([]byte) (int, error)
}

Configuration

Option Type Default Description
max-methods int 10 Maximum number of methods allowed on an interface, including embedded methods.
[checks.interface-method-limit]
max-methods = 10
Navigation

Type to search…

↑↓ navigate↵ selectEsc close