godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.04k stars 20.19k forks source link

Unused class variable warning does not have one for public class variable #96155

Open drearyweary opened 3 weeks ago

drearyweary commented 3 weeks ago

Tested versions

Reproducible in Godot 4.3.stable

System information

macOS 13.6.7 (Intel) - Godot v4.3.stable - Vulkan (Mobile)

Issue description

In 3.5, the Unused Class Variable warning would trigger for unused public and private class member variables. Now in 4.x, this has been renamed to Unused Private Class Variable and only warns for private class variable.

Steps to reproduce

Turn on warning for Unused Private Class Variable and Unused Variable in Project Settings > Debug > GDScript. Then type in a new script:

var some_public_var # This will not have a warning
var _some_private_var # This will have an UNUSED PRIVATE CLASS VARIABLE warning

func _ready():
    var some_local_var  # This will have an UNUSED VARIABLE warning

I apologize if this change was made because unused public class variables are ok to have, but the previous warning was very useful to find class variables I forgot to remove. I am not familiar with other languages to know if this is the convention elsewhere.

Minimal reproduction project (MRP)

N/A

AThousandShips commented 3 weeks ago

This is by design, Unused Variable is for local variables, as the documentation says

Member variables can be unused as they could be:

It not being used in the same script is not an indication of anything being wrong, unlike a private variable which should be expected to be used in the same script, and a local variable which should be used locally

Feature proposals are tracked here, please open a proposal instead.

drearyweary commented 3 weeks ago

Thank you for the explanation. I won't make any proposal changes since this is the correct behavior.