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

bevy_color: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] #17090

Conversation

LikeLakers2
Copy link
Contributor

@LikeLakers2 LikeLakers2 commented Jan 2, 2025

Objective

Solution

Set the clippy::allow_attributes and clippy::allow_attributes_without_reason lints to deny, and bring bevy_audio in line with the new restrictions.

No code changes have been made - except if a lint that was previously allow(...)'d could be removed via small code changes. For example, unused_variables can be handled by adding a _ to the beginning of a field's name.

Testing

I ran cargo clippy, and received no errors.

@IQuick143 IQuick143 added C-Code-Quality A section of code that is hard to understand or change D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward A-Color Color spaces and color math labels Jan 2, 2025
Comment on lines 219 to 222
#[allow(clippy::excessive_precision)]
#[expect(
clippy::excessive_precision,
reason = "The code with excessive precision was copied from another codebase."
)]
Copy link
Contributor Author

@LikeLakers2 LikeLakers2 Jan 2, 2025

Choose a reason for hiding this comment

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

(Forgot to copy this comment over.)

I'm not really happy with these two lint attributes (this one, and the one shown in the comment below), as there really isn't a reason for the floats to have excessive precision, beyond the code having been copied verbatim from another code-base.

That said, I feel truncating the floats is out-of-scope for this PR, hence me changing the lint attributes to be expect(...).

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say the rationale could be to be consistent with other implementations?
But I agree that truncating the floats is out of scope here, also maybe for documentation purposes (If someone were to use our code as a template and worked with a greater precision. Alternatively you're expressing the intent of multiplying with these precise values, even if it's not going to be achievable with f32's.)

Copy link
Contributor Author

@LikeLakers2 LikeLakers2 Jan 2, 2025

Choose a reason for hiding this comment

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

Hmm. I'm not so sure about that rationale, personally. I don't really know how to explain why, but it just doesn't sit right with me.

I mean, I'm willing to change it to that - reason = "Excessive precision is used here to be consistent with other implementations." - but I'd maybe like a second opinion before I do that.

Copy link
Member

Choose a reason for hiding this comment

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

I like the reason in your last message better!

Copy link
Contributor

@eero-lehtinen eero-lehtinen Jan 2, 2025

Choose a reason for hiding this comment

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

The original source of these numbers is actually https://bottosson.github.io/posts/oklab/#converting-from-linear-srgb-to-oklab.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So should I change the reason to this?

reason = "Excessive precision is used here to be consistent with other implementations."

Or are we still discussing what it should be?

Copy link
Contributor

@eero-lehtinen eero-lehtinen Jan 2, 2025

Choose a reason for hiding this comment

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

I would just truncate. The extra digits don't have a meaning. (Or you could say that the numbers match the reference implementation)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eero-lehtinen I would truncate - but honestly, doing so feels like it'd be out-of-scope for this PR.

Copy link
Contributor

@eero-lehtinen eero-lehtinen Jan 3, 2025

Choose a reason for hiding this comment

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

That reason you suggested or what I said is completely fine. Just ship it.

Copy link
Contributor Author

@LikeLakers2 LikeLakers2 Jan 3, 2025

Choose a reason for hiding this comment

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

Truncated floats are visible at this PR: #17109

I'm not a fan of the truncated floats, as they reduce readability... I would personally just do as I have in this PR, and move the allow to an expect.

But I'll see what Alice/other maintainers say.

Comment on lines 242 to 248
#[allow(clippy::excessive_precision)]
#[expect(
clippy::excessive_precision,
reason = "The code with excessive precision was copied from another codebase."
)]
Copy link
Contributor Author

@LikeLakers2 LikeLakers2 Jan 2, 2025

Choose a reason for hiding this comment

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

Ditto.

@LikeLakers2 LikeLakers2 requested a review from IQuick143 January 2, 2025 13:18
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 3, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 3, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 3, 2025
@LikeLakers2
Copy link
Contributor Author

@alice-i-cecile Requesting this be re-added to the merge queue.

@LikeLakers2 LikeLakers2 changed the title bevy_color: Apply #[deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] bevy_color: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] Jan 4, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 5, 2025
Merged via the queue into bevyengine:main with commit 5b0406c Jan 5, 2025
28 checks passed
@LikeLakers2 LikeLakers2 deleted the lint/deny_allow_and_without_reason/bevy_color branch January 5, 2025 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Color Color spaces and color math C-Code-Quality A section of code that is hard to understand or change D-Straightforward Simple bug fixes and API improvements, docs, test and examples 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.

5 participants