Merge pull request #8250 from rarysson/update-warning-system

Update GDScript warning system to use `@warning_ignore`
This commit is contained in:
Max Hilbrunner
2023-11-10 22:33:44 +01:00
committed by GitHub
7 changed files with 11 additions and 28 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

@@ -11,47 +11,30 @@ to runtime errors.
You can configure warnings in the Project Settings under the section
called **GDScript**:
.. figure:: img/typed_gdscript_warning_system_settings.webp
:alt: Warning system project settings
Warning system project settings
.. image:: img/typed_gdscript_warning_system_settings.webp
.. note::
You must enable **Advanced Settings** in order to see the
You must enable **Advanced Settings** in order to see the
GDScript section in the sidebar. You can also search for "GDScript" when
Advanced Settings is off.
You can find a list of warnings for the active GDScript file in the
script editor's status bar. The example below has 3 warnings:
script editor's status bar. The example below has 2 warnings:
.. figure:: img/typed_gdscript_warning_example.png
:alt: Warning system example
.. image:: img/typed_gdscript_warning_example.webp
Warning system example
To ignore specific warnings in one file, insert a special comment of the
form ``# warning-ignore:warning-id``, or click on the ignore link to the
right of the warning's description. Godot will add a comment above the
To ignore specific warnings in one file, insert an annotation of the
form ``@warning_ignore("warning-id")``, or click on the ignore link to the
left of the warning's description. Godot will add an annotation above the
corresponding line and the code won't trigger the corresponding warning
anymore:
.. figure:: img/typed_gdscript_warning_system_ignore.png
:alt: Warning system ignore example
Warning system ignore example
You can also choose to ignore not just one but all warnings of a certain
type in this file with ``# warning-ignore-all:warning-id``. To ignore all
warnings of all types in a file add the comment ``# warnings-disable`` to it.
.. image:: img/typed_gdscript_warning_system_ignore.webp
Warnings won't prevent the game from running, but you can turn them into
errors if you'd like. This way your game won't compile unless you fix
all warnings. Head to the ``GDScript`` section of the Project Settings to
turn on this option. Here's the same file as the previous example with
warnings as errors turned on:
turn on this option to the warning that you want. Here's the same file as
the previous example with the warning ``unused_variable`` as an error turned on:
.. figure:: img/typed_gdscript_warning_system_errors.png
:alt: Warnings as errors
Warnings as errors
.. image:: img/typed_gdscript_warning_system_errors.webp