mpeterv / luacheck

A tool for linting and static analysis of Lua code.
MIT License
1.92k stars 322 forks source link

[w212] Unused Argument "self" #173

Closed cyw3 closed 6 years ago

cyw3 commented 6 years ago
function a.new(self, agrs)
    agrs = 4
end

test.lua:64:17: unused argument 'self'

When I use luacheck to scan my project, there are many warnings about Unused Argument "self". What can i do for it?

mpeterv commented 6 years ago

If not using an argument is correct, you can name it as _ and it will be ignored. You can silence all warnings about unused arguments named self with --ignore 212/self or equivalents in config and inlne options. See documentation.

smackesey commented 5 years ago

Many linters take this convention further by allowing you to prefix a named argument with _. This is better to keep track of what the arguments are even when not using them. Would you consider adjusting the rule to allow for this? Thanks.