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

Minor cleanup #3292

Merged
merged 5 commits into from
Aug 11, 2024
Merged

Minor cleanup #3292

merged 5 commits into from
Aug 11, 2024

Conversation

apostasie
Copy link
Contributor

@apostasie apostasie commented Aug 11, 2024

A handful of maintenance changes

  • use http.ErrSchemeMismatch instead of our ad-hoc plain text parsing method now that go exposes it
  • move away from abandoned mapstructure dependency (https://gist.github.com/mitchellh/90029601268e59a29e64e55bab1c5bdc) and replace it by blessed fork
  • get rid of naked returns (naked-rets are true evil) and enable linter
  • remove contains method and use go slices.Contains (go 1.21)
  • move projectloader.Load to testutil

@@ -10,7 +10,7 @@ linters:
- govet
- ineffassign
- misspell
# - nakedret
- nakedret
Copy link
Member

Choose a reason for hiding this comment

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

What is the benefit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a matter of choice, and deciding if we want to allow naked returns or not.

I (clearly) think we should not.

Naked returns IMHO are a very contentious language feature (golang/go#21291 ).

They make code harder to read and understand, more confusing to newcomers (have to look back to the function signature to figure out what is being returned), and they are likely error prone, for example when err gets shadowed (named returns are already problematic in that regard when used with defer).

We only had two in the codebase.
Adding the linter will ensure we won't get any in the future.

WDYT?

Signed-off-by: apostasie <spam_blackhole@farcloser.world>
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
@apostasie apostasie marked this pull request as ready for review August 11, 2024 16:13
@AkihiroSuda AkihiroSuda added this to the v2.0.0 milestone Aug 11, 2024
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda AkihiroSuda merged commit 4588ee7 into containerd:main Aug 11, 2024
19 checks passed
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.

2 participants