unparam icon indicating copy to clipboard operation
unparam copied to clipboard

False positive for functions in map

Open mholt opened this issue 1 year ago • 1 comments

var cmdMap = map[string]func() error{
	"cmd1": func() error { // OK
		return errors.New("foo")
	},
	"cmd2": func() error { // false positive
		return nil
	},
}

In this code, I think it's pretty clear cmd2 needs to have an error return because the signature of the map value mandates it, but it gets flagged as "result 0 (error) is always nil".

mholt avatar Aug 29 '24 21:08 mholt

Possibly a duplicate of #40

This really needs to be fixed. Putting nolint everywhere is defeating the purpose, so I will probably be uninstalling the linter.

mholt avatar Jan 01 '25 17:01 mholt