Some functions accept varargs but expect an even number of arguments. Check these calls where possible.
(Well, that list ended up a lot shorter than expected. Well, that list is getting depressingly long.)
https://godoc.org/github.com/go-kit/kit/log#Logger does too, if suggestions related to #461 are good here
Same for https://github.com/grpc/grpc-go/blob/master/Documentation/grpc-metadata.md#creating-a-new-metadata
Edit: metadata.Pairsand metadata.AppendToOutgoingContext
go.uber.org/zap has a SugaredLogger type that’s similar to go-kit’s logger.
Can we make this configurable? At work we have private packages that have this same pattern
Don't forget about strings.NewReplacer.
@frioux I do have vague plans for custom rule sets that users can write, but nothing has materialized yet and it would be a future feature that I might add to staticcheck.
We can probably detect some of these functions automatically, if we detect the following pattern in functions:
if len(args)%2 != 0 {
panic("some message")
}
(plus the expected constraints: args must be the unmodified vararg, all paths through the function must hit the condition)
I built this, but it's painfully slow:
https://godoc.org/github.com/ZipRecruiter/splinter/pairs
On Tue, May 19, 2020, 11:02 PM Dominik Honnef notifications@github.com
wrote:
We can probably detect some of these functions automatically, if we detect
the following pattern in functions:if len(args)%2 != 0 {
panic("some message")
}(plus the expected constraints: args must be the unmodified vararg, all
paths through the function must hit the condition)—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/dominikh/go-tools/issues/464#issuecomment-631255754,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAB7Y4QJQ4ADDOTQZ33GGLRSNW5RANCNFSM4HKWTWAQ
.