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

Add capability to mark arguments ignored #11

Closed
harningt opened this issue Jan 6, 2015 · 3 comments
Closed

Add capability to mark arguments ignored #11

harningt opened this issue Jan 6, 2015 · 3 comments

Comments

@harningt
Copy link

harningt commented Jan 6, 2015

In developing some APIs, arguments to a function may not be used but are critical to matching the API the object defines.

Ex (horribly ugly to reduce line-height)

local a = { __index = {} }
local b = { __index = {} }
-- self ignored
function a.__index.apply_stuff(self, y, z)
    return y + z
end
-- z ignored
function b.__index.apply_stuff(self, y, z)
    return self.x + y
end

Perhaps using a _ suffix or prefix would be good to indicate parameters unused... probably via configuration option. Example w/ prefix applied:

local a = { __index = {} }
local b = { __index = {} }
-- self ignored
function a.__index.apply_stuff(_self, y, z)
    return y + z
end
-- z ignored
function b.__index.apply_stuff(self, y, _z)
    return self.x + y
end
@mpeterv
Copy link
Owner

mpeterv commented Jan 6, 2015

I agree that this can be useful, but IMO the usecase is too small and specific to make an option for it. In the next version (0.8.0) I plan to add a more flexible system for filtering warnings using numeric codes, then it should be possible to use something like --ignore 212/_.* to achieve the effect of your suggestion (prefix version; 212 is code for unused argument warning, _.* is a pattern matching ignored names).

@mpeterv
Copy link
Owner

mpeterv commented Jan 6, 2015

In the meantime you can use -a, though it filters out too many warnings (all unused arguments and loop variables).

@mpeterv
Copy link
Owner

mpeterv commented Jan 9, 2015

New filtering system implemented on master branch, --ignore 212/_.* works. Unfortunately bleeding-edge version is not very useful now (warning codes are not documented or displayed and there are some half-implemented new warnings). I expect to release 0.8.0 anywhere from next week to the end of January.

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

No branches or pull requests

2 participants