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

Warn on pass-through functions #47

Open
arichard4 opened this issue Dec 17, 2021 · 1 comment
Open

Warn on pass-through functions #47

arichard4 opened this issue Dec 17, 2021 · 1 comment

Comments

@arichard4
Copy link

Developers who aren’t familiar with lua often don’t understand that functions are first-class citizens in lua. This results in creating functions that do nothing but call another function, passing any parameters to the outer function into the inner function.

One bit of (unlintable) complexity: sometimes, the outer function can be used to deliberately pass in fewer parameters to an inner function; ie inner function takes 3 parameters, outer function takes 2 and calls the inner function with an implicit nil third parameter, but at a call site that passes the outer function three parameters.

@alerque
Copy link
Member

alerque commented Jan 22, 2022

I think the "sometimes" caveat here is probably frequent enough and valid enough that warning on other cases is probably not worthwhile. That being said are you sure we can't lint for it? If we can track unused variables wouldn't we be able to figure out if everything being passed in was used, if there are unused args... Nevermind even in starting to write this I see why it is unlintable. Also there are other use cases such as passing additional arguments from the surrounding scope to the inside function.

I can't imagine this not throwing for too many false positives to be useful. We would need a third level of notice — something below warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants