Use https://staticcheck.io/
I just updated the internal (Google) version of go-github and one of the existing tools flagged some issues that seem reasonable to flag on GitHub.
The tool is staticcheck: https://staticcheck.io/
They look like they have a CLI and GitHub Actions.
Example of the errors it found, on actions_artifacts.go Line 121 there is an unused error value
parsedURL, err := url.Parse(resp.Header.Get("Location"))
return parsedURL, newResponse(resp), nil
@gmlewis and @willnorris curious what you think?
@gmlewis and @willnorris curious what you think?
Cool find, @gauntface ! Can you create a PR to incorporate it into the GitHub action workflow in this repo? Or I'm happy to work on it if you would prefer.
Curiously, it looks like staticcheck might not work yet with Go 1.18 beta:
$ go version
go version devel go1.18-8ff254e30b Thu Dec 9 19:01:08 2021 +0000 linux/amd64
$ staticcheck ./...
-: cannot import "internal/cpu" (unknown iexport format version 2), export data is newer version - update tool (compile)
-: cannot import "internal/goarch" (unknown iexport format version 2), export data is newer version - update tool (compile)
This looks pretty trivial: https://staticcheck.io/docs/running-staticcheck/github-actions/ I can put together a PR after I clean up the violations if there are no objections.
We already run golangci-lint. We can just enable staticcheck there (https://golangci-lint.run/usage/linters/)
apparently we explicitly disable staticcheck in https://github.com/google/go-github/blob/master/.golangci.yml, probably because it was failing at the time. What I will typically do with golangci-lint is check in the initial config with failing checks disabled, then do follow-up commits that fix the failures and re-enable the check. We just never did that follow-up here I guess.
I'll take a stab at cleaning and enabling it later today if no one is working on it.