Skip to content

bevy_reflect: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] #17092

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

Conversation

LikeLakers2
Copy link
Contributor

@LikeLakers2 LikeLakers2 commented Jan 2, 2025

Objective

We want to deny the following lints:

  • clippy::allow_attributes - Because there's no reason to #[allow(...)] an attribute if it wouldn't lint against anything; you should always use #[expect(...)]
  • clippy::allow_attributes_without_reason - Because documenting the reason for allowing/expecting a lint is always good

Solution

Set the clippy::allow_attributes and clippy::allow_attributes_without_reason lints to deny, and bring bevy_reflect 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 A-Reflection Runtime information about types D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 2, 2025
#![allow(unused_qualifications)]
#![expect(
unused_qualifications,
reason = "Temporary workaround for impl_reflect!(Option/Result false-positive"
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand the parenthesis here

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I'd like to clean this up before merging. @MrGVSV, what did you mean here?

Copy link
Member

Choose a reason for hiding this comment

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

This actually wasn't me. Looks like it was added in #14828. My guess is that since Option and Result are in the prelude, their full qualification is unnecessary, but we rely on it for generating the TypePath impl within impl_reflect!.

@@ -199,7 +199,7 @@ mod tests {

#[reflect_trait]
trait Enemy: Reflect + Debug {
#[allow(dead_code, reason = "this method is purely for testing purposes")]
#[expect(dead_code, reason = "this method is purely for testing purposes")]
Copy link
Contributor

Choose a reason for hiding this comment

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

This method may become used during said testing, and it would be annoying if this generated a warning during testing.

Copy link
Member

Choose a reason for hiding this comment

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

I think I prefer leaving this as an expect for now.

@alice-i-cecile alice-i-cecile added S-Needs-Help The author needs help finishing this PR. and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 2, 2025
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Doesn't make things worse; no reason to block on fixing that weird comment.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 3, 2025
Merged via the queue into bevyengine:main with commit 120b733 Jan 3, 2025
28 checks passed
@LikeLakers2 LikeLakers2 deleted the lint/deny_allow_and_without_reason/bevy_reflect branch January 3, 2025 23:07
@LikeLakers2 LikeLakers2 changed the title bevy_reflect: Apply #[deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] bevy_reflect: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] Jan 4, 2025
mrchantey pushed a commit to mrchantey/bevy that referenced this pull request Feb 4, 2025
…ttributes_without_reason)]` (bevyengine#17092)

# Objective
We want to deny the following lints:
* `clippy::allow_attributes` - Because there's no reason to
`#[allow(...)]` an attribute if it wouldn't lint against anything; you
should always use `#[expect(...)]`
* `clippy::allow_attributes_without_reason` - Because documenting the
reason for allowing/expecting a lint is always good

## Solution
Set the `clippy::allow_attributes` and
`clippy::allow_attributes_without_reason` lints to `deny`, and bring
`bevy_reflect` 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Reflection Runtime information about types 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-Help The author needs help finishing this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants