Skip to content
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

Enable revive's defer rule in golangci-lint #2070

Merged
merged 6 commits into from
Jan 28, 2025

Conversation

RebeccaMahany
Copy link
Contributor

Enables https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#defer in our ruleset, and fixes existing violations.

@RebeccaMahany RebeccaMahany marked this pull request as ready for review January 28, 2025 17:39
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
cmd, err := browserLauncher(ctx, actionUri)
cmd, err := browserLauncher(context.TODO(), actionUri)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't move a timeout with a defer cancel to a new function because then calling cmd.Start at the end of that function makes it fail immediately. I don't think the timeout is super meaningful here so I've removed it rather than adding a lint exception.

Copy link
Contributor

@zackattack01 zackattack01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Copy link
Contributor

@James-Pickett James-Pickett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this looks like a pretty solid improvement.

@RebeccaMahany RebeccaMahany added this pull request to the merge queue Jan 28, 2025
Merged via the queue into kolide:main with commit 988d072 Jan 28, 2025
32 checks passed
@RebeccaMahany RebeccaMahany deleted the becca/revive-defer branch January 28, 2025 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants