Scony / godot-gdscript-toolkit

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

Function definitions with multi-lined parameters have the same indentation as the function body #226

Closed RedWheeler closed 10 months ago

RedWheeler commented 1 year ago

Functions with arguments that are too long to fit on a single line are multi-lined with the same indentation as the function body, making it difficult to differentiate between the function body and definition. Perhaps it would be better to increase the indentation for the arguments to better differentiate the two. For example:

func function_name(
    argument_1 : Type,
    argument_2 : Type,
    argument_3 : Type,
    argument_4 : Type,
    argument_5 : Type 
) -> ReturnType:
    line of similar length
    line of similar length
    line of similar length
    ...

vs

func function_name(
        argument_1 : Type,
    argument_2 : Type,
    argument_3 : Type,
    argument_4 : Type,
    argument_5 : Type 
    ) -> ReturnType:
    line of similar length
    line of similar length
    line of similar length
    ...
Scony commented 1 year ago

Well, with such an approach we'd have an artificial indentation. Normally I'd say it's not a big problem as the functions are usually not indented much, but considering lambdas are now available, the above approach may lead to the enormous number of extra indentations in random places. Consider code like:

class X:
    func foo(
            argument_1 : Type,
            argument_2 : Type
    ):
        if true:
            var lmbda = func(
                    argument_x : Type,
                    argument_y : Type
            ): return 1

as you can see, the arguments of lambda which is on 3rd indentation level are very far to the right already.

Therefore IMO having a minimal indentation is better. It's also consistent with e.g. python's black module.

Scony commented 10 months ago

Unless there are any other arguments I think we can close this one.