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

Check if module was required to a local variable #185

Open
keeprocking opened this issue Oct 17, 2018 · 3 comments
Open

Check if module was required to a local variable #185

keeprocking opened this issue Oct 17, 2018 · 3 comments

Comments

@keeprocking
Copy link

According to https://luacheck.readthedocs.io/en/stable/warnings.html, there's no warnings for cases when a module being required is not assigned to a local variable, e.g.

require 'foo.bar'

instead of

local bar = require 'foo.bar'

Is it possible to add one? I would love to have a separate warning code for this because I need to differ such cases from "113 - Accessing an undefined global variable".

Thank you.

@mpeterv
Copy link
Owner

mpeterv commented Oct 17, 2018

This can be added, yes. In case require argument is a literal it could use it as the warning "name" for filtering, so that something like ignore = {"xxx"}; only = {"xxx/foo%.bar"} enabled the warning only for foo.bar module (where xxx is the new warning code). Or perhaps the warning should be disabled by default, then the ignore option is not needed.

@keeprocking
Copy link
Author

Sorry, I don't understand.
If I want to spot all the places (without knowing which modules are actually being required) where require is called without saving its result to a local variable, how do I do that?
Is it possible with existing config options?

@keeprocking
Copy link
Author

Petya? Some help would be much appreciated!

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