-
Notifications
You must be signed in to change notification settings - Fork 95
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
nogo: add missing go vet checks #6218
Conversation
Change log: https://tip.golang.org/doc/go1.22 Since musl toolchain in --config=static is not compatible with the latest Go version, disable static workflows for now. Issue is reported in uber/hermetic_cc_toolchain#171
Remove usage of `vet = True` in nogo definition. It's simply a shortcut attribute to appends some additional analyzers to the nogo binary. Instead, run `go tool vet help` and copy all listed analyzers in the doc to our analyzer. This list is more up-to-date than the one in current rules_go. Fix 2 vet issues found with new analyzers added: - Misuse of unbuffered os.Signal channel as argument to signal.Notify The channel should be buffered with minimal size of 1. - time.Since should not be used in defer statement See golang/go#60048 for more information
based on #6217 |
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.
A couple small things but mostly looks good
ead5a49
to
5f640d7
Compare
tools/metrics/grafana/grafana.go
Outdated
@@ -174,9 +174,13 @@ func exportNormalizedDashboard(d *Dashboard) error { | |||
return err | |||
} | |||
outPath := filepath.Join(dashboardsDir, fileName) | |||
outFile, err := os.ReadFile(outPath) | |||
if err != nil { |
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.
nit: the original intent was to write the file if it did not exist or if it contains different bytes
if err != nil { | |
if err != nil && !os.IsNotExist(err) { |
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.
In case the file does not exist, the byte slice content return will be nil and after the bytes.Equal
result 🤔
I guess we want to write when the previous file was not there (i.e. on the first time exporting)?
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 sent a fix that would handle the nil content case.
Remove usage of
vet = True
in nogo definition. It's simply a shortcutattribute to appends some additional analyzers to the nogo binary.
Instead, run
go tool vet help
and copy all listed analyzers in the docto our analyzer. This list is more up-to-date than the one in current
rules_go.
Fix 2 new vet issues found with new analyzers added:
Misuse of unbuffered os.Signal channel as argument to signal.Notify
The channel should be buffered with minimal size of 1.
time.Since should not be used in defer statement
See cmd/vet: time.Since should not be used in defer statement golang/go#60048 for more information
Also re-enabled
nilness
shows a range of issues in our code base that comparesnil == nil
,non-nil != nil
. Fixed those issues in a separate commit for easier review.