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

A way to disable "setting non-standard global variable" ? #3

Closed
kernelp4nic opened this issue Jun 3, 2014 · 6 comments
Closed

A way to disable "setting non-standard global variable" ? #3

kernelp4nic opened this issue Jun 3, 2014 · 6 comments

Comments

@kernelp4nic
Copy link

Hello Peter,

There is a way via command line to just disable this setting? On our (kinda old) code I need to expose some globals in a module. There is a way to disable this check via command line args?

I still want to check for accessing global variables (I don't want --no-global)

Example:

-- test.lua
function bar() end
foo()
Checking test.lua                        Failure

    test.lua:1:10: setting non-standard global variable bar
    test.lua:2:1: accessing undefined variable foo

Total: 2 warnings / 0 errors in 1 file

I just want one warning on this (accessing undefined variable foo)

@mpeterv
Copy link
Owner

mpeterv commented Jun 3, 2014

I could simply add an option to filter such warnings, but I think it would be more useful to have an option(e,g, --allow-defined) which also allows accessing globals set elsewhere. E.g.

bar = {}
function bar.foo() end
...
bar.foo()

wouldn't produce warnings with such option enabled. This is actually on my (virtual) todo list, so it will be added by the next release.

@mpeterv
Copy link
Owner

mpeterv commented Jun 4, 2014

I've just added an option(--allow-defined/-d) on master branch. It removes all setting non-standard global variable warnings and also removes accessing undefined variable warnings for globals set elsewhere.

@X-Raym
Copy link

X-Raym commented May 19, 2016

Hi ! How can I activate this setting ?

@mpeterv
Copy link
Owner

mpeterv commented May 19, 2016

@X-Raym hi, you can pass -d to luacheck or add allow_defined = true to luacheck config called .luacheckrc. Alternatively, pass the globals you define to --globals.

@X-Raym
Copy link

X-Raym commented May 19, 2016

Thank you again for your quick support !

I tried to modify the file located in /usr/local/lib/luarocks/rocks-5.2/luacheck/0.15.0-1/spec/configs/projectbut without success. The same errors message are still visible.

If may be more flexible if we had buttons (or at least config settings) to toggle these behaviors right from Atom. 🎅
Maybe it could filter luacheck warnings list output rather than modifying its config file.
Just an idea, I don't know if it is possible.

@mpeterv
Copy link
Owner

mpeterv commented May 19, 2016

@X-Raym try modifying file called .luacheckrc in the root of your project.

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

3 participants