在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):philips/lualint开源软件地址(OpenSource Url):https://github.com/philips/lualint开源编程语言(OpenSource Language):Lua 100.0%开源软件介绍(OpenSource Introduction):lualint performs luac-based static analysis of global variable usage in Lua source code.
Descriptionlualint uses luac's bytecode listing. It reports all accesses to undeclared global variables, which catches many typing errors in variable names. For example:
It is primarily designed for use on LTN7-style modules, where each source file only exports one global symbol. (A module contained in the file "foobar.lua" should only export the symbol "foobar".) A "relaxed" mode is available for source not in LTN7 style. It only detects reads from globals that were never set. The switch "-r" puts lualint into relaxed mode for the following files; "-s" switches back to strict. Required packages are tracked, although not recursively. If you call "myext.process()" you should require "myext", and not depend on other dependencies to load it. LUA_PATH is followed as usual to find requirements. Some (not strictly LTN7) modules may wish to export other variables into the global environment. To do so, use the declare function:
Similarly, to quiet warnings about reading global variables you are aware may be unavailable:
One way of defining these is in a module "declare.lua":
(Setting declare is OK, because it's in the "declare" module.) These functions don't have to do anything, or in fact actually exist! They can be in dead code:
This is because lualint only performs a rather primitive and cursory scan of the bytecode. Perhaps declarations should only be allowed in the main chunk. TODOThe errors don't come out in any particular order. Should switch to RiciLake's parser, which should do a much better job of this and allow detection of some other common situations. CREDITSJayCarlson ([email protected]) This is all Ben Jackson's ([email protected]) fault, who did some similar tricks in MOO. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论