feat(diagnostic): report unresolved require modules#968
feat(diagnostic): report unresolved require modules#968lewis6991 wants to merge 1 commit intoEmmyLuaLs:mainfrom
Conversation
Summary of ChangesHello @lewis6991, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new diagnostic feature that helps developers identify Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new unresolved-require diagnostic to report require calls for modules that cannot be found. The implementation extends the existing RequireModuleVisibilityChecker to handle this new check. When a module path from a require call with a string literal argument cannot be resolved, a WARNING is now correctly emitted. The changes are well-implemented and include tests covering cases for resolved, unresolved, and non-literal module paths.
|
This check is unnecessary; we can import |
But then these are not type checked and you get |
|
This is only an ideal scenario; in the current ecosystem, there exists a vast number of third-party libraries with undeclared types. |
|
What benefit do you get from this tool if libraries can't be resolved? So many things will not work: hover, goto, most diagnostics, etc. Having a single warning for each unresolved module shouldn't be that bad. It's certainly not unnecessary. And if it is that bad, what is so bad about downgrading the warning per project? I find it's much better for checks to be strict by default, rather than requiring users to enable everything. Selectively downgrading is much safer. I understand that some environments do not have very good typing for the libraries they import, and that is why I made this a warning instead of an error. |
|
If the library path is incorrect, |
|
Sorry I don't understand this point. One of the main uses of emmylua (and all static analysis tools) is to catch issues statically (early) rather than at runtime (late). |
Add an unresolved-require diagnostic for require("...") calls that
resolve to a string module path but cannot be found in the module index.
Extend the existing require visibility checker to emit
unresolved-require when module lookup fails.
7bbf876 to
b409937
Compare
|
Have you considered the scenario when importing a |
|
If you really want to join, then its warning level needs to be |
|
I think that since we're going to diagnose require, ambiguous require calls should also be detected. |
这样做那么你每个小脚本在引用到 luarocks 时都要建立一个 |
Meta files should be provided so the module can be resolved, even if the meta file just returns
If it's overridden, then surely it must still provide the same interface? Otherwise, the code is too dynamic and isn't very good to use with emmylua.
The check doesn't say the module doesn't exist, just that the checker cannot resolve it, which is important and worth having a warning for. It either indicates that the checkers environment isn't setup correctly, or there is a genuine typo in the module name. |
Add an unresolved-require diagnostic for require("...") calls that
resolve to a string module path but cannot be found in the module index.
Extend the existing require visibility checker to emit
unresolved-require when module lookup fails.