Skip to content

Add missing_reflect lint#137

Closed
BD103 wants to merge 40 commits intomainfrom
missing-reflect
Closed

Add missing_reflect lint#137
BD103 wants to merge 40 commits intomainfrom
missing-reflect

Conversation

@BD103
Copy link
Copy Markdown
Member

@BD103 BD103 commented Oct 12, 2024

Closes #54, but blocked by #125 and #128 since I added UI tests.

@BD103 BD103 added A-Linter Related to the linter and custom lints C-Feature Make something new possible S-Blocked This cannot move forward until something else changes labels Oct 12, 2024
@BD103 BD103 removed the S-Blocked This cannot move forward until something else changes label Oct 14, 2024
@BD103
Copy link
Copy Markdown
Member Author

BD103 commented Oct 14, 2024

I may recreate this branch, there's a lot of commits already and I want to refactor the entire lint.

@BD103 BD103 closed this Oct 14, 2024
@BD103 BD103 deleted the missing-reflect branch October 14, 2024 20:38
BD103 added a commit that referenced this pull request Oct 15, 2024
Closes #54. See #137 for past attempt.

This adds a lint that lets users require all components, resources, and
events derive `Reflect`. `Reflect` is often used by tools such as
`bevy-inspector-egui` to view the state of the world while the game is
running, but these tools are far less useful if they do not have access
to reflection data.

This lint is off by default, and intended to be used to require
`Reflect` for types within specific modules. For example:

```rust
#[deny(bevy::missing_reflect)]
mod components {
    use bevy::prelude::*;

    #[derive(Component)]
    struct MyComponent;
}
```

Developers are free to require it throughout the entire crate, however.

```rust
#![deny(bevy::missing_reflect)]
```

This lint gives lots of information when it is raised, such as where the
offending trait was implemented and how to fix it:


![image](https://github.com/user-attachments/assets/e0c33639-d81d-44e6-b7da-433b9f61a61d)

Thanks to `clippy_utils`'s
[`suggest_item_with_attr()`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/sugg/trait.DiagExt.html#tymethod.suggest_item_with_attr),
the suggestion is machine applicable. This means that `cargo fix` can
automatically fix this lint, making migrating a code base super easy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Related to the linter and custom lints C-Feature Make something new possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add lint: Missing #[derive(Reflect)]

1 participant