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 *most* clippy lints #15906

Merged
merged 2 commits into from
Oct 14, 2024
Merged

Conversation

clarfonthey
Copy link
Contributor

@clarfonthey clarfonthey commented Oct 14, 2024

Objective

Another clippy-lint fix: the goal is so that ci lints actually displays the problems that a contributor caused, and not a bunch of existing stuff in the repo. (when run on nightly)

Solution

This fixes all but the clippy::needless_lifetimes lint, which will result in substantially more fixes and be in other PR(s). I also explicitly allow non_local_definitions since it is not working correctly, but will be fixed.

A few things were manually fixed: for example, some places had an explicitly defined div_ceil function that was used, which is no longer needed since this function is stable on unsigned integers. Also, empty lines in doc comments were handled individually.

Testing

I ran cargo clippy --workspace --all-targets --all-features --fix --allow-staged with the clippy::needless_lifetimes lint marked as allow in Cargo.toml to avoid fixing that too. It now passes with all but the listed lint.

@alice-i-cecile alice-i-cecile added C-Code-Quality A section of code that is hard to understand or change S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it A-Cross-Cutting Impacts the entire engine labels Oct 14, 2024
@@ -587,7 +587,7 @@ impl AssetSources {
AssetSourceId::Name(name) => self
.sources
.get(&name)
.ok_or_else(|| MissingAssetSourceError(AssetSourceId::Name(name))),
.ok_or(MissingAssetSourceError(AssetSourceId::Name(name))),
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the problem with the original code? Now this value is constructed every time instead of only when needed.

Copy link
Contributor Author

@clarfonthey clarfonthey Oct 14, 2024

Choose a reason for hiding this comment

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

It's not actually constructed: since it's just wrapping in enum variants/newtype structs, it's basically as simple as a copy anyway, and adding an extra level of function indirection just makes it harder to optimize.

The clippy lint specifically looks for "trivial" constructions like this, since the amount of text makes it seem like a lot of work is being done, when it's actually not.

Copy link
Contributor

Choose a reason for hiding this comment

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

What a useful lint :)

@BenjaminBrienen BenjaminBrienen added the D-Trivial Nice and easy! A great choice to get started with Bevy label Oct 14, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Oct 14, 2024
Merged via the queue into bevyengine:main with commit e79bc78 Oct 14, 2024
28 checks passed
@clarfonthey clarfonthey deleted the lints-fixes branch October 14, 2024 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Cross-Cutting Impacts the entire engine C-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants