Could unused flag unused function arguments?
e.g.
func hello(v int) {
println(1)
}
// complains that 'v' is not used.
c.f. https://github.com/coreos/etcd/issues/8068
And thanks for the great tool!
This is an inherently incorrect science, and false positives are likely. I believe this was discarded for unused on purpose. I've written unparam for this, which does an okay job.
What mvdan said.
I know that this issue has been closed for over a year now, and that the official response is "Just use unparam!", but I would like to add some input, as a heavy user of megacheck.
Unused parameters often occur during a refactoring/rapid prototyping. Often, they mask bugs, that will only be discovered at test time (or even production). I would assume that a tool called unused finds unused parameters as well, even if it's behind a flag like -exported, but it doesn't. At all. I already have four tools that I use on every project (six, if you count megacheck as three tools). Adding another one for a feature that unused is missing doesn't sound right.
I don't mean any disrespect towards @mvdan, but I really think this should be a part of unused.
I'll reconsider it for the rewrite of unused, although I'd be inclined to limit it to unexported functions only.
@ainar-g 5 linters isn’t a problem: you can use gometalinter or similar tool: it makes running of even dozens of linters easy. And they will run in parallel by these tools.
Most helpful comment
This is an inherently incorrect science, and false positives are likely. I believe this was discarded for
unusedon purpose. I've writtenunparamfor this, which does an okay job.