Scony / godot-gdscript-toolkit

Independent set of GDScript tools - parser, linter, formatter, and more
MIT License
944 stars 65 forks source link

A few config questions (calling private function from static function) #307

Closed NamespaceV closed 4 days ago

NamespaceV commented 3 months ago
  1. Can I turn off warnings for private method calls in static functions of the class. I don't want this to be reported as an error:
    
    class_name X;

static func create() ->X: var x = X.new() x._private() return x

func _private(): pass



2. Can I turn off errors on private/public functions order.
I often mix private and public functions to keep them in coherent regions.
I would like to keep all the other order checks, but i don't want to get errors when private and public functions are mixed.
Scony commented 3 months ago

Hi,

you can either mark particular lines not to report errors using this mechanism: https://github.com/Scony/godot-gdscript-toolkit/wiki/3.-Linter#disabling-checks-on-demand

or you can create settings like advised here: https://github.com/Scony/godot-gdscript-toolkit/wiki/3.-Linter#tweaking-default-check-settings and then either set private-method-call to None like private-method-call: None or using disable so smth like disable: [private-method-call] (I don't remember exactly).

NamespaceV commented 3 months ago

I created a .gdlintrc to tweak a few settings. I can't find a good way for both above.

About 2 - I guess private and public functions mixing is not reported at all, so its kinda fine for me... I would like to force subclass class definitions at the end of the file though I guess its not an issue for me then, but some food for thought on allowing configuration of orders like:

- X
- mix of A,B,C
- Z

About 1 - I often use static factory functions in my classes. I think this is gdlint error to report private function access as an error in a static function of the class defining said private function.

I do want to have access to privates of other classes reported. And i'd rather not annotate all my factory functions with

# gdlint: disable=private-method-call
func SomeWrongName():
    pass
# gdlint: enable=private-method-call

nor

# gdlint: ignore=private-method-call

especially as i want private method calls to be reported. But not when static method of the class calls a private method of said class. I consider static methods internals of the class so they should be able to call private functions.

Scony commented 4 days ago

Actually, the private-method-call check was removed in fcd3067585733b897b6a8b02da75fd53341b4285 so closing this issue as not relevant anymore