diff --git a/tutorials/scripting/gdscript/index.rst b/tutorials/scripting/gdscript/index.rst index 8ad213e11a0..b3e1962bd11 100644 --- a/tutorials/scripting/gdscript/index.rst +++ b/tutorials/scripting/gdscript/index.rst @@ -14,6 +14,7 @@ GDScript gdscript_styleguide static_typing warning_system + warnings/index gdscript_format_string .. seealso:: diff --git a/tutorials/scripting/gdscript/warnings/assert_always_false.rst b/tutorials/scripting/gdscript/warnings/assert_always_false.rst new file mode 100644 index 00000000000..de56911770b --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/assert_always_false.rst @@ -0,0 +1,51 @@ +ASSERT_ALWAYS_FALSE +======================= + +The warning message is: + +.. code-block:: none + + Assert statement will raise an error because the expression is always false. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/assert_always_false`. + +When this warning occurs +------------------------ + +The :ref:`assert() ` keyword can be used to ensure that a given condition is met before allowing code execution to continue. If the first argument passed to it is truthy, the rest of the function will run as expected; if it is falsy, then the project will stop. + +If ``assert()`` is passed something guaranteed to be falsy, then the ``assert()`` call will always stop the project. + +.. code-block:: + + # Zero always evaluates to false. + assert(0, "Zero is falsy") + + # Likewise, an empty string always evaluates to false. + assert("", "An empty string is falsy") + +.. note:: + + Godot will *not* raise this warning if a literal falsy boolean is passed: + + .. code-block:: + + # Despite false being passed, this won't raise ASSERT_ALWAYS_FALSE. + assert(false, "False is false") + + # This evaluates to a boolean which is false, so it also won't raise + # the warning. + assert(3 == 4, "3 isn't equal to 4") + + This is because ``assert(false)`` calls are often used in development to forcibly halt program execution and avoid strange errors later on. + + See `GH-58087 `_ for more information. + +How to fix this warning +----------------------- + +Assuming you want code following the ``assert()`` to run, remove it from your code. If you do want code execution to stop at that point, replace the condition with ``false``, or :ref:`consider using breakpoints instead `. + + + diff --git a/tutorials/scripting/gdscript/warnings/assert_always_true.rst b/tutorials/scripting/gdscript/warnings/assert_always_true.rst new file mode 100644 index 00000000000..27c61001859 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/assert_always_true.rst @@ -0,0 +1,36 @@ +ASSERT_ALWAYS_TRUE +====================== + +The warning message is: + +.. code-block:: none + + Assert statement is redundant because the expression is always true. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/assert_always_true`. + +When this warning occurs +------------------------ + +The :ref:`assert() ` keyword can be used to ensure that a given condition is met before allowing code execution to continue. If the first argument passed to it evaluates to ``true``, the rest of the function will run as expected; if it is ``false``, then the project will stop. + +If ``assert()`` is passed an expression that is guaranteed to be ``true``, then the ``assert()`` call will never stop the project, thus making it redundant. + +.. code-block:: + + # The boolean true will always be true, so this assert will never stop + # the program. + assert(true, "True is false, somehow?") + + # Likewise, 3 will never be equal to 4, so this assert will never stop + # the program. + assert(3 != 4, "3 is equal to 4") + +How to fix this warning +----------------------- + +Remove the ``assert()`` statement from your code. + + + diff --git a/tutorials/scripting/gdscript/warnings/confusable_capture_reassignment.rst b/tutorials/scripting/gdscript/warnings/confusable_capture_reassignment.rst new file mode 100644 index 00000000000..657c6d7b5ac --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/confusable_capture_reassignment.rst @@ -0,0 +1,25 @@ +CONFUSABLE_CAPTURE_REASSIGNMENT +=================================== + +The warning message is: + +.. code-block:: none + + Reassigning lambda capture does not modify the outer local variable "my_var". + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/confusable_capture_reassignment`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/confusable_identifier.rst b/tutorials/scripting/gdscript/warnings/confusable_identifier.rst new file mode 100644 index 00000000000..bca81d3ed53 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/confusable_identifier.rst @@ -0,0 +1,31 @@ +CONFUSABLE_IDENTIFIER +========================= + +The warning message is: + +.. code-block:: none + + The identifier "my_vаr" has misleading characters and might be confused with something else. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/confusable_identifier`. + +When this warning occurs +------------------------ + +Some alphabets such as Cyrillic have characters that look like Latin (i.e., English, Spanish, etc.) characters, but are actually different. + +.. code-block:: + + var engine_nаme = "Godot" + print(engine_name) + +In this code snippet, the ``print`` statement would fail, because ``engine_name`` is actually not defined. The identifier in the ``print`` statement uses the Latin character "a" (U+0061), while the identifier in the variable declaration above uses the Cyrillic character "а" (U+0430). + +How to fix this warning +----------------------- + +Avoid using Cyrillic or other alphabets' characters that are visually similar to Latin ones. A good rule of thumb is to always use the Latin alphabet for program identifiers. + + + diff --git a/tutorials/scripting/gdscript/warnings/confusable_local_declaration.rst b/tutorials/scripting/gdscript/warnings/confusable_local_declaration.rst new file mode 100644 index 00000000000..803f9125eb1 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/confusable_local_declaration.rst @@ -0,0 +1,25 @@ +CONFUSABLE_LOCAL_DECLARATION +================================ + +The warning message is: + +.. code-block:: none + + The variable "my_param" is declared below in the parent block. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/confusable_local_declaration`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/confusable_local_usage.rst b/tutorials/scripting/gdscript/warnings/confusable_local_usage.rst new file mode 100644 index 00000000000..e1f34034724 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/confusable_local_usage.rst @@ -0,0 +1,25 @@ +CONFUSABLE_LOCAL_USAGE +========================== + +The warning message is: + +.. code-block:: none + + The identifier "my_var" will be shadowed below in the block. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/confusable_local_usage`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/deprecated_keyword.rst b/tutorials/scripting/gdscript/warnings/deprecated_keyword.rst new file mode 100644 index 00000000000..697fa2a1bd7 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/deprecated_keyword.rst @@ -0,0 +1,25 @@ +DEPRECATED_KEYWORD +====================== + +The warning message is: + +.. code-block:: none + + The "..." keyword is deprecated and will be removed in a future release, please replace its uses by "...". + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/deprecated_keyword`. + +When this warning occurs +------------------------ + +There are currently no deprecated keywords in GDScript; as such, this warning should never appear. + + +How to fix this warning +----------------------- + +Follow instructions on the Godot Docs for how to use the alternative keyword. + + + diff --git a/tutorials/scripting/gdscript/warnings/empty_file.rst b/tutorials/scripting/gdscript/warnings/empty_file.rst new file mode 100644 index 00000000000..163e7ba031f --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/empty_file.rst @@ -0,0 +1,24 @@ +EMPTY_FILE +============== + +The warning message is: + +.. code-block:: none + + Empty script file. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/empty_file`. + +When this warning occurs +------------------------ + +This warning may appear when you create a ``.gd`` file with no code to run. A completely blank file will raise this warning, as will a file that only contains comments. + +How to fix this warning +----------------------- + +Add code to the ``.gd`` file or delete it. + + + diff --git a/tutorials/scripting/gdscript/warnings/enum_variable_without_default.rst b/tutorials/scripting/gdscript/warnings/enum_variable_without_default.rst new file mode 100644 index 00000000000..d8308c12294 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/enum_variable_without_default.rst @@ -0,0 +1,55 @@ +ENUM_VARIABLE_WITHOUT_DEFAULT +================================= + +The warning message is: + +.. code-block:: none + + The variable "my_var" has an enum type and does not set an explicit default value. The default will be set to "0". + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/enum_variable_without_default`. + +When this warning occurs +------------------------ + +This warning may appear when declaring a variable whose type is an enum with values assigned to its members, but the variable is not assigned a value. + +.. code-block:: + + enum MyEnum { + A = 1, + B = 2, + C = 3 + } + + func _ready(): + var my_var: MyEnum # Will give warning ENUM_VARIABLE_WITHOUT_DEFAULT. + +Godot will usually default an enum-typed variable to the integer 0. However, if the enum does not have a member that corresponds to 0, Godot will be confused on how to assign it. + +How to fix this warning +----------------------- + +Provide the variable with a default value, like so: + +.. code-block:: + + var my_var: MyEnum = MyEnum.A + +Alternatively, if the enum has a member with a value of 0, Godot will use that as the default value. + +.. code-block:: + + enum MyEnum { + Z = 0, # Will be used as the default value. + A = 1, + B = 2, + C = 3 + } + + func _ready(): + var my_var: MyEnum # Will default to MyEnum.Z. + + + diff --git a/tutorials/scripting/gdscript/warnings/get_node_default_without_onready.rst b/tutorials/scripting/gdscript/warnings/get_node_default_without_onready.rst new file mode 100644 index 00000000000..f678db6b4db --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/get_node_default_without_onready.rst @@ -0,0 +1,63 @@ +GET_NODE_DEFAULT_WITHOUT_ONREADY +==================================== + +This warning appears when a node's default value is set to a location in the scene tree without using the ``@onready`` annotation. + +Depending on how you attempt to access the scene tree, the warning message will be one of the following: + +.. code-block:: none + + The default value is using "$" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this. + + The default value is using "%" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this. + + The default value is using "get_node()" which won't return nodes in the scene tree before "_ready()" is called. Use the "@onready" annotation to solve this. + +The default warning level for this warning is **Error**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/get_node_default_without_onready`. + +When this warning occurs +------------------------ + +In GDScript, instance variables can be set by declaring them outside of a method. Additionally, they can be given a default value using ``=``:: + +.. code-block:: + + extends Area2D + + var my_num = 3 + +This way, the variable ``my_num`` will always start out with a value of ``3`` in each instance of this class. +GDScript also has methods to retrieve specific nodes from the scene tree: namely, the :ref:`get_node() ` method, and its shorthand versions ``$`` (and ``%`` for unique nodes). Thus, if you want to have an instance variable default to a child of the node with a script, it may be tempting to write something like the following:: + +.. code-block:: + + extends Area2D + + var my_collision_shape = $CollisionShape2D + +However, class instance variables' default values are evaluated and assigned before the scene tree is set up. This means that at the time of assigning the default value, the node may not be in the scene tree, and the variable will be set to ``null`` instead. + +How to fix this warning +----------------------- + +The most straightforward solution is to add the ``@onready`` annotation before your variable declaration:: + +.. code-block:: + + extends Area2D + + @onready var my_collision_shape = $CollisionShape2D + +Now, the default value of the variable will not be assigned until the scene tree has been initialized, and the target node will be present. + +Alternatively, you can set the value of the variable at the beginning of your ``_ready()`` method:: + +.. code-block:: + + extends Area2D + + var my_collision_shape + + func _ready(): + my_collision_shape = $CollisionShape2D \ No newline at end of file diff --git a/tutorials/scripting/gdscript/warnings/incompatible_ternary.rst b/tutorials/scripting/gdscript/warnings/incompatible_ternary.rst new file mode 100644 index 00000000000..48a807b75cc --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/incompatible_ternary.rst @@ -0,0 +1,25 @@ +INCOMPATIBLE_TERNARY +======================== + +The warning message is: + +.. code-block:: none + + Values of the ternary operator are not mutually compatible. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/incompatible_ternary`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/index.rst b/tutorials/scripting/gdscript/warnings/index.rst new file mode 100644 index 00000000000..ae7cc94e5b5 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/index.rst @@ -0,0 +1,60 @@ +:allow_comments: False + +.. _doc_gdscript_warnings: + +GDScript warnings +================= + +This is a collection of the warnings that GDScript can emit, and information on how to fix the code that causes them. + +.. rubric:: Warnings + :heading-level: 2 + +.. toctree:: + :maxdepth: 1 + :name: toc-gdscript-warnings + + unassigned_variable + unassigned_variable_op_assign + unused_variable + unused_local_constant + unused_private_class_variable + unused_parameter + unused_signal + shadowed_variable + shadowed_variable_base_class + shadowed_global_identifier + unreachable_code + unreachable_pattern + standalone_expression + standalone_ternary + incompatible_ternary + untyped_declaration + inferred_declaration + unsafe_property_access + unsafe_method_access + unsafe_cast + unsafe_call_argument + unsafe_void_return + return_value_discarded + static_called_on_instance + missing_tool + redundant_static_unload + redundant_await + assert_always_true + assert_always_false + integer_division + narrowing_conversion + int_as_enum_without_cast + int_as_enum_without_match + enum_variable_without_default + empty_file + deprecated_keyword + confusable_identifier + confusable_local_declaration + confusable_local_usage + confusable_capture_reassignment + inference_on_variant + native_method_override + get_node_default_without_onready + onready_with_export diff --git a/tutorials/scripting/gdscript/warnings/inference_on_variant.rst b/tutorials/scripting/gdscript/warnings/inference_on_variant.rst new file mode 100644 index 00000000000..78059d26c74 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/inference_on_variant.rst @@ -0,0 +1,37 @@ +INFERENCE_ON_VARIANT +======================== + +The warning message is: + +.. code-block:: none + + The variable type is being inferred from a Variant value, so it will be typed as Variant. + +The default warning level for this warning is **Error**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/inference_on_variant`. + +When this warning occurs +------------------------ + +This warning may appear when using the ``:=`` operator to declare a variable with an inferred type, when the inferred type is Variant. + +.. code-block:: + + func _ready(): + var my_var := get_value() # Will give warning INFERENCE_ON_VARIANT. + + func get_value(): + return 3 + +Because the return type of ``get_value()`` isn't explicitly stated to be ``int``, Godot won't assume that it only returns an ``int``, and thus will consider its return type to be ``Variant``. The ``:=`` operator will then only be able to set the type of ``my_var`` to ``Variant``, which is effectively the same as not setting a type for ``my_var`` at all. + +How to fix this warning +----------------------- + +If initializing a variable based on the return value of a function (like in the example above), give the function an explicit return type: + +.. code-block:: + + func get_value() -> int: + return 3 + diff --git a/tutorials/scripting/gdscript/warnings/inferred_declaration.rst b/tutorials/scripting/gdscript/warnings/inferred_declaration.rst new file mode 100644 index 00000000000..c56fdc64a0d --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/inferred_declaration.rst @@ -0,0 +1,33 @@ +INFERRED_DECLARATION +======================== + +The warning message is: + +.. code-block:: none + + "for" iterator variable "i" has an implicitly inferred static type. + +The default warning level for this warning is **Ignore**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/inferred_declaration`. + +When this warning occurs +------------------------ + +This warning may appear when creating a variable for a particular scope, such as a ``for`` loop, without specifying its type explicitly: + +.. code-block:: + + for i in 10: # Will give warning INFERRED_DECLARATION. + print(i) + +In this example, the variable ``i`` did not have its type specified. It is implied to be an ``int``, but not outright stated in the code. + +How to fix this warning +----------------------- + +Provide a type specifier for the variable, like so: + +.. code-block:: + + for i: int in 10: # Will not give a warning. + print(i) diff --git a/tutorials/scripting/gdscript/warnings/int_as_enum_without_cast.rst b/tutorials/scripting/gdscript/warnings/int_as_enum_without_cast.rst new file mode 100644 index 00000000000..bc9c98c9f11 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/int_as_enum_without_cast.rst @@ -0,0 +1,31 @@ +INT_AS_ENUM_WITHOUT_CAST +============================ + +The warning message is: + +.. code-block:: none + + Integer used when an enum value is expected. If this is intended cast the integer to the enum type. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/int_as_enum_without_cast`. + +When this warning occurs +------------------------ + +This warning may appear when attempting to use an integer value in place of an enum value: + +.. code-block:: + + var my_var: MyEnum + my_var = 1 # Will give warning INT_AS_ENUM_WITHOUT_CAST. + +How to fix this warning +----------------------- + +Cast the integer value to the enum type. + +.. code-block:: + + var my_var: MyEnum + my_var = 1 as MyEnum diff --git a/tutorials/scripting/gdscript/warnings/int_as_enum_without_match.rst b/tutorials/scripting/gdscript/warnings/int_as_enum_without_match.rst new file mode 100644 index 00000000000..68b18fadbba --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/int_as_enum_without_match.rst @@ -0,0 +1,55 @@ +INT_AS_ENUM_WITHOUT_MATCH +============================= + +The warning message is: + +.. code-block:: none + + Cannot cast 3 as Enum "MyClass.MyEnum": no enum member has matching value. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/int_as_enum_without_match`. + +When this warning occurs +------------------------ + +This warning may appear when attempting to cast an integer value to an enum type, but the enum type doesn't have a member with a corresponding value. + +.. code-block:: + + enum MyEnum { ZERO, ONE, TWO } + + func _ready(): + var my_var = 3 as MyEnum # Will give warning INT_AS_ENUM_WITHOUT_MATCH. + +The purpose of the enum is to keep track of a pre-determined number of possible values. In most cases, there is no reason to assign a value outside of those pre-determined ones, so it is considered to be likely a mistake. + +How to fix this warning +----------------------- + +Provide a value for the enum that corresponds to the intended integer value. + +.. code-block:: + + enum MyEnum { ZERO, ONE, TWO, THREE } + + func _ready(): + var my_var = 3 as MyEnum # Will now correspond to MyEnum.THREE. + +Remember that while Godot will assign integer values to enum members by default, you can also explicitly define their corresponding values: + +.. code-block:: + + enum MyEnum { ZERO, ONE, TWO, TEN_THOUSAND = 10000 } + + func _ready(): + var my_var = 10000 as MyEnum # Will correspond to MyEnum.TEN_THOUSAND. + +Alternatively, you may just need to change the integer number you're attempting to cast as an enum value to be within the range of valid values. + +.. code-block:: + + enum MyEnum { ZERO, ONE, TWO } + + func _ready(): + var my_var = 2 as MyEnum # Will correspond to MyEnum.TWO diff --git a/tutorials/scripting/gdscript/warnings/integer_division.rst b/tutorials/scripting/gdscript/warnings/integer_division.rst new file mode 100644 index 00000000000..1f57f6379d1 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/integer_division.rst @@ -0,0 +1,41 @@ +INTEGER_DIVISION +==================== + +The warning message is: + +.. code-block:: none + + Integer division, decimal part will be discarded. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/integer_division`. + +When this warning occurs +------------------------ + +This warning may appear when attempting to divide two integers: + +.. code-block:: + + var result = 5 / 3 # Will give warning INTEGER_DIVISION. + +Because both operands are integers, the result will be an integer as well. Integers can't store fractional parts of numbers, so the result must be a whole number. Godot discards anything after the decimal point in the mathematical result to obtain the integer result. **Note that the number is not rounded to the nearest whole number.** + + +How to fix this warning +----------------------- + +Use floating-point numbers (``float``) for the division operation: + +.. code-block:: + + var result = 5.0 / 3.0 + +If the integers being divided are variables, cast them to ``float``: + +.. code-block:: + + var a: int = 5 + var b: int = 3 + var result = float(a) / float(b) + diff --git a/tutorials/scripting/gdscript/warnings/missing_tool.rst b/tutorials/scripting/gdscript/warnings/missing_tool.rst new file mode 100644 index 00000000000..1ac202dd991 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/missing_tool.rst @@ -0,0 +1,25 @@ +MISSING_TOOL +================ + +The warning message is: + +.. code-block:: none + + The base class script has the "@tool" annotation, but this script does not have it. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/missing_tool`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/narrowing_conversion.rst b/tutorials/scripting/gdscript/warnings/narrowing_conversion.rst new file mode 100644 index 00000000000..1e6251fe9c4 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/narrowing_conversion.rst @@ -0,0 +1,25 @@ +NARROWING_CONVERSION +======================== + +The warning message is: + +.. code-block:: none + + Narrowing conversion (float is converted to int and loses precision). + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/narrowing_conversion`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/native_method_override.rst b/tutorials/scripting/gdscript/warnings/native_method_override.rst new file mode 100644 index 00000000000..cc35b10ba76 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/native_method_override.rst @@ -0,0 +1,37 @@ +NATIVE_METHOD_OVERRIDE +========================== + +The warning message is: + +.. code-block:: none + + The method "get_class()" overrides a method from native class "Object". This won't be called by the engine and may not work as expected. + +The default warning level for this warning is **Error**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/native_method_override`. + +When this warning occurs +------------------------ + +This warning may appear if you try to define a method in a script that has the name as a native class's method: + +.. code-block:: + + extends Node + + func get_class(): # Will give warning NATIVE_METHOD_OVERRIDE. + return "MyCoolClass" + +Here, ``get_class()`` is a method on ``Object``. When Godot tries to call this class's ``get_class()`` method for internal purposes, it will use the already-existing definition, not the one the user has defined here. + +How to fix this warning +----------------------- + +Name the function something else: + +.. code-block:: + + func get_class_name(): # Will not give a warning. + return "MyCoolClass" + +(Note that doing this still won't override the behavior of a native method.) diff --git a/tutorials/scripting/gdscript/warnings/onready_with_export.rst b/tutorials/scripting/gdscript/warnings/onready_with_export.rst new file mode 100644 index 00000000000..a1b1c3589f5 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/onready_with_export.rst @@ -0,0 +1,25 @@ +ONREADY_WITH_EXPORT +======================= + +The warning message is: + +.. code-block:: none + + "@onready" will set the default value after "@export" takes effect and will override it. + +The default warning level for this warning is **Error**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/onready_with_export`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/redundant_await.rst b/tutorials/scripting/gdscript/warnings/redundant_await.rst new file mode 100644 index 00000000000..0d7cebe227a --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/redundant_await.rst @@ -0,0 +1,25 @@ +REDUNDANT_AWAIT +=================== + +The warning message is: + +.. code-block:: none + + "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/redundant_await`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/redundant_static_unload.rst b/tutorials/scripting/gdscript/warnings/redundant_static_unload.rst new file mode 100644 index 00000000000..c22639adddd --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/redundant_static_unload.rst @@ -0,0 +1,25 @@ +REDUNDANT_STATIC_UNLOAD +=========================== + +The warning message is: + +.. code-block:: none + + The "@static_unload" annotation is redundant because the file does not have a class with static variables. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/redundant_static_unload`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/return_value_discarded.rst b/tutorials/scripting/gdscript/warnings/return_value_discarded.rst new file mode 100644 index 00000000000..36f37b66129 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/return_value_discarded.rst @@ -0,0 +1,41 @@ +RETURN_VALUE_DISCARDED +========================== + +The warning message is: + +.. code-block:: none + + The function "get_number()" returns a value that will be discarded if not used. + +The default warning level for this warning is **Ignore**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/return_value_discarded`. + +When this warning occurs +------------------------ + +This warning may appear if a method returns a value, but that value is not used in an expression or assigned to a variable: + +.. code-block:: + + func _ready(): + print("About to get a number...") + get_number() # Will give warning RETURN_VALUE_DISCARDED. + print("Got a number!") + + func get_number() -> int: + return 5 + +How to fix this warning +----------------------- + +Assign the returned value to a variable for use later. + +.. code-block:: + + func _ready(): + print("About to get a number...") + var num = get_number() + print("Got a number! It's %s" % num) + +However, some methods in Godot's APIs return values that are not necessary to store. As such, depending on the situation it may make more sense to ignore this warning. + diff --git a/tutorials/scripting/gdscript/warnings/shadowed_global_identifier.rst b/tutorials/scripting/gdscript/warnings/shadowed_global_identifier.rst new file mode 100644 index 00000000000..b4651fb8d54 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/shadowed_global_identifier.rst @@ -0,0 +1,38 @@ +SHADOWED_GLOBAL_IDENTIFIER +============================== + +The warning message is: + +.. code-block:: none + + The variable "char" has the same name as a built-in function. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/shadowed_global_identifier`. + +When this warning occurs +------------------------ + +This warning may appear when using a name for something that is already being used for an existing: + +* built-in function (like ``char`` or ``convert``), +* native class (like ``Node`` or ``Area2D``), +* global class defined in another script file, +* or built-in type (like ``int`` or ``String``). + +When something is *shadowed*, its name is taken by something else, and as such, it can't be accessed any more within that scope. For example, if you used the code: + +.. code-block:: + + var char = "A" + +and later within this block of code, you wanted to convert an ``int`` ASCII/Unicode character point into a ``String`` (i.e., what the ``char()`` function does), you would be out of luck. + + +How to fix this warning +----------------------- + +Change the name of the identifier to something else that isn't the same as a global identifier. + + + diff --git a/tutorials/scripting/gdscript/warnings/shadowed_variable.rst b/tutorials/scripting/gdscript/warnings/shadowed_variable.rst new file mode 100644 index 00000000000..f87b0292a46 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/shadowed_variable.rst @@ -0,0 +1,38 @@ +SHADOWED_VARIABLE +===================== + +The warning message is: + +.. code-block:: none + + The local variable "level" is shadowing an already-declared variable at line 3 in the current class. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/shadowed_variable`. + +When this warning occurs +------------------------ + +This warning may appear when giving something the same name as a variable previously defined in the class. + +.. code-block:: + + extends Node + + var level = 3 + + func _ready(): + # Will give warning SHADOWED_VARIABLE. + var level = 1 + print("Time for level %s" % level) + +In this example, the script class has a property ``level`` which can be accessed from its functions. However, at the first line of ``_ready()``, a new ``level`` variable is declared for that function specifically. After this declaration, any references to ``level`` will go to that version and not the shared variable for the class. This is called *shadowing*. + + +How to fix this warning +----------------------- + +Change the name to something that isn't being used by the class. For example, if receiving a warning about using the identifier ``level``, consider using something more descriptive like ``new_level``. + + + diff --git a/tutorials/scripting/gdscript/warnings/shadowed_variable_base_class.rst b/tutorials/scripting/gdscript/warnings/shadowed_variable_base_class.rst new file mode 100644 index 00000000000..29566d2cf8f --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/shadowed_variable_base_class.rst @@ -0,0 +1,36 @@ +SHADOWED_VARIABLE_BASE_CLASS +================================ + +The warning message is: + +.. code-block:: none + + The local variable "name" is shadowing an already-declared property in the base class "Node". + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/shadowed_variable_base_class`. + +When this warning occurs +------------------------ + +This warning may appear when using a name for something that the script's base class already uses for something else. + +.. code-block:: + + extends Node + + func _ready(): + # Will give warning SHADOWED_VARIABLE_BASE_CLASS. + var name = "Bob" + print("Hi, my name is %s" % name) + +In this example, the ``Node`` class already defines ``name`` as the name associated with the node itself in the scene tree and editor. Before the ``var name`` declaration, writing ``name = "MyNode"`` would have set the node's name. After the declaration, though, the same line of code would not change it. In fact, after the ``var name``, the node's name can no longer be accessed within the ``_ready()`` function. This is called *shadowing*. + + +How to fix this warning +----------------------- + +Change the name to something that isn't being used by the base class. For example, if receiving a warning about using the identifier ``name``, consider using something more descriptive like ``char_name`` or ``item_name``. + + + diff --git a/tutorials/scripting/gdscript/warnings/standalone_expression.rst b/tutorials/scripting/gdscript/warnings/standalone_expression.rst new file mode 100644 index 00000000000..8cacd73655a --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/standalone_expression.rst @@ -0,0 +1,51 @@ +STANDALONE_EXPRESSION +========================= + +The warning message is: + +.. code-block:: none + + Standalone expression (the line may have no effect). + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/standalone_expression`. + +When this warning occurs +------------------------ + +This warning may appear when writing an expression (a combination of values) that aren't assigned to anything or passed to a function: + +.. code-block:: + + # Will give warning STANDALONE_EXPRESSION. + (5 * 3) + 2 + +This expression evaluates to the integer value ``17``, but after that, nothing happens to or with it. + +Note that the warning states the expression *may* have no effect, not that it *won't* have an effect. If the expression includes a function call that ends up doing more than just returning a value, the line itself ultimately will have an effect. + +.. code-block:: + + extends Node + + var counter = 0 + + func _ready(): + # Will give warning STANDALONE_EXPRESSION. + (5 * 3) + 2 * add_to_val(3) + + func add_to_val(val) -> int: + counter += 1 + return val + 2 + +Here, the line in ``_ready()`` receives the ``STANDALONE_EXPRESSION`` warning, even though the call to ``add_to_val()`` changes the ``counter`` property. (The other math calculations still won't have any effect, though.) + +How to fix this warning +----------------------- + +If you've written an expression in your code, it's likely because you intended to use it for something. Make sure you're assigning it to a variable or passing it to a function if so. + +If you're certain that you don't need the expression for anything, remove it. Make sure to keep function calls that may have side effects (such as the ``add_to_val()`` call in the example above). + + + diff --git a/tutorials/scripting/gdscript/warnings/standalone_ternary.rst b/tutorials/scripting/gdscript/warnings/standalone_ternary.rst new file mode 100644 index 00000000000..d2b2e25d4c6 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/standalone_ternary.rst @@ -0,0 +1,53 @@ +STANDALONE_TERNARY +====================== + +The warning message is: + +.. code-block:: none + + Standalone ternary operator: the return value is being discarded. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/standalone_ternary`. + +When this warning occurs +------------------------ + +This warning may appear when writing a ternary expression that is not being assigned to anything or passed into a function: + +.. code-block:: + + # Will give warning STANDALONE_TERNARY. + 3 if visible else 0 + +This ternary expression will return either ``3`` or ``0``, but that value won't carry over to anything or have any effect on the program. + +The warning may also appear when using a ternary operator to call different functions based on a condition: + +.. code-block:: + + # Will give warning STANDALONE_TERNARY. + chase_player() if can_see_player() else be_idle() + + + +How to fix this warning +----------------------- + +If the possible return values from the ternary expression are important, assign them to a variable so they aren't lost: + +.. code-block:: + + var number = 3 if visible else 0 + +For calling different functions as seen in the second example, consider splitting it into an if-else statement. While it takes a few more lines, they will be shorter and easier to read. + +.. code-block:: + + if can_see_player(): + chase_player() + else: + be_idle() + + + diff --git a/tutorials/scripting/gdscript/warnings/static_called_on_instance.rst b/tutorials/scripting/gdscript/warnings/static_called_on_instance.rst new file mode 100644 index 00000000000..e500ee71d22 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/static_called_on_instance.rst @@ -0,0 +1,45 @@ +STATIC_CALLED_ON_INSTANCE +============================= + +The warning message is: + +.. code-block:: none + + The function "do_static_thing()" is a static function but was called from an instance. Instead, it should be directly called from the type: "MyClass.do_static_thing()". + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/static_called_on_instance`. + +When this warning occurs +------------------------ + +.. + It's been a problem with other pages too, but I worry this is getting a bit repetitive with the original warning message. + +This warning may appear when attempting to call a static function on an instance. + +.. code-block:: + + class MathFuncs: + static func subtract_two(val): + return val - 2 + + func _ready(): + var my_math_funcs = MathFuncs.new() + + # Will give warning STATIC_CALLED_ON_INSTANCE. + var result = my_math_funcs.subtract_two(5) + +When a function is *static*, it belongs to the class as a whole, not any one specific instance of the class. This can be quite handy for writing functions that you want to access from anywhere, without needing a class instance. + +How to fix this warning +----------------------- + +Don't use an instance of the class to access the function. Instead, use the class name itself: + +.. code-block:: + + var result = MathFuncs.subtract_two(5) + + + diff --git a/tutorials/scripting/gdscript/warnings/unassigned_variable.rst b/tutorials/scripting/gdscript/warnings/unassigned_variable.rst new file mode 100644 index 00000000000..fd021d23316 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/unassigned_variable.rst @@ -0,0 +1,36 @@ +UNASSIGNED_VARIABLE +======================= + +The warning message is: + +.. code-block:: none + + The variable "my_var" is used before being assigned a value. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/unassigned_variable`. + +When this warning occurs +------------------------ + +This warning may appear when attempting to use a variable that hasn't had a value assigned to it yet. + +.. code-block:: + + var my_var + print(my_var) + +Without having a value assigned to the variable, Godot may not know what to do with it. + +How to fix this warning +----------------------- + +Assign a value to the variable before including it in an expression or function call: + +.. code-block:: + + var my_var = 5 + print(my_var) + + + diff --git a/tutorials/scripting/gdscript/warnings/unassigned_variable_op_assign.rst b/tutorials/scripting/gdscript/warnings/unassigned_variable_op_assign.rst new file mode 100644 index 00000000000..eb4e2ee477b --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/unassigned_variable_op_assign.rst @@ -0,0 +1,43 @@ +UNASSIGNED_VARIABLE_OP_ASSIGN +================================= + +The warning message is: + +.. code-block:: none + + The variable "my_counter" is modified with the compound-assignment operator "+=" but was not previously initialized. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/unassigned_variable_op_assign`. + +When this warning occurs +------------------------ + +This warning may appear when attempting to use one of the compound-assignment operators, like ``+=``, ``-=``, ``*=``, or ``/=``, on a variable that hasn't had a value assigned to it yet. + +.. code-block:: + + var my_counter: int + my_counter += 1 + +Compound-assignment operators are shorthand for performing a binary math operation and an assignment operation. The above example is equivalent to: + +.. code-block:: + + var my_counter: int + my_counter = my_counter + 1 + +Here, the variable ``my_counter`` hasn't been given a value at the time that the code attempts to use the value from ``my_counter`` in order to calculate the new value for it. + +How to fix this warning +----------------------- + +Assign an initial value to the variable before attempting to use a compound-assignment operator with it: + +.. code-block:: + + var my_counter: int = 0 + my_counter += 1 + + + diff --git a/tutorials/scripting/gdscript/warnings/unreachable_code.rst b/tutorials/scripting/gdscript/warnings/unreachable_code.rst new file mode 100644 index 00000000000..0c4ea7d8800 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/unreachable_code.rst @@ -0,0 +1,62 @@ +UNREACHABLE_CODE +==================== + +The warning message is: + +.. code-block:: none + + Unreachable code (statement after return) in function "_ready()". + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/unreachable_code`. + +When this warning occurs +------------------------ + +This warning may appear there is code in a function that can never be reached because all possible code paths before it would hit a ``return`` statement and leave the function: + +.. code-block:: + + func calculate_num(a): + if a > 5: + return 10 + else: + return 3 + + print("Returning zero") + return 0 + +In this function, there are only two ways the code can be run: + +* If ``a`` is greater than ``5``, the function will return ``10``, and the print statement will not be reached. +* If ``a`` is equal to or less than ``5``, the function will return ``3``, and again the print statement will not be reached. + +There is no way for code execution to get past the if-else block and to the print statement. + +How to fix this warning +----------------------- + +If you want the code marked with the warning to be run, modify your function's logic so that there is a path to that code. + +.. code-block:: + + func calculate_num(a): + if a > 5: + return 10 + elif a > 2: # Now this condition can be false, and the print statement can be reached. + return 3 + + print("Returning zero") + return 0 + +If the code with the warning isn't important, then remove it. + +.. code-block:: + + func calculate_num(a): + if a > 5: + return 10 + else: + return 3 + + diff --git a/tutorials/scripting/gdscript/warnings/unreachable_pattern.rst b/tutorials/scripting/gdscript/warnings/unreachable_pattern.rst new file mode 100644 index 00000000000..382d59047ee --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/unreachable_pattern.rst @@ -0,0 +1,25 @@ +UNREACHABLE_PATTERN +======================= + +The warning message is: + +.. code-block:: none + + Unreachable pattern (pattern after wildcard or bind). + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/unreachable_pattern`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/unsafe_call_argument.rst b/tutorials/scripting/gdscript/warnings/unsafe_call_argument.rst new file mode 100644 index 00000000000..9508d6cde9d --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/unsafe_call_argument.rst @@ -0,0 +1,25 @@ +UNSAFE_CALL_ARGUMENT +======================== + +The warning message is: + +.. code-block:: none + + The argument 1 of the function "set_health()" requires the subtype "int" but the supertype "Variant" was provided. + +The default warning level for this warning is **Ignore**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/unsafe_call_argument`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/unsafe_cast.rst b/tutorials/scripting/gdscript/warnings/unsafe_cast.rst new file mode 100644 index 00000000000..dcb4ae3b1ed --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/unsafe_cast.rst @@ -0,0 +1,25 @@ +UNSAFE_CAST +=============== + +The warning message is: + +.. code-block:: none + + Casting "Variant" to "%s" is unsafe. + +The default warning level for this warning is **Ignore**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/unsafe_cast`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/unsafe_method_access.rst b/tutorials/scripting/gdscript/warnings/unsafe_method_access.rst new file mode 100644 index 00000000000..6a5499c7628 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/unsafe_method_access.rst @@ -0,0 +1,25 @@ +UNSAFE_METHOD_ACCESS +======================== + +The warning message is: + +.. code-block:: none + + The method "do_thing()" is not present on the inferred type "Node" (but may be present on a subtype). + +The default warning level for this warning is **Ignore**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/unsafe_method_access`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/unsafe_property_access.rst b/tutorials/scripting/gdscript/warnings/unsafe_property_access.rst new file mode 100644 index 00000000000..3e045fb05f4 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/unsafe_property_access.rst @@ -0,0 +1,25 @@ +UNSAFE_PROPERTY_ACCESS +========================== + +The warning message is: + +.. code-block:: none + + The property "health" is not present on the inferred type "Node" (but may be present on a subtype). + +The default warning level for this warning is **Ignore**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/unsafe_property_access`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/unsafe_void_return.rst b/tutorials/scripting/gdscript/warnings/unsafe_void_return.rst new file mode 100644 index 00000000000..3203ba96a48 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/unsafe_void_return.rst @@ -0,0 +1,25 @@ +UNSAFE_VOID_RETURN +====================== + +The warning message is: + +.. code-block:: none + + The method "do_thing()" returns "void" but it's trying to return a call to "do_other_thing()" that can't be ensured to also be "void". + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/unsafe_void_return`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/untyped_declaration.rst b/tutorials/scripting/gdscript/warnings/untyped_declaration.rst new file mode 100644 index 00000000000..5ea18dfa24c --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/untyped_declaration.rst @@ -0,0 +1,27 @@ +UNTYPED_DECLARATION +======================= + +The warning message is: + +.. code-block:: none + + Function "_ready()" has no static return type. + + Variable "my_age" has no static type. + +The default warning level for this warning is **Ignore**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/untyped_declaration`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/unused_local_constant.rst b/tutorials/scripting/gdscript/warnings/unused_local_constant.rst new file mode 100644 index 00000000000..c6f50c89f0b --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/unused_local_constant.rst @@ -0,0 +1,25 @@ +UNUSED_LOCAL_CONSTANT +========================= + +The warning message is: + +.. code-block:: none + + The local constant "MAX_VALUE" is declared but never used in the block. If this is intended, prefix it with an underscore: "_MAX_VALUE". + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/unused_local_constant`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/unused_parameter.rst b/tutorials/scripting/gdscript/warnings/unused_parameter.rst new file mode 100644 index 00000000000..d3dd0fab01f --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/unused_parameter.rst @@ -0,0 +1,25 @@ +UNUSED_PARAMETER +==================== + +The warning message is: + +.. code-block:: none + + The parameter "delta" is never used in the function "_process()". If this is intended, prefix it with an underscore: "_delta". + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/unused_parameter`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/unused_private_class_variable.rst b/tutorials/scripting/gdscript/warnings/unused_private_class_variable.rst new file mode 100644 index 00000000000..44aa4487306 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/unused_private_class_variable.rst @@ -0,0 +1,25 @@ +UNUSED_PRIVATE_CLASS_VARIABLE +================================= + +The warning message is: + +.. code-block:: none + + The class variable "_health" is declared but never used in the class. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/unused_private_class_variable`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/unused_signal.rst b/tutorials/scripting/gdscript/warnings/unused_signal.rst new file mode 100644 index 00000000000..04beeaf990e --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/unused_signal.rst @@ -0,0 +1,25 @@ +UNUSED_SIGNAL +================= + +The warning message is: + +.. code-block:: none + + The signal "defeated" is declared but never explicitly used in the class. + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/unused_signal`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + + diff --git a/tutorials/scripting/gdscript/warnings/unused_variable.rst b/tutorials/scripting/gdscript/warnings/unused_variable.rst new file mode 100644 index 00000000000..f98a417cbd5 --- /dev/null +++ b/tutorials/scripting/gdscript/warnings/unused_variable.rst @@ -0,0 +1,25 @@ +UNUSED_VARIABLE +=================== + +The warning message is: + +.. code-block:: none + + The local variable "counter" is declared but never used in the block. If this is intended, prefix it with an underscore: "_counter". + +The default warning level for this warning is **Warn**. +To modify it, see :ref:`ProjectSettings.debug/gdscript/warnings/unused_variable`. + +When this warning occurs +------------------------ + +TODO + + +How to fix this warning +----------------------- + +TODO + + +