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

fix: fix checks URL panic and other issues caught by staticcheck #580

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

benhoyt
Copy link
Contributor

@benhoyt benhoyt commented Feb 28, 2025

This fixes #579, which results in a panic if an HTTP check URL was malformed. Thanks for the report and the test at https://github.com/canonical/tako/pull/24, @alnvdl-work.

This PR also adds staticcheck to the linting, which found this issue, and a few other minor issues. Fix the other issues and add a staticcheck.conf and a GitHub Action to run it. The other issues are mostly not problems, but include:

  • Use of deprecated functions (these are okay, just lint:ignore)
  • Error messages shouldn't end with "."
  • strconv.ParseFloat second arg is not the base (10), so should be 32 or 64. I actually tried to add this check to go vet years ago.
  • Various unused functions and struct fields.
  • time.Now().Sub(t) -> time.Since(t)
  • Use of rand.Seed (deprecated) in tests

Fixes #579

@@ -150,7 +146,7 @@ func (cmd cmdHelp) Execute(args []string) error {
}
if cmd.All {
if len(cmd.Positional.Subs) > 0 {
return fmt.Errorf("help accepts a command, or '--all', but not both.")
return fmt.Errorf("help accepts a command, or '--all', but not both")
Copy link

@alnvdl-work alnvdl-work Feb 28, 2025

Choose a reason for hiding this comment

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

So, in the other repo, this was actually deemed not to be a problem, so I reverted the change there. What is your opinion about this?

checks = [
"inherit",
"-SA5008", # duplicate struct tag (cli/cmd_*.go use this for "choice")
"-ST1012", # error var should have name of the form errFoo

Choose a reason for hiding this comment

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

Out of curiosity, what is the rationale for disabling this one?

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.

HTTP checker fails to verify error returned by http.NewRequestWithContext
2 participants