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 clippy warnings for sources #2745

Merged
merged 3 commits into from
Jan 23, 2023

Conversation

bcressey
Copy link
Contributor

Issue number:

Fixes #1776 (finally)

Description of changes:
Fix all clippy warnings for the sources tree, and add coverage to the CI lint checks.

Testing done:
cargo make check-lints passes for three platforms:

  • aws-k8s-1.24
  • vmware-k8s-1.24
  • metal-k8s-1.24

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

Adopt the fixes suggested by clippy in most cases.

Disable pedantic warnings for the update metadata crate after fixing
several. The intent seems to have been to hold the updater code to an
especially high bar, but in practice it creates a higher maintenance
burden when updating Rust, and requires changes in mission-critical
code for merely stylistic reasons.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
Apply snafu annotations to box the error types most often flagged by
the `clippy::result_large_err` lint, which complains whenever the Err
part of a Result is greater than or equal to 128 bytes.

This is most common for errors with several String fields, since each
String occupies 24 bytes.

That includes:
* apiclient::Error
* datastore::Error
* tough:error::Error
* handlebars::RenderError

Also box a few larger types, like `semver::Version`, and use a Vec
instead of an array for `PartitionSet`.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
Signed-off-by: Ben Cressey <bcressey@amazon.com>
Copy link
Contributor

@stmcginnis stmcginnis left a comment

Choose a reason for hiding this comment

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

A lot of files touched, but overall not too bad considering no linting was being performed before.

I tried looking through for any nuanced behavioral changes, but nothing stood out. Looks good to me.

Copy link
Contributor

@zmrow zmrow left a comment

Choose a reason for hiding this comment

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

Thanks!

💎

Copy link
Member

@webern webern left a comment

Choose a reason for hiding this comment

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

Nice, we probably want to merge this asap.

Copy link
Contributor

@yeazelm yeazelm left a comment

Choose a reason for hiding this comment

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

LGTM but I will admit I'm unsure of the Boxing of those errors.

sources/api/thar-be-updates/src/status.rs Show resolved Hide resolved
Copy link
Contributor

@cbgbt cbgbt left a comment

Choose a reason for hiding this comment

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

Nice! 🚀

@bcressey bcressey merged commit c1312ec into bottlerocket-os:develop Jan 23, 2023
@bcressey bcressey deleted the clippy-sources branch January 23, 2023 23:26
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.

build: check clippy and cargo fmt during github actions checks
7 participants