GDScript Unused Variable Warning Question

Godot Version

4.3

Question

In Godot 3.5, unused member variables in scripts that extend classes could get warnings when unused in the script. In 4.x, only local and private variables get this warning.

Is there a setting that gives the unused non-private member warning like in 3.5? Or is this the correct behavior going forward and member variables of extended classes should be using underscores as private variables? I am asking so I can understand the convention. Thank you for the help.

1 Like

In Project Settings β†’ General β†’ Debug β†’ GDScript are all the options for warnings. Im not sure about your specific case but you can go there and change the behaviour

Hi, thanks for responding. Yes, I have turned on the warning for unused variable and unused private class variable.

In 3.5, there was only an unused variable warning and any public member variable of an extended class would also get the warning. Now in 4.x, the description for unused variable states it is only for a local variable (which I take as variables declared within functions) and the warning does it accordingly.

Together with the unused private class variable warning, does this mean that unused public class variables should not get the warning? I am not familiar with other languages and whether this is the convention, so if someone can let me know, then I can understand how to declare variables properly in 4.x.

1 Like

well public variables of classes can be modified outside of the class, so its difficult to detect, if they are used, by the compiler

1 Like

Hi! First post reply ever here in this forum. :slight_smile:
I second this, but also, more concerning for me is that unused functions are not marked or notified at all with GDScript.

Eg:

Is there any community plugin or linter for this? Thanks!

image
image
@alighathor I think these two marks are enough, I don’t need more than that

1 Like

As i stated above, the things can be accessed from basically any script you have, so its difficult for the compiler to check for every method or script-variable if its being used by any script

1 Like

Makes sense!