Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gdlint: missing support for functions on class-definitions-order: #277

Open
MikeSchulze opened this issue Jan 23, 2024 · 3 comments
Open
Labels
discussion Let's discuss enhancement New feature or request linter
Milestone

Comments

@MikeSchulze
Copy link

Hi, I love the tool, but I miss the option to sort by function types.

Please add options to check the sort order, for static, public and private functions

class-definitions-order:
  - static_func
  - public_func
  - private_func
@MikeSchulze MikeSchulze changed the title gdlint missing support for functions on class-definitions-order: gdlint: missing support for functions on class-definitions-order: Jan 23, 2024
@Scony Scony added the enhancement New feature or request label Jan 23, 2024
@Scony
Copy link
Owner

Scony commented Jan 23, 2024

I think I was going to add it at some point, but there is an ambiguity regarding some core functions inherited e.g. from Node etc.

Consider the code:

func _ready():
    pass
func public_foo():
    pass
func _private_foo():
    pass

To me, the above order is ok - first we got essential, inherited functions , then public ones ,then private ones. The problem is, however, that the gdtoolkit is unable to tell if _ready() is implicitly inherited and therefore it cannot differentiate between _ready() and _private_foo(). Thus having

class-definitions-order:
  - static_func
  - public_func
  - private_func

would require the code to be:

func public_foo():
    pass
func _ready():
    pass
func _private_foo():
    pass

How would you resolve that?

@Scony Scony added the discussion Let's discuss label Jan 23, 2024
@MikeSchulze
Copy link
Author

Hello, thank you for the answer.
I would not make a distinction between core and user private functions.
But if you can read the original class definition, it would be possible.
Unfortunately, I don't see an example of static functions in your example.

class-definitions-order:
  - static_func
  - public_func
  - private_func

Should be result in

static func bar():
    pass
static func _bar():
    pass
func foo():
    pass
func _ready():
    pass
func _foo():
    pass

@Scony
Copy link
Owner

Scony commented Jan 24, 2024

Okay, I'll experiment with that.

@Scony Scony added the linter label Mar 21, 2024
@Scony Scony added this to the 4.x milestone Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Let's discuss enhancement New feature or request linter
Projects
Status: No status
Development

No branches or pull requests

2 participants