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

Huge amount of unused variable, unused parameter and shadowing warnings + native function override defaulting to error #569

Open
hsandt opened this issue Feb 21, 2024 · 3 comments

Comments

@hsandt
Copy link

hsandt commented Feb 21, 2024

I recently tried to uncheck Project Settings > debug/gdscript/warnings/exclude_addons so I could spot warnings in my own locally developed add-on, but there is no way to tell Godot to only enable warnings on one addons - so it enabled warnings on ALL add-ons including GUT. However, GUT has a huge amount of warnings.

The most obvious is debug/gdscript/warnings/native_method_override because its default value is Error, so GUT run will simply fail as it detects native instantiate being overridden:

doubler.gd > class PackedSceneDouble > func instantiate

Parser Error: The method "instantiate()" overrides a method from native class "PackedScene". This won't be called by the engine and may not work as expected. (Warning treated as error.)

However, from the comment above:

A stroke of genius if I do say so. This allows for doubling a scene without
having to write any files. By overloading the "instantiate" method we can
make whatever we want.

I see it's a really neat trick, so we want to keep it for simplicity (avoid user having to call a proxy instantiate each time). However if I disable this warning, it will disable it completely for my project too...

Then, skipping this particular trick, there are many other warnings:

image

on unused variable, unused parameter and shadowing warnings which are probably easier to fix.

For now I'll just re-enable Exclude add-ons and only disable it from times to times when running the game but not GUT: indeed, as long as you don't run GUT tests themselves, the warnings/errors won't trigger so you can still test your game and custom add-ons to spot their own warnings.

What we'd really need is a more granular control of warnings over different folders, I'll open a proposal for it.

@hsandt
Copy link
Author

hsandt commented Feb 21, 2024

Ah, just found it was mentioned in https://gut.readthedocs.io/en/latest/#engine-warnings

Should I keep the issue open and reuse it as warning tracker to track cleanup advance or just close it then?

@bitwes
Copy link
Owner

bitwes commented Feb 21, 2024

I think this should stay open. I've had most warnings disabled for GUT for a long time because of all the warnings that would show up due to dynamic code and code used to test GUT. Having a list or something would be good. I despise unused vars and such, so it would be nice if I could re-enable some/all of the warnings. There were just so many "invalid" warnings that it was hard to find the ones that mattered.

@bitwes
Copy link
Owner

bitwes commented Feb 21, 2024

@hsandt FYI I edited your comment for formatting (the # in the quote were all turned into H1s).

Parser Error: The method "instantiate()" overrides a method from native class "PackedScene". This won't be called by the engine and may not work as expected. (Warning treated as error.)

GUT should disable and then enable this warning (if it was enabled) when creating a double of a scene, the same way that DOUBLE_STRATEGY.INCLUDE_NATIVE does it. We don't really care that the engine won't call it. There's some edge cases that should be explored, but GUT has been doing it this way for a long time and I've not seen any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants