GDQuest / GDQuest/GDScript-formatter

Linter: no-else-return failing to detect return in this case

Offen
#339 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Rust
Sterne
455
Forks
39
Ø Merge
1 T. 15 Std.
Gemergte PRs (30 T.)
4

Beschreibung

There is a bug in your linter that causes it to not recognize that the designated block can fail the if statement and skip the return statement:
1) The incorrect warning is:
“WARNING on line 75 (no-else-return)
Unnecessary 'else' after 'if'/'elif' blocks that end with 'return'”

2) The code that triggered this error is:
...
#Return false if vector_angle falls between start_arc and end_arc.
#This will ensure that weapons can only fire within their designated arcs.
if end_arc > start_arc:
if vector_angle > end_arc or vector_angle < start_arc:
return false
else:
if vector_angle > end_arc and vector_angle < start_arc:
return false

#Ensure target is within range
if vector_to_target.length() > ability_range:
return false
else:
return true

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Start at the linter implementation for the no-else-return rule and reproduce the warning with the provided nested if/else snippet. Done means the rule no longer reports the final else as unnecessary when the preceding branch can continue, with regression coverage for this case.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
godot, rust
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
68/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.