golangci-lint
golangci-lint copied to clipboard
feat: add go-refcheck linter
Your feature request related to a problem? Please describe.
Add support for go-refcheck: https://github.com/geraldywy/go-refcheck
Does what copyfighter does, but go-refcheck is rewritten using go/analysis https://github.com/jmhodges/copyfighter
Describe the solution you'd like.
Integrate this linter as an option within golangci-lint
Describe alternatives you've considered.
Run it separately
Additional context.
No response
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.
Hello,
I think that is already handled with gocritic https://github.com/go-critic/go-critic
Also, a project without any license is not usable.
Hi,
Thanks for the reply. To my knowledge, not exactly. The closest match I could find was gocritic's hugeParam with a slight difference in that it reports passing of large structs by value in function params as opposed to func receivers which the linter is made for. Do correct me on this I am mistaken.
Also, I am the author of the proposed linter, I can add a license to it if need be.
Maybe you can add a rule or improve a rule in go-critic because it feels very very close to some rules.
go-critic
pretty much support it.
hugeParam
checks any func declarations, methods too (and also supports some common exceptions like String()
):
$ pwd
/tmp/go-refcheck/testdata/src/p
$ gocritic check -enable hugeParam [email protected]=32 p.go
./p.go:28:7: hugeParam: l is heavy (56 bytes); consider passing it by pointer
./p.go:32:7: hugeParam: l is heavy (56 bytes); consider passing it by pointer
./p.go:47:7: hugeParam: m is heavy (64 bytes); consider passing it by pointer
./p.go:61:7: hugeParam: n is heavy (32 bytes); consider passing it by pointer
If desired, you can improve their warning message for methods.
P.S. IMO, go-refcheck
is not the best naming for such check. ref
typically is about reference issues (loop closures, etc.)