godot-gdscript-toolkit icon indicating copy to clipboard operation
godot-gdscript-toolkit copied to clipboard

New Lint rule: prefer shorthand node paths

Open Shinigami92 opened this issue 2 years ago • 2 comments
trafficstars

Name of rule open to be defined :)

I would like to get lint errors for

get_node("Area2D/CollisionShape2D")
get_node("Timer")

and it should be used like this

$Area2D/CollisionShape2D
$Timer

Shinigami92 avatar Nov 04 '23 21:11 Shinigami92

To me that idea sounds good, but I'm wondering if there are any potential corner-cases where this would be a false-positive... @Shinigami92 any ideas?

Scony avatar Dec 06 '23 21:12 Scony

[...] but I'm wondering if there are any potential corner-cases where this would be a false-positive... @Shinigami92 any ideas?

Yes! I think it might not be possible if get_node is called on something else than self.

I'm currently in vacation, so will explore some more in detail later when I'm back

Shinigami92 avatar Dec 07 '23 11:12 Shinigami92

I've been thinking about it further and I think that check would be too pedantic. It would be a good candidate if gdlint would have remarks like in pylint, but it's not planned so IMO not worth implementing this one.

Scony avatar Mar 21 '24 21:03 Scony