Skip to content

Commit 3ac5264

Browse files
authored
Fix formatting of all function-specific @warning_ignore values (#355)
1 parent 90ebbd1 commit 3ac5264

File tree

3 files changed

+387
-0
lines changed

3 files changed

+387
-0
lines changed

gdtoolkit/formatter/annotation.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,98 @@
1515
"icon",
1616
"tool",
1717
]
18+
19+
"""
20+
Source: https://github.com/godotengine/godot/blob/master/modules/gdscript/gdscript_warning.h
21+
Source last updated: 2025-01-09
22+
23+
Unused because not applicable to functions:
24+
- "unused_variable"
25+
- "unused_local_constant"
26+
- "shadowed_variable"
27+
- "shadowed_variable_base_class"
28+
- "missing_tool"
29+
- "empty_file"
30+
- "unused_private_class_variable"
31+
- "unused_signal"
32+
- "redundant_static_unload"
33+
- "get_node_default_without_onready"
34+
- "onready_with_export"
35+
36+
Unused because deprecated:
37+
- "property_used_as_function"
38+
- "constant_used_as_function"
39+
- "function_used_as_property"
40+
"""
1841
_NON_STANDALONE_WARNING_IGNORES = [
42+
# Variable used but never assigned.
43+
"unassigned_variable",
44+
# Variable never assigned but used in an assignment operation (+=, *=, etc).
45+
"unassigned_variable_op_assign",
46+
# Function parameter is never used.
1947
"unused_parameter",
48+
# A global class or function has the same name as variable.
49+
"shadowed_global_identifier",
50+
# Code after a return statement.
51+
"unreachable_code",
52+
# Pattern in a match statement after a catch all pattern (wildcard or bind).
53+
"unreachable_pattern",
54+
# Expression not assigned to a variable.
55+
"standalone_expression",
56+
# Return value of ternary expression is discarded.
57+
"standalone_ternary",
58+
# Possible values of a ternary if are not mutually compatible.
59+
"incompatible_ternary",
60+
# Variable/parameter/function has no static type, explicitly specified or implicitly inferred.
61+
"untyped_declaration",
62+
# Variable/constant/parameter has an implicitly inferred static type.
63+
"inferred_declaration",
64+
# Property not found in the detected type (but can be in subtypes).
65+
"unsafe_property_access",
66+
# Function not found in the detected type (but can be in subtypes).
67+
"unsafe_method_access",
68+
# Casting a `variant` value to non-`variant`.
69+
"unsafe_cast",
70+
# Function call argument is of a supertype of the required type.
71+
"unsafe_call_argument",
72+
# Function returns void but returned a call to a function that can't be type checked.
73+
"unsafe_void_return",
74+
# Function call returns something but the value isn't used.
75+
"return_value_discarded",
76+
# A static method was called on an instance of a class instead of on the class itself.
77+
"static_called_on_instance",
78+
# Await is used but expression is synchronous (not a signal nor a coroutine).
79+
"redundant_await",
80+
# Expression for assert argument is always true.
81+
"assert_always_true",
82+
# Expression for assert argument is always false.
83+
"assert_always_false",
84+
# Integer divide by integer, decimal part is discarded.
85+
"integer_division",
86+
# Float value into an integer slot, precision is lost.
87+
"narrowing_conversion",
88+
# An integer value was used as an enum value without casting.
89+
"int_as_enum_without_cast",
90+
# An integer value was used as an enum value without matching enum member.
91+
"int_as_enum_without_match",
92+
# A variable with an enum type does not have a default value. the default will be set to `0`
93+
# instead of the first enum value.
94+
"enum_variable_without_default",
95+
# The keyword is deprecated and should be replaced.
96+
"deprecated_keyword",
97+
# The identifier contains misleading characters that can be confused. e.g. "usеr"
98+
# (has cyrillic "е" instead of latin "e").
99+
"confusable_identifier",
100+
# The parent block declares an identifier with the same name below.
101+
"confusable_local_declaration",
102+
# The identifier will be shadowed below in the block.
103+
"confusable_local_usage",
104+
# Reassigning lambda capture does not modify the outer local variable.
105+
"confusable_capture_reassignment",
106+
# The declaration uses type inference but the value is typed as variant.
107+
"inference_on_variant",
108+
# The script method overrides a native one, this may not work as intended.
109+
"native_method_override",
20110
]
21111

22112

tests/formatter/input-output-pairs/simple_function_annotations.in.gd

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,135 @@ func i():
3434
@rpc("any_peer", "call_local")
3535
func j():
3636
pass
37+
38+
@warning_ignore("unassigned_variable")
39+
func k01():
40+
pass
41+
42+
@warning_ignore("unassigned_variable_op_assign")
43+
func k02():
44+
pass
45+
46+
@warning_ignore("unused_parameter")
47+
func k03():
48+
pass
49+
50+
@warning_ignore("shadowed_global_identifier")
51+
func k04():
52+
pass
53+
54+
@warning_ignore("unreachable_code")
55+
func k05():
56+
pass
57+
58+
@warning_ignore("unreachable_pattern")
59+
func k06():
60+
pass
61+
62+
@warning_ignore("standalone_expression")
63+
func k07():
64+
pass
65+
66+
@warning_ignore("standalone_ternary")
67+
func k08():
68+
pass
69+
70+
@warning_ignore("incompatible_ternary")
71+
func k09():
72+
pass
73+
74+
@warning_ignore("untyped_declaration")
75+
func k10():
76+
pass
77+
78+
@warning_ignore("inferred_declaration")
79+
func k11():
80+
pass
81+
82+
@warning_ignore("unsafe_property_access")
83+
func k12():
84+
pass
85+
86+
@warning_ignore("unsafe_method_access")
87+
func k13():
88+
pass
89+
90+
@warning_ignore("unsafe_cast")
91+
func k14():
92+
pass
93+
94+
@warning_ignore("unsafe_call_argument")
95+
func k15():
96+
pass
97+
98+
@warning_ignore("unsafe_void_return")
99+
func k16():
100+
pass
101+
102+
@warning_ignore("return_value_discarded")
103+
func k17():
104+
pass
105+
106+
@warning_ignore("static_called_on_instance")
107+
func k18():
108+
pass
109+
110+
@warning_ignore("redundant_await")
111+
func k19():
112+
pass
113+
114+
@warning_ignore("assert_always_true")
115+
func k20():
116+
pass
117+
118+
@warning_ignore("assert_always_false")
119+
func k21():
120+
pass
121+
122+
@warning_ignore("integer_division")
123+
func k22():
124+
pass
125+
126+
@warning_ignore("narrowing_conversion")
127+
func k23():
128+
pass
129+
130+
@warning_ignore("int_as_enum_without_cast")
131+
func k24():
132+
pass
133+
134+
@warning_ignore("int_as_enum_without_match")
135+
func k25():
136+
pass
137+
138+
@warning_ignore("enum_variable_without_default")
139+
func k26():
140+
pass
141+
142+
@warning_ignore("deprecated_keyword")
143+
func k27():
144+
pass
145+
146+
@warning_ignore("confusable_identifier")
147+
func k28():
148+
pass
149+
150+
@warning_ignore("confusable_local_declaration")
151+
func k29():
152+
pass
153+
154+
@warning_ignore("confusable_local_usage")
155+
func k30():
156+
pass
157+
158+
@warning_ignore("confusable_capture_reassignment")
159+
func k31():
160+
pass
161+
162+
@warning_ignore("inference_on_variant")
163+
func k32():
164+
pass
165+
166+
@warning_ignore("native_method_override")
167+
func k33():
168+
pass

0 commit comments

Comments
 (0)