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

inline command globals doesn't work with variables on the same line #210

Closed
artemreyt opened this issue Nov 26, 2020 · 3 comments
Closed

Comments

@artemreyt
Copy link

Here is example of code:

global_number = io.read("number") -- luacheck: globals global_number

global_number = global_number * 2
if global_number > 0 then
    print("Positive")
else
    print("Non-positive")
end

Run luacheck:

$ luacheck --codes globals_luacheck.lua
Checking globals_luacheck.lua                     3 warnings

    globals_luacheck.lua:3:1: (W111) setting non-standard global variable global_number
    globals_luacheck.lua:3:17: (W113) accessing undefined variable global_number
    globals_luacheck.lua:4:4: (W113) accessing undefined variable global_number

Total: 3 warnings / 0 errors in 1 file

It will be ok if to place -- luacheck: globals global_number on the line before declaring global_number, but our code style tells to add inline options on the same line with code. Other inline command work in this way.

@artemreyt
Copy link
Author

Created the same issue in forked luarocks repo.

@alerque
Copy link

alerque commented Oct 7, 2021

Thank you for migrating this issue to the new official repository. Can I request you close this one to help tidy up? I'm looking for things than need migrating and the fewer open issues here the better.

@artemreyt
Copy link
Author

Of course, thanks!

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

No branches or pull requests

2 participants