godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

GDScript Overridden function parameters shouldn't warn for UNUSED_PARAMETER #10791

Open Ryan-000 opened 3 hours ago

Ryan-000 commented 3 hours ago

Describe the project you are working on

Projects using GDScript.

Describe the problem or limitation you are having in your project

The GDScript warning system often flags unused parameters, such as delta in functions like _process and _physics_process, as an issue.

However, in many cases, these parameters are intentionally left unused. For instance, overriding _process may not always require using delta, but the engine mandates including it in the function signature.

This results in unnecessary warnings that reduce focus on more meaningful issues and clutter the editor.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

I propose that GDScript should suppress UNUSED_PARAMETER warnings in engine virtual functions, like those that must adhere to predefined signatures, like _process(delta) and _physics_process(delta). Ideally, this could be implemented for all overridden script methods.

This would clean up unnecessary warnings in projects, allowing developers to focus on actual issues.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

func _process(delta):
    # This will no longer trigger a warning
    pass

If this enhancement will not be used often, can it be worked around with a few lines of script?

The warning can be manually silenced by prefixing the unused parameter with an underscore (e.g., _delta) or using @warning_ignore("unused_parameter").

However, this approach clutters the function signature and becomes time-consuming when dealing with multiple overridden functions. It’s especially frustrating when you comment out code that uses the parameter, as you then have to add the underscore to avoid warnings, only to remove it again when restoring the code, which is tedious and annoying.

Is there a reason why this should be core and not an add-on in the asset library?

GDScript is core

AdriaandeJongh commented 3 hours ago

Alternatively: a project setting specifically for warning about unused parameters of virtual functions.

Ryan-000 commented 3 hours ago

Alternatively: a project setting specifically for warning about unused parameters of virtual functions.

Yeah, ill just make it optional.

HolonProduction commented 3 hours ago

In my opinion there are only few virtual methods where parameters are often unused, namely _process and _physics_process. For most other overridden methods (especially ones that come from user scripts) it is much less likely to be fine to omit using those values. I'd argue that even for _process and _physics_process there are a lot of cases where this warning might be relevant since beginners often don't properly apply delta were they should.

I agree that this can be annoying, but this solution trades viable and helpful warnings for a very small usability improvement.

To me it feels like a quick fix system for warnings would be the better solution.

sockeye-d commented 35 minutes ago

I'd argue that even for _process and _physics_process there are a lot of cases where this warning might be relevant since beginners often don't properly apply delta were they should.

Applying/not applying delta is a different issue, I don't think misuse of the process function should factor into this. There have been many situations where I put something in process that didn't care about delta (synchronizing something every frame, etc.)