-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add a Bevy Linter #2582
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
Add a Bevy Linter #2582
Conversation
Partial solution to #1602. |
Obviously, that specific lint should probably also be added as a bevy internal check We could even steal cargo style reporting for that, although obviously our ability to select spans is a more limited. Once we get editor integration in some form, we'd also want to wire up the warnings there |
Co-authored-by: Alice Cecile <[email protected]>
I'm excited for the possibilities here. We can add more lints once this is merged IMO. I'd like to see a proper README for this new crate; mostly containing the information from this PR description but also linking or containing to some advice on how to add new lints. |
Already done: https://github.com./MinerSebas/bevy/blob/Linter/.github/workflows/ci.yml#L94-L95
What do you mean with As for editor Integration, rust-analyzer can also show these Lints (VSCode Setting Example taken from here): "rust-analyzer.checkOnSave.overrideCommand": [
"cargo",
"dylint",
"--all",
"--workspace",
"--",
"--message-format=json"
] |
Also what name should this crate have?
|
IMO bevy_lint is best. It's clear, simple and doesn't tie us to dylint in the future if we ever choose to swap. |
If you're looking for some more easy lints:
|
Already in my Personal List. Others in the Query category include useless Or:
I thought about it, but i dont think i should invest time into it, because it will no longer be posible.
👍 |
I'm not sure I want to commit the bevy org to maintaining custom lints at this point:
This feels like a perfect candidate for "third party maintenance", at least while bevy apis stabilize and the lints are still being actively developed and experimented with. Its an easy way to parallelize / decentralize decision making and would almost certainly allow bevy_lint to mature faster. Ultimately I think it makes sense for us to manage this stuff, but I'm not convinced now is the time to do it. My current position is that we should reserve the Curious what everyone else thinks. |
I'd be happy to have it third-party maintained for now, but used on Bevy itself (it's a useful tool!) + prominently promoted. Reducing the Cart bottleneck for it does sound appealing. |
A reasonable stance to take. |
Objective
This adds a Linter for Bevy Code.
Solution
Uses dylint to run Lints.
To use this (once it is released) a User needs to add this to their
Cargo.toml
:And then run these Commands:
Currently, it only checks if you have any Function that accepts Querys that contain an unnecessary With Filter.
(Copied from UI-Test File)
Testing
If you want to test this right now, then the Cargo.toml should look like this.
If you are on Windows and use MSVC, you will need to build the executables yourself, until trailofbits/dylint#43 and trailofbits/dylint#45 are merged and released:
git clone https://github.com./MinerSebas/dylint cd dylint git checkout linker cargo install --path cargo-dylint cargo install --path dylint-link
If you use the GNU Toolchain on Windows, you are out of luck.
For some reason, the GNU Linker does not want to link the Lint Library successfully.
(More Information here trailofbits/dylint#45 (comment))