-
Notifications
You must be signed in to change notification settings - Fork 202
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
move to golangci-lint and address linting issues #242
base: main
Are you sure you want to change the base?
Conversation
Previously, two separate checks "errcheck" and "staticcheck" were used. These are also part of "golangci-lint" [1] metalinter. In addition, "golangci-lint" has a nolint directive [2], which at least "errcheck" did not seem to have. At this point in time, "golangci-lint" bundles 72 linters [3] (of which this project uses two) - so additional check can easily be added. A configuration file was required to suppress false positives regarding determinism stemming from "print" and "fmt" functions. As this project use "go 1.16" some safe linting suggestions have been applied (e.g. related to deprecation of https://pkg.go.dev/io/ioutil). [1] https://golangci-lint.run/ [2] https://golangci-lint.run/usage/false-positives/#nolint-directive [3] https://golangci-lint.run/usage/linters/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I think we should do the same to https://github.com/temporalio/sdk-go then too. It's a bit off to do it one way in our samples but another in the canonical Go SDK project. (some in-progress PRs are already changing from using ioutil, so we may have to wait until after those)
body, err := ioutil.ReadAll(resp.Body) | ||
_ = resp.Body.Close() | ||
defer resp.Body.Close() // nolint:errcheck | ||
body, err := io.ReadAll(resp.Body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should leave this how it was and just change ioutil
to os
. We want to explicitly show we ignore errors and there is no benefit to changing this to a defer here.
|
||
workflowcheck: | ||
@printf $(COLOR) "Run workflow check..." | ||
@go install go.temporal.io/sdk/contrib/tools/workflowcheck | ||
@workflowcheck -show-pos ./... | ||
@workflowcheck -config workflowcheck.config.yaml -show-pos ./... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add this config? Is something triggering it?
What was changed
Previously, two separate checks "errcheck" and "staticcheck" were used. These are also part of "golangci-lint" [1] metalinter.
In addition, "golangci-lint" has a nolint directive [2], which at least "errcheck" did not seem to have.
At this point in time, "golangci-lint" bundles 72 linters [3] (of which this project uses two) - so additional check can easily be added. A configuration file was required to suppress false positives regarding determinism stemming from "print" and "fmt" functions.
As this project use "go 1.16" some safe linting suggestions have been applied (e.g. related to deprecation of https://pkg.go.dev/io/ioutil).
Why?
I wanted to use the nolint directive of golangci-lint to selectively ignore checks, e.g. to ignore an error in
defer
when closing an HTTP response body.At the same time, it seemed to simplify the
Makefile
to use a single "metalinter" instead of two separate linters.Checklist
Tested locally, via:
Not required.