Skip to content

Unused Component/Resource Warning #9776

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

Open
Braymatter opened this issue Sep 12, 2023 · 4 comments
Open

Unused Component/Resource Warning #9776

Braymatter opened this issue Sep 12, 2023 · 4 comments
Labels
A-App Bevy apps and plugins A-ECS Entities, components, systems, and events C-Feature A new feature, making something new possible

Comments

@Braymatter
Copy link
Contributor

What problem does this solve or what need does it fill?

It would be very nice if we had some tool that would emit a warning whenever a component or a resource is not a part of any query in the application.

Sometimes this scenario can result in hard to track down bugs.

We have a DespawnAfterDuration component / system we use. After moving the parent plugin around to a subcrate, but not remounting the plugin to the app, the component never gets processed as the system/plugin aren't added to the app builder.

Often times when moving code around / refactoring we'll forget to add a plugin / system etc. and we run into these sorts of things. Also very common for me when adding entirely new plugins / systems.

What solution would you like?

Ideally a clippy lint / dead_code would be best I think.

What alternative(s) have you considered?

I've attempted to just be better, but it hasn't worked out yet.

@Braymatter Braymatter added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Sep 12, 2023
@nicopap
Copy link
Contributor

nicopap commented Sep 12, 2023

A lead would be to accumulate the FilteredAccess of all the schedules registered in the App, OR-ing the write, read-write, with, without fields, and check if there is any 0s in the resulting bitset.

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events A-App Bevy apps and plugins and removed S-Needs-Triage This issue needs to be labelled labels Sep 14, 2023
@hymm
Copy link
Contributor

hymm commented Sep 20, 2023

A lead would be to accumulate the FilteredAccess of all the schedules registered in the App, OR-ing the write, read-write, with, without fields, and check if there is any 0s in the resulting bitset.

I don't think this will work. Components are registered when they're spawned or used in systems.

@hymm
Copy link
Contributor

hymm commented Sep 20, 2023

This is the whole life before main problem that needs support from rust to fix nicely.

The only way checking the schedule could work is if the user manually calls init_component on the world.

@tormeh
Copy link
Contributor

tormeh commented Oct 16, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-App Bevy apps and plugins A-ECS Entities, components, systems, and events C-Feature A new feature, making something new possible
Projects
None yet
Development

No branches or pull requests

5 participants