-
Notifications
You must be signed in to change notification settings - Fork 98
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
Some small fixes for staticcheck #1565
Some small fixes for staticcheck #1565
Conversation
045b89a
to
ef6f02c
Compare
@@ -59,7 +59,7 @@ func runSocket(args []string) error { | |||
|
|||
// Wait forever | |||
sig := make(chan os.Signal, 1) | |||
signal.Notify(sig, os.Interrupt, os.Kill, syscall.Signal(15)) | |||
signal.Notify(sig, os.Interrupt, syscall.SIGTERM, syscall.Signal(15)) |
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.
os.Kill cannot be trapped (did you mean syscall.SIGTERM?)
@@ -118,7 +118,7 @@ func WithDebugLogging() FlattenOpts { | |||
// re-writing arrays into maps, and for filtering. See "Query | |||
// Specification" for docs. | |||
func WithQuery(q []string) FlattenOpts { | |||
if q == nil || len(q) == 0 || (len(q) == 1 && q[0] == "") { | |||
if len(q) == 0 || (len(q) == 1 && q[0] == "") { |
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.
should omit nil check; len() for []string is defined as zero
"tuf-server.example.com": resolution{ips: []string{"34.149.84.181"}, err: nil}, | ||
"google.com": resolution{ips: []string{"2620:149:af0::10", "17.253.144.10"}, err: nil}, | ||
"apple.com": resolution{ips: []string{"2607:f8b0:4009:808::200e", "142.250.65.206"}, err: nil}, | ||
"kolide-server.example.com": {ips: []string{"2607:f8b0:4009:808::200e", "142.250.65.206"}, 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.
simplifycompositelit
@@ -20,8 +19,6 @@ import ( | |||
func TestTufReleaseVersionTable(t *testing.T) { | |||
t.Parallel() | |||
|
|||
rand.Seed(time.Now().UnixNano()) |
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.
rand.Seed has been deprecated since Go 1.20 and an alternative has been available since Go 1.0: As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New(NewSource(seed)) to obtain a local random generator.
ErrorControlNormal = "normal" | ||
ErrorControlCritical = "critical" | ||
ErrorControlNormal ErrorControlType = "normal" | ||
ErrorControlCritical ErrorControlType = "critical" | ||
) | ||
|
||
type StartType string |
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 can't make this same fix for the StartType
constants below because it causes a compilation error (!!) and I didn't want to make too many changes in this PR
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.
Reasonable! As long as it's not nolint
we can fix it in a followup
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.
Thank you for this!
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.
🔥 thank you!
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.
yay
ErrorControlNormal = "normal" | ||
ErrorControlCritical = "critical" | ||
ErrorControlNormal ErrorControlType = "normal" | ||
ErrorControlCritical ErrorControlType = "critical" | ||
) | ||
|
||
type StartType string |
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.
Reasonable! As long as it's not nolint
we can fix it in a followup
Addresses some, but not all, occurrences of staticcheck violations in the following categories:
Code simplifications:
Misuse of standard library:
Dubious code constructs that have a high probability of being wrong:
Stylistic issues: