-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Go Report Card #217
Comments
Hmm, looks like almost all of the issues in the repo could be found with the golint tool. We should get in the habit of running that. |
Should we create a |
Yeah, I'd be in favor of auto-running some form of linting, but I'd like to investigate if the linting rules are configurable before we start failing builds. There are a few things turned up by the linter that don't seem important to me, such as:
|
Heh, and this one:
|
I am very easygoing with these things, I can definitely live with the silly ones if it gives us a standardised and well-supported way to check for more interesting things. |
IMHO I am not really about skipping these lint errors, it's pretty handy for writing idiomatic golang code ^.^ Also it might be required if you decide to add it at awesome-go list |
Commit 1: Enable lint check for comments Part of #217. Follow up from #1982 and #2018. A subsequent commit will fix the ci failure. Commit 2: Address all comment-related linter errors. This change addresses all comment-related linter errors by doing the following: - Add comments to exported symbols - Make some exported symbols private - Recommend via TODOs that some exported symbols should should move or be removed This PR does not: - Modify, move, or remove any code - Modify existing comments Signed-off-by: Andrew Seigner <siggy@buoyant.io>
`ineffassign` detects ineffectual assignments in Go code. This change introduces a `bin/ineffassign` into ci, and fixes 4 ineffectual assignments caught by ineffassign. Also perform a one-time gofmt cleanup: - `gofmt -s -w controller/` - `gofmt -s -w pkg/` Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
`ineffassign` detects ineffectual assignments in Go code. This change introduces a `bin/ineffassign` into ci, and fixes 4 ineffectual assignments caught by ineffassign. Also perform a one-time gofmt cleanup: - `gofmt -s -w controller/` - `gofmt -s -w pkg/` Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
`golangci-lint` performs numerous checks on Go code, including golint, ineffassign, govet, and gofmt. This change modifies `bin/lint` to use `golangci-lint`, and replaces usage of golint and govet. Also perform a one-time gofmt cleanup: - `gofmt -s -w controller/` - `gofmt -s -w pkg/` Part of #217
`golangci-lint` performs numerous checks on Go code, including golint, ineffassign, govet, and gofmt. This change modifies `bin/lint` to use `golangci-lint`, and replaces usage of golint and govet. Also perform a one-time gofmt cleanup: - `gofmt -s -w controller/` - `gofmt -s -w pkg/` Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
`golangci-lint` performs numerous checks on Go code, including golint, ineffassign, govet, and gofmt. This change modifies `bin/lint` to use `golangci-lint`, and replaces usage of golint and govet. Also perform a one-time gofmt cleanup: - `gofmt -s -w controller/` - `gofmt -s -w pkg/` Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
Taking this a bit further, #2284 introduced a .golangci.yml file, which specifies which golangci-lint checkers to run. To help improve the codebase further, we should work towards reducing the number of checkers in the
|
gosimple is a Go linter that specializes in simplifying code Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
gosimple is a Go linter that specializes in simplifying code Also fix one spelling error in `cred_test.go` Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
gosimple is a Go linter that specializes in simplifying code Also fix one spelling error in `cred_test.go` Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
`unused` checks Go code for unused constants, variables, functions, and types. Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
`varcheck` finds unused global variables and constants. Our repo was already passing so no fixes needed. Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
`deadcode` finds unused code. `varcheck` finds unused global variables and constants. Our repo was already passing both linters so no fixes needed. Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
Enables the following linters: - `deadcode` finds unused code. - `depguard` checks if package imports are in a list of acceptable packages. - `misspell` finds commonly misspelled English words in comments. - `nakedret` finds naked returns in functions greater than a specified function length. - `varcheck` finds unused global variables and constants. Our repo was already passing these linters so no fixes needed. Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
Enables the following linters: - `deadcode` finds unused code. - `depguard` checks if package imports are in a list of acceptable packages. - `misspell` finds commonly misspelled English words in comments. - `nakedret` finds naked returns in functions greater than a specified function length. - `varcheck` finds unused global variables and constants. Our repo was already passing these linters so no fixes needed. Also explicitly list all linters enabled by default, for reference. Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
Enables the following linters: - `deadcode` finds unused code. - `depguard` checks if package imports are in a list of acceptable packages. - `misspell` finds commonly misspelled English words in comments. - `nakedret` finds naked returns in functions greater than a specified function length. - `varcheck` finds unused global variables and constants. Our repo was already passing these linters so no fixes needed. Also explicitly list all linters enabled by default, for reference. Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
goimports checks import lines, adding missing ones and removing unreferenced ones: https://godoc.org/golang.org/x/tools/cmd/goimports It also requires named imports for packages whose import paths don't match their package names: - golang/go#28428 - https://go-review.googlesource.com/c/tools/+/145699/ Also standardized named imports of common Kubernetes packaages. Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
goconst finds repeated strings that could be replaced by a constant: https://github.com/jgautheron/goconst Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
interlacer suggests narrower interface types: https://github.com/mvdan/interfacer Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
interfacer suggests narrower interface types: https://github.com/mvdan/interfacer Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
unconvert removes unnecessary type conversions: https://github.com/mdempsky/unconvert Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
unparam reports unused function parameters: https://github.com/mvdan/unparam Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
goconst finds repeated strings that could be replaced by a constant: https://github.com/jgautheron/goconst Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
goimports checks import lines, adding missing ones and removing unreferenced ones: https://godoc.org/golang.org/x/tools/cmd/goimports It also requires named imports for packages whose import paths don't match their package names: - golang/go#28428 - https://go-review.googlesource.com/c/tools/+/145699/ Also standardized named imports of common Kubernetes packaages. Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
goimports checks import lines, adding missing ones and removing unreferenced ones: https://godoc.org/golang.org/x/tools/cmd/goimports It also requires named imports for packages whose import paths don't match their package names: - golang/go#28428 - https://go-review.googlesource.com/c/tools/+/145699/ Also standardized named imports of common Kubernetes packaages. Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
unconvert removes unnecessary type conversions: https://github.com/mdempsky/unconvert Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
interfacer suggests narrower interface types: https://github.com/mvdan/interfacer Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
unparam reports unused function parameters: https://github.com/mvdan/unparam Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
interfacer suggests narrower interface types: https://github.com/mvdan/interfacer Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
unparam reports unused function parameters: https://github.com/mvdan/unparam Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
unparam reports unused function parameters: https://github.com/mvdan/unparam Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
unparam reports unused function parameters: https://github.com/mvdan/unparam Part of #217 Signed-off-by: Andrew Seigner <siggy@buoyant.io>
@siggy this issue doesn't feel particularly actionable at this point (and there's a ton of awesome work that's already been done). WDYT about closing this out and opening up directed issues for what's remaining? |
@grampelberg I'm fine with closing this one. Note that we lost our perfect gofmt score recently: |
I was wondering about that. Thanks! |
We are getting an A+ on Go Report Card, but there is still a lot to improve:
https://goreportcard.com/report/github.com/runconduit/conduithttps://goreportcard.com/report/github.com/linkerd/linkerd2
We should consider these changes, and also add a badge to
README.md
.The text was updated successfully, but these errors were encountered: