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

Deny the clippy::allow_attributes and clippy::allow_attributes_without_reason lints #17111

Open
8 of 49 tasks
LikeLakers2 opened this issue Jan 3, 2025 · 0 comments
Open
8 of 49 tasks
Labels
A-Cross-Cutting Impacts the entire engine C-Code-Quality A section of code that is hard to understand or change C-Tracking-Issue An issue that collects information about a broad development initiative D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!

Comments

@LikeLakers2
Copy link
Contributor

LikeLakers2 commented Jan 3, 2025

This is a tracking issue for denying the clippy::allow_attributes and clippy::allow_attributes_without_reason lints across all bevy crates.

What are these?

clippy::allow_attributes

This lints against any instances of #[allow(...)], suggesting they be changed to #[expect(...)].

The use case for this is to avoid letting #[allow(...)]s pile up within Bevy's database, especially since #[expect(...)] is now available. By using #![deny(clippy::allow_attributes)], we can remove any instances of #[allow(...)].

Do note that it's not possible to forbid this lint - there are instances where we are forced to #[allow(...)], as the lints may not always be triggered (such as in macros for tuples).

Notably, this does not lint against #![allow(...)] (notice the !), per the lint's description:

This lint only warns outer attributes (#[allow]), as inner attributes (#![allow]) are usually used to enable or disable lints on a global scale.

However, I will make an attempt to look for instances of #![allow(...)] anyways... if I remember.

See also:
https://rust-lang.github.io/rust-clippy/master/index.html#allow_attributes

clippy::allow_attributes_without_reason

This lints against any instances of #[allow(...)] or #[expect(...)] that do not include a reason = "..." field.

This ensures that if an expect or allow is used, it is given a reason - which helps to document why it's there in the first place.

Notably, this does not lint against #[warn(...)] or #[deny(...)].

See also:
https://rust-lang.github.io/rust-clippy/master/index.html#allow_attributes_without_reason

Checklist

PRs marked as drafts in the list below mean that something (i.e. another PR) blocking them. Once the blocking PRs are merged, each applicable PR will be updated to fix any conflicts, and marked as ready to merge.

@alice-i-cecile alice-i-cecile added C-Code-Quality A section of code that is hard to understand or change C-Tracking-Issue An issue that collects information about a broad development initiative S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! A-Cross-Cutting Impacts the entire engine D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels Jan 3, 2025
github-merge-queue bot pushed a commit that referenced this issue Jan 5, 2025
…tributes_without_reason)]` (#17090)

# Objective
- #17111

## 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.
github-merge-queue bot pushed a commit that referenced this issue Jan 5, 2025
…w_attributes_without_reason)]` (#17159)

# Objective
- #17111

## 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
`cargo clippy`, `cargo clippy --package bevy_dev_tools` and cargo test
--package bevy_dev_tools` were run, and no errors were encountered.
(Except for one warning from bevy_sprite, but I plan to fix that when I
get to bevy_sprite)
github-merge-queue bot pushed a commit that referenced this issue Jan 6, 2025
…y::allow_attributes_without_reason)]` attributes to include a reason field pointing to the tracking issue (#17136)

# Objective
Ensure the deny lint attributes added as a result of #17111 point to the
tracking issue.

## Solution
Change all existing instances of:
```rust
#![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)]
```
to
```rust
#![deny(
    clippy::allow_attributes,
    clippy::allow_attributes_without_reason,
    reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
```

## Testing
N/A
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 C-Tracking-Issue An issue that collects information about a broad development initiative D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!
Projects
None yet
Development

No branches or pull requests

2 participants