Open pseidemann opened 1 year ago
Related:
~It's a good idea, but I'm not a fan of the implementation in the proposal. This kind of system in other languages is usually done by either marking the start and end of a code block using two separate comments, or the ability to outright suppress the warning for the entire file (thinking about ESLint right now).~
In Godot 4, you do not disable warnings with comments. Instead, you use the @warning_ignore
annotation.
hi @Mickeon, thanks for your feedback.
I cannot follow your first remark. didn't I propose two separate comments?
definitely, this proposal should also be adapted for godot 4, so it seems the syntax would be then @...
instead of # ...
edit: edited the "Describe the feature" section to make it clear that I propose two new directives (it's also visible in the pseudo code)
Sorry, I didn't read the proposal thoroughly. I thought the X and Y stood for the beginning and end of a warning suppression block.
You can ignore multiple lines if you place @warning_ignore
above a function, tested in beta 10.
But can you ignore specific warnings in an entire script? Or even all warnings? I think something like this could be positioned in the same place @tool is placed.
But can you ignore specific warnings in an entire script?
I think this would be addressed using https://github.com/godotengine/godot/pull/76020 at the top of a script, and not closing the section (as closing it is optional).
Or even all warnings?
Ignoring all warnings at once is generally considered an antipattern, as it does not provide readers with the information of which warnings are supposed to be ignored (until you remove the annotation). Also, it can suppress warnings that are added in future releases or code changes, and therefore hide potential real issues in the script.
Many linters in other programming languages don't support an "ignore all warnings" syntax for this reason.
If we want a more compact syntax to ignore multiple warnings with a single annotation, a comma-separated syntax should be added instead.
Describe the project you are working on
any GDScript code
Describe the problem or limitation you are having in your project
I want to be able to ignore a GDScript warning (or potentially multiple) for multiple lines of code and enable the warning again after these lines.
currently it is only possible to ignore a warning for one line or for the entire file
Describe the feature / enhancement and how it helps to overcome the problem or limitation
add two new warning directives to GDScript, which start and end the disabling of warnings, similar to the syntax of
# warning-ignore-all: X
, but for multiple lines of codeDescribe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
If this enhancement will not be used often, can it be worked around with a few lines of script?
every line which triggers warning X needs to be prepended by
# warning-ignore: X
, making the code and real comments hard to readIs there a reason why this should be core and not an add-on in the asset library?
core functionality of GDScript