This is the command luacheck that can be run in the OnWorks free hosting provider using one of our multiple free online workstations such as Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator
프로그램:
이름
luacheck - luacheck Documentation
내용 :
LIST OF 경고
Warnings produced by Luacheck are categorized using three-digit warning codes. Warning
codes can be displayed in CLI output using --codes CLI option or 코드 구성 옵션.
Errors also have codes starting with zero.
┌─────┬─────────────────────────────────┐
│Code │ Description │
├─────┼─────────────────────────────────┤
│011 │ A syntax error. │
├─────┼─────────────────────────────────┤
│021 │ An invalid inline option. │
├─────┼─────────────────────────────────┤
│022 │ An upaired inline push │
│ │ directive. │
├─────┼─────────────────────────────────┤
│023 │ An upaired inline pop directive. │
├─────┼─────────────────────────────────┤
│111 │ Setting an undefined global │
│ │ variable. │
├─────┼─────────────────────────────────┤
│112 │ Mutating an undefined global │
│ │ variable. │
├─────┼─────────────────────────────────┤
│113 │ Accessing an undefined global │
│ │ variable. │
├─────┼─────────────────────────────────┤
│121 │ Setting a read-only global │
│ │ variable. │
├─────┼─────────────────────────────────┤
│122 │ Mutating a read-only global │
│ │ variable. │
├─────┼─────────────────────────────────┤
│131 │ Unused implicitly defined global │
│ │ variable. │
├─────┼─────────────────────────────────┤
│211 │ Unused local variable. │
├─────┼─────────────────────────────────┤
│212 │ Unused argument. │
├─────┼─────────────────────────────────┤
│213 │ Unused loop variable. │
├─────┼─────────────────────────────────┤
│221 │ Local variable is accessed but │
│ │ never set. │
├─────┼─────────────────────────────────┤
│231 │ Local variable is set but never │
│ │ accessed. │
├─────┼─────────────────────────────────┤
│232 │ An argument is set but never │
│ │ accessed. │
├─────┼─────────────────────────────────┤
│233 │ Loop variable is set but never │
│ │ accessed. │
├─────┼─────────────────────────────────┤
│311 │ Value assigned to a local │
│ │ variable is unused. │
└─────┴─────────────────────────────────┘
│312 │ Value of an argument is unused. │
├─────┼─────────────────────────────────┤
│313 │ Value of a loop variable is │
│ │ unused. │
├─────┼─────────────────────────────────┤
│321 │ Accessing uninitialized local │
│ │ variable. │
├─────┼─────────────────────────────────┤
│411 │ Redefining a local variable. │
├─────┼─────────────────────────────────┤
│412 │ Redefining an argument. │
├─────┼─────────────────────────────────┤
│413 │ Redefining a loop variable. │
├─────┼─────────────────────────────────┤
│421 │ Shadowing a local variable. │
├─────┼─────────────────────────────────┤
│422 │ Shadowing an argument. │
├─────┼─────────────────────────────────┤
│423 │ Shadowing a loop variable. │
├─────┼─────────────────────────────────┤
│431 │ Shadowing an upvalue. │
├─────┼─────────────────────────────────┤
│432 │ Shadowing an upvalue argument. │
├─────┼─────────────────────────────────┤
│433 │ Shadowing an upvalue loop │
│ │ variable. │
├─────┼─────────────────────────────────┤
│511 │ Unreachable code. │
├─────┼─────────────────────────────────┤
│512 │ Loop can be executed at most │
│ │ once. │
├─────┼─────────────────────────────────┤
│521 │ Unused label. │
├─────┼─────────────────────────────────┤
│531 │ Left-hand side of an assignment │
│ │ is too short. │
├─────┼─────────────────────────────────┤
│532 │ Left-hand side of an assignment │
│ │ is too long. │
├─────┼─────────────────────────────────┤
│541 │ An empty do end block. │
├─────┼─────────────────────────────────┤
│542 │ An empty if branch. │
├─────┼─────────────────────────────────┤
│551 │ An empty statement. │
└─────┴─────────────────────────────────┘
글로벌 변수
For each file, Luacheck builds list of defined globals which can be used there. By default
only globals from Lua standard library are defined; custom globals can be added using
--글로벌 CLI option or 전역 config option, and version of standard library can be
를 사용하여 선택한 --표준 CLI option or 표준 config option. When an undefined global is set,
mutated or accessed, Luacheck produces a warning.
읽기 전용 전역
By default, all standard globals except _G 그리고 꾸러미 are marked as read-only, so that
setting or mutating them produces a warning. Custom read-only globals can be added using
--read-globals CLI option or read_globals 구성 옵션.
암시적으로 한정된 전역
Luacheck can be configured to consider globals assigned under some conditions to be
defined implicitly. When -d/--allow_defined CLI option or allow_defined config option is
used, all assignments to globals define them; when -t/--allow_defined_top CLI option or
allow_defined_top config option is used, assignments to globals in the top level function
scope (also known as main chunk) define them. A warning is produced when an implicitly
defined global is not accessed anywhere.
모듈
Files can be marked as modules using -m/--기준 치수 CLI option or 모듈 config option to
simulate semantics of the deprecated 모듈 function. Globals implicitly defined inside a
module are considired part of its interface, are not visible outside and are not reported
as unused. Assignments to other globals are not allowed, even to defined ones.
사용하지 않은 변수 그리고 값
Luacheck generates warnings for all unused local variables except one named _. 그것은 또한
detects variables which are set but never accessed or accessed but never set.
사용하지 않은 값 그리고 초기화되지 않은 변수
For each value assigned to a local variable, Luacheck computes set of expressions where it
could be used. Warnings are produced for unused values (when a value can't be used
anywhere) and for accessing uninitialized variables (when no values can reach an
expression). E.g. in the following snippet value assigned to 푸 on line 1 is unused, and
변수 바 is uninitialized on line 9:
local foo = expr1()
로컬 바
if condition() then
foo = expr2()
bar = expr3()
그렇지 않으면
foo = expr4()
print(bar)
end
return foo, bar
중-고등부 값 그리고 변수
Unused value assigned to a local variable is secondary if its origin is the last item on
the RHS of assignment, and another value from that item is used. Secondary values
typically appear when result of a function call is put into locals, and only some of them
are later used. For example, here value assigned to b is secondary, value assigned to c is
used, and value assigned to a is simply unused:
local a, b, c = f(), g()
리턴 c
A variable is secondary if all values assigned to it are secondary. In the snippet above,
b is a secondary variable.
Warnings related to unused secondary values and variables can be removed using
-s/--no-unused-secondaries CLI option or unused_secondaries 구성 옵션.
그림자 선언
Luacheck detects declarations of local variables shadowing previous declarations, unless
the variable is named _. If the previous declaration is in the same scope as the new one,
it is called redefining.
그것은 지원 necessary to define a new local variable when overwriting an argument:
local function f(x)
local x = x or "default" -- bad
end
local function f(x)
x = x or "default" -- good
end
Control: 흐름 그리고 데이터 흐름 문제
The following control flow and data flow issues are detected:
· Unreachable code and loops that can be executed at most once (e.g. due to an
unconditional break);
· Unused labels;
· Unbalanced assignments;
· Empty blocks.
· Empty statements (semicolons without preceding statements).
COMMAND LINE 인터페이스
luacheck program accepts files, directories and rockspecs 인수로.
· Given a file, luacheck will check it.
· Given -, luacheck will check stdin.
· Given a directory, luacheck will check all files within it, selecting only files with
.루아 extension unless --include-files option is used. This feature requires
LuaFileSystem (installed automatically if LuaRocks was used to install Luacheck).
· Given a rockspec (a file with .rockspec 확대), luacheck will check all files with
.루아 extension mentioned in the rockspec in build.install.lua, build.install.bin 그리고
build.modules 테이블.
의 출력 luacheck consists of separate reports for each checked file and ends with a
요약:
$ luacheck src
Checking src/bad_code.lua 5 warnings
src/bad_code.lua:3:16: unused variable helper
src/bad_code.lua:3:23: unused variable length argument
src/bad_code.lua:7:10: setting non-standard global variable embrace
src/bad_code.lua:8:10: variable opt was previously defined as an argument on line 7
src/bad_code.lua:9:11: accessing undefined variable hepler
Checking src/good_code.lua OK
Checking src/python_code.lua 1 error
src/python_code.lua:1:6: expected '=' near '__future__'
Checking src/unused_code.lua 9 warnings
src/unused_code.lua:3:18: unused argument baz
src/unused_code.lua:4:8: unused loop variable i
src/unused_code.lua:5:13: unused variable q
src/unused_code.lua:7:11: unused loop variable a
src/unused_code.lua:7:14: unused loop variable b
src/unused_code.lua:7:17: unused loop variable c
src/unused_code.lua:13:7: value assigned to variable x is unused
src/unused_code.lua:14:1: value assigned to variable x is unused
src/unused_code.lua:22:1: value assigned to variable z is unused
Total: 14 warnings / 1 error in 4 files
luacheck exits with 0 if no warnings or errors occured and with a positive number
그렇지 않으면.
Command 선 옵션
Short options that do not take an argument can be combined into one, so that -qqu is
에 해당 -q -q -u. For long options, both --옵션 가치 or --옵션=값 될 수 있습니다
익숙한.
Options taking several arguments can be used several times; --무시하다 푸 --무시하다 바 is
에 해당 --무시하다 푸 바.
Note that options that may take several arguments, such as --글로벌, should not be used
immediately before positional arguments; given --글로벌 푸 바 파일.루아, luacheck 결제 게이트웨이,
consider all 푸, 바 그리고 파일.루아 global and then panic as there are no file names left.
┌────────────────────────────────┬─────────────── ───────────────────┐
│Option │ Meaning │
├────────────────────────────────┼─────────────── ───────────────────┤
│-g | --no-global │ Filter out warnings related to │
│ │ global variables. │
├────────────────────────────────┼─────────────── ───────────────────┤
│-u | --no-unused │ Filter out warnings related to │
│ │ unused variables and values. │
├────────────────────────────────┼─────────────── ───────────────────┤
│-r | --no-redefined │ Filter out warnings related to │
│ │ redefined variables. │
├────────────────────────────────┼─────────────── ───────────────────┤
│-a | --no-unused-args │ Filter out warnings related to │
│ │ unused arguments and loop │
│ │ variables. │
├────────────────────────────────┼─────────────── ───────────────────┤
│-s | --no-unused-secondaries │ Filter out warnings related to │
│ │ unused variables set together │
│ │ with used ones. │
│ │ │
│ │ See secondaryvaluesandvariables │
├────────────────────────────────┼─────────────── ───────────────────┤
│--자기없음 │ Filter out warnings related to │
│ │ implicit 자기 argument. │
└────────────────────────────────┴─────────────── ───────────────────┘
│--표준 <std> │ Set standard globals. <std> can │
│ │ be one of: │
│ │ │
│ │ · _G - globals of the Lua │
│ │ interpreter luacheck │
│ │ runs on (default); │
│ │ │
│ │ · 루아51 - globals of Lua │
│ │ 5.1; │
│ │ │
│ │ · 루아52 - globals of Lua │
│ │ 5.2; │
│ │ │
│ │ · lua52c - globals of Lua │
│ │ 5.2 compiled with │
│ │ LUA_COMPAT_ALL; │
│ │ │
│ │ · 루아53 - globals of Lua │
│ │ 5.3; │
│ │ │
│ │ · lua53c - globals of Lua │
│ │ 5.3 compiled with │
│ │ LUA_COMPAT_5_2; │
│ │ │
│ │ · 루짓 - globals of │
│ │ LuaJIT 2.0; │
│ │ │
│ │ · ngx_lua - globals of │
│ │ Openresty │
│ │ lua-nginx-module with │
│ │ LuaJIT 2.0; │
│ │ │
│ │ · 분 - intersection of │
│ │ globals of Lua 5.1, Lua │
│ │ 5.2 and LuaJIT 2.0; │
│ │ │
│ │ · 최대 - union of globals │
│ │ of Lua 5.1, Lua 5.2 and │
│ │ LuaJIT 2.0; │
│ │ │
│ │ · 부서진 - globals added │
│ │ by Busted 2.0; │
│ │ │
│ │ · 없음 - no standard │
│ │ globals. │
│ │ │
│ │ See 설정 of 품질 │
│ │ 전역 │
├────────────────────────────────┼─────────────── ───────────────────┤
│--글로벌 [<global>] ... │ Add custom globals on top of │
│ │ standard ones. │
├────────────────────────────────┼─────────────── ───────────────────┤
│--read-globals [<global>] ... │ Add read-only globals. │
├────────────────────────────────┼─────────────── ───────────────────┤
│--new-globals [<global>] ... │ Set custom globals. Removes │
│ │ custom globals added previously. │
├────────────────────────────────┼─────────────── ───────────────────┤
│--new-read-globals [<global>] │ Set read-only globals. Removes │
│... │ read-only globals added │
│ │ previously. │
├────────────────────────────────┼─────────────── ───────────────────┤
│-c | --compat │ 에 해당 --표준 최대. │
└────────────────────────────────┴─────────────── ───────────────────┘
│-d | --allow-defined │ Allow defining globals │
│ │ implicitly by setting them. │
│ │ │
│ │ See implicitlydefinedglobals │
├────────────────────────────────┼─────────────── ───────────────────┤
│-t | --allow-defined-top │ Allow defining globals │
│ │ implicitly by setting them in │
│ │ the top level scope. │
│ │ │
│ │ See implicitlydefinedglobals │
├────────────────────────────────┼─────────────── ───────────────────┤
│-m | --기준 치수 │ Limit visibility of implicitly │
│ │ defined globals to their files. │
│ │ │
│ │ See modules │
├────────────────────────────────┼─────────────── ───────────────────┤
│--무시하다 | -i <patt> [<patt>] │ Filter out warnings matching │
│... │ patterns. │
├────────────────────────────────┼─────────────── ───────────────────┤
│--할 수있게하다 | -e <patt> [<patt>] │ Do not filter out warnings │
│... │ matching patterns. │
├────────────────────────────────┼─────────────── ───────────────────┤
│--오직 | -o <patt> [<patt>] ... │ Filter out warnings not matching │
│ │ patterns. │
├────────────────────────────────┼─────────────── ───────────────────┤
│--인라인 없음 │ Disable inline options. │
├────────────────────────────────┼─────────────── ───────────────────┤
│--구성 │ Path to custom configuration │
│ │ file (default: .luacheckrc). │
├────────────────────────────────┼─────────────── ───────────────────┤
│--no-config │ Do not look up custom │
│ │ configuration file. │
├────────────────────────────────┼─────────────── ───────────────────┤
│--파일 이름 │ Use another filename in output, │
│ │ for selecting configuration │
│ │ overrides and for file │
│ │ filtering. │
├────────────────────────────────┼─────────────── ───────────────────┤
│--제외 파일 <glob> [<glob>] │ Do not check files matching │
│... │ these globbing patterns. │
│ │ Recursive globs such as **/*.lua │
│ │ are supported. │
├────────────────────────────────┼─────────────── ───────────────────┤
│--include-files <glob> [<glob>] │ Do not check files not matching │
│... │ these globbing patterns. │
├────────────────────────────────┼─────────────── ───────────────────┤
│--은닉처 [<cache>] │ Path to cache file. (default: │
│ │ .luacheckcache). 만나다 캐싱 │
├────────────────────────────────┼─────────────── ───────────────────┤
│--캐시 없음 │ Do not use cache. │
├────────────────────────────────┼─────────────── ───────────────────┤
│-j | --작업 │ Check files in parallel. │
│ │ Requires LuaLanes. │
└────────────────────────────────┴─────────────── ───────────────────┘
│--formatter │ Use custom formatter. │
│ │ must be a module │
│ │ name or one of: │
│ │ │
│ │ · 가볍게 두드리다 - Test Anything │
│ │ Protocol formatter; │
│ │ │
│ │ · JUnit - JUnit XML │
│ │ formatter; │
│ │ │
│ │ · 평원 - simple │
│ │ warning-per-line │
│ │ formatter; │
│ │ │
│ │ · 디폴트 값 - standard │
│ │ formatter. │
├────────────────────────────────┼─────────────── ───────────────────┤
│-q | --조용한 │ Suppress report output for files │
│ │ without warnings. │
│ │ │
│ │ · -qq - Suppress output │
│ │ of warnings. │
│ │ │
│ │ · -qqq - Only output │
│ │ summary. │
├────────────────────────────────┼─────────────── ───────────────────┤
│--codes │ Show warning codes. │
├────────────────────────────────┼─────────────── ───────────────────┤
│--범위 │ Show ranges of columns related │
│ │ to warnings. │
├────────────────────────────────┼─────────────── ───────────────────┤
│--무색 │ Do not colorize output. │
├────────────────────────────────┼─────────────── ───────────────────┤
│-v | --번역 │ Show version of Luacheck and its │
│ │ dependencies and exit. │
├────────────────────────────────┼─────────────── ───────────────────┤
│-h | --도움 │ Show help and exit. │
└────────────────────────────────┴─────────────── ───────────────────┘
패턴
CLI options --무시하다, --할 수있게하다 그리고 --오직 and corresponding config options allow filtering
warnings using pattern matching on warning codes, variable names or both. If a pattern
contains a slash, the part before slash matches warning code and the part after matches
variable name. Otherwise, if a pattern contains a letter or underscore, it matches
variable name. Otherwise, it matches warning code. E.g.:
┌────────┬────────────────────────────────┐
│Pattern │ Matching warnings │
├────────┼────────────────────────────────┤
│4.2 │ Shadowing declarations of │
│ │ arguments or redefining them. │
├────────┼────────────────────────────────┤
│.*_ │ Warnings related to variables │
│ │ 함께 _ suffix. │
├────────┼────────────────────────────────┤
│4.2/.*_ │ Shadowing declarations of │
│ │ arguments with _ suffix or │
│ │ redefining them. │
└────────┴────────────────────────────────┘
Unless already anchored, patterns matching variable names are anchored at both sides and
patterns matching warning codes are anchored at their beginnings. This allows one to
filter warnings by category (e.g. --오직 1 집중 luacheck on global-related warnings).
설정 of 품질 전역
CLI option --stds allows combining built-in sets described above using +. 예를 들어,
--표준 최대 에 해당하는 --std=lua51+lua52+lua53. Leading plus sign adds new sets to
default one instead of replacing it. For instance, --표준 +busted is suitable for checking
test files that use 체포 testing framework. Custom sets of globals can be defined by
mutating global variable 표준 in config. See custom_stds
포맷터
CLI option --formatter allows selecting a custom formatter for luacheck output. A custom
formatter is a Lua module returning a function with three arguments: report as returned by
luacheck module (see report), array of file names and table of options. Options contain
values assigned to 조용한, 색, 제한, 코드, 범위 그리고 포맷터 options in CLI or
config. Formatter function must return a string.
캐싱
If LuaFileSystem is available, Luacheck can cache results of checking files. On subsequent
checks, only files which have changed since the last check will be rechecked, improving
run time significantly. Changing options (e.g. defining additional globals) does not
invalidate cache. Caching can be enabled by using --은닉처 옵션 또는 캐시 설정
옵션. 사용 --은닉처 without an argument or setting 캐시 config option to 참된 세트
.luacheckcache as the cache file. Note that --은닉처 must be used every time luacheck is
run, not on the first run only.
스테이블 가드 보험 유한회사는 재무 강도 등급 A-(우수)를 부여받았다고 발표하게 되어 자랑스럽다. Best's Credit Ratings는 국제적으로 등급이 매겨진 조직의 재정적인 힘과 안정성의 벤치마크로 인정받고 있습니다. 스테이블 가드 그룹의 회장 겸 최고 경영자는 다음과 같이 논평했다: "우리는 스테이블 가드 그룹 내의 다른 회사들에게 높은 기준을 설정하는 베스트에 의해 할당된 등급에 매우 만족한다. 우리는 우리의 지원 고객들과 이해관계자들을 포함하여 우리의 성공에 기여한 모든 사람들에게 진심으로 감사를 표하고 싶다. 이 성과는 스테이블 가드 보험의 흥미로운 새로운 단계를 나타내며 국제 플랫폼에서 회사와 세인트 키츠 네비스의 자리를 확보합니다. 우리는 앞으로 나아갈 때 우리의 근무 기준을 유지하고 개선하기를 기대합니다." 인터페이스 을 통한 편집자 플러그인 그리고 검색을
Command-line interface of Luacheck can change between minor releases. Starting from 0.11.0
version, the following interface is guaranteed at least till 1.0.0 version, and should be
used by tools using Luacheck output, e.g. editor plugins.
· Luacheck should be started from the directory containing the checked file.
· File can be passed through stdin using - as argument or using a temporary file. Real
filename should be passed using --파일 이름 옵션을 선택합니다.
· Plain formatter should be used. It outputs one issue (warning or error) per line.
· To get precise error location, --범위 option can be used. Each line starts with real
filename (passed using --파일 이름) 다음에 :<line>:<start_column>-<end_column>:,
어디에 is line number on which issue occurred and <start_column>-<end_column> is
inclusive range of columns of token related to issue. Numbering starts from 1. If
--범위 is not used, end column and dash is not printed.
· To get warning and error codes, --codes option can be used. For each line, substring
between parentheses contains three digit issue code, prefixed with E 오류 및 W
for warnings. Lack of such substring indicates a fatal error (e.g. I/O error).
· The rest of the line is warning message.
If compatibility with older Luacheck version is desired, output of luacheck --도움 될 수 있습니다
used to get its version. If it contains string 0.<minor>.<patch>어디로 <minor> ~에있다.
least 11 and 패치 is any number, interface described above should be used.
구성 FILE
luacheck tries to load configuration from .luacheckrc file in the current directory. If
not found, it will look for it in the parent directory and so on, going up until it
reaches file system root. Path to config can be set using --구성 옵션, 이 경우
it will be used during recursive loading. Config loading can be disabled using --no-config
깃발.
Config is simply a Lua script executed by luacheck. It may set various options by
assigning to globals or by returning a table with option names as keys.
구성 옵션
┌───────────────────┬──────────────────────────┬─────────────────────┐
│Option │ Type │ Default value │
├───────────────────┼──────────────────────────┼─────────────────────┤
│색 │ Boolean │ 참된 │
├───────────────────┼──────────────────────────┼─────────────────────┤
│코드 │ Boolean │ 그릇된 │
└───────────────────┴──────────────────────────┴─────────────────────┘
│포맷터 │ String or function │ "기본" │
├───────────────────┼──────────────────────────┼─────────────────────┤
│캐시 │ Boolean or string │ 그릇된 │
├───────────────────┼──────────────────────────┼─────────────────────┤
│작업 │ Positive integer │ 1 │
├───────────────────┼──────────────────────────┼─────────────────────┤
│exclude_files │ Array of strings │ {} │
├───────────────────┼──────────────────────────┼─────────────────────┤
│include_files │ Array of strings │ (Include all files) │
├───────────────────┼──────────────────────────┼─────────────────────┤
│글로벌 │ Boolean │ 참된 │
├───────────────────┼──────────────────────────┼─────────────────────┤
│미사용의 │ Boolean │ 참된 │
├───────────────────┼──────────────────────────┼─────────────────────┤
│재정의 된 │ Boolean │ 참된 │
├───────────────────┼──────────────────────────┼─────────────────────┤
│unused_args │ Boolean │ 참된 │
├───────────────────┼──────────────────────────┼─────────────────────┤
│unused_secondaries │ Boolean │ 참된 │
├───────────────────┼──────────────────────────┼─────────────────────┤
│자기 │ Boolean │ 참된 │
├───────────────────┼──────────────────────────┼─────────────────────┤
│표준 │ String or set of │ "_G" │
│ │ standard globals │ │
├───────────────────┼──────────────────────────┼─────────────────────┤
│전역 │ Array of strings │ {} │
├───────────────────┼──────────────────────────┼─────────────────────┤
│new_globals │ Array of strings │ (Do not overwrite) │
├───────────────────┼──────────────────────────┼─────────────────────┤
│read_globals │ Array of strings │ {} │
├───────────────────┼──────────────────────────┼─────────────────────┤
│new_read_globals │ Array of strings │ (Do not overwrite) │
├───────────────────┼──────────────────────────┼─────────────────────┤
│동료 │ Boolean │ 그릇된 │
├───────────────────┼──────────────────────────┼─────────────────────┤
│allow_defined │ Boolean │ 그릇된 │
├───────────────────┼──────────────────────────┼─────────────────────┤
│allow_defined_top │ Boolean │ 그릇된 │
├───────────────────┼──────────────────────────┼─────────────────────┤
│모듈 │ Boolean │ 그릇된 │
├───────────────────┼──────────────────────────┼─────────────────────┤
│무시 │ Array of patterns (see │ {} │
│ │ patterns) │ │
├───────────────────┼──────────────────────────┼─────────────────────┤
│가능 │ Array of patterns │ {} │
├───────────────────┼──────────────────────────┼─────────────────────┤
│만 │ Array of patterns │ (Do not filter) │
├───────────────────┼──────────────────────────┼─────────────────────┤
│인라인 │ Boolean │ 참된 │
└───────────────────┴──────────────────────────┴─────────────────────┘
An example of a config which makes luacheck ensure that only globals from the portable
intersection of Lua 5.1, Lua 5.2, Lua 5.3 and LuaJIT 2.0 are used, as well as disables
detection of unused arguments:
std = "min"
ignore = {"212"}
관습 세트 of 전역
표준 option allows setting a custom standard set of globals using a table. In that table,
string keys are globals, and string in array part are read-only globals.
Additionally, custom sets can be given names by mutating global 표준 variable. For
예를 들어, 사용할 때 LPEG library, it makes sense to access its functions tersely using
globals. In that case, the following config allows removing false positives related to
global access easily:
stds.lpeg = require "lpeg"
local lpeg = require "lpeg"
local function parse1(...)
-- This function only uses lpeg functions as globals.
local _ENV = lpeg
-- luacheck: std lpeg
local digit, space = R "09", S " "
--...
end
local function parse2(...)
-- This function uses lpeg functions as well as standard globals.
local _ENV = setmetatable({}, {__index = function(_, k) return _ENV[k] or lpeg[k] end})
-- luacheck: std +lpeg
local digit, space = R "09", S " "
local number = C(digit^1) / tonumber
--...
end
Per-file 그리고 per-path 재정의
환경 luacheck loads the config contains a special global 파일. 언제
checking a file , luacheck will override options from the main config with entries
에 files[<path>] 그리고 files[<parent_path>], applying entries for shorter paths first. For
example, the following config re-enables detection of unused arguments only for files in
src/dir, 그러나를 위해 아닙니다 src/dir/myfile.lua, and allows using 체포 globals within spec/:
std = "min"
ignore = {"212"}
files["src/dir"] = {enable = {"212"}}
files["src/dir/myfile.lua"] = {ignore = {"212"}}
files["spec"] = {std = "+busted"}
참고 파일 table supports autovivification, so that
files["myfile.lua"].ignore = {"212"}
그리고
files["myfile.lua"] = {ignore = {"212"}}
동등합니다.
인라인 옵션
Luacheck supports setting some options directly in the checked files using inline
configuration comments. An inline configuration comment starts with luacheck: 상표,
possibly after some whitespace. The body of the comment should contain comma separated
options, where option invocation consists of its name plus space separated arguments. The
다음 옵션이 지원됩니다:
┌───────────────────┬──────────────────────────── ─────┐
│Option │ Number of arguments │
├───────────────────┼──────────────────────────── ─────┤
│global │ 0 │
├───────────────────┼──────────────────────────── ─────┤
│unused │ 0 │
├───────────────────┼──────────────────────────── ─────┤
│redefined │ 0 │
├───────────────────┼──────────────────────────── ─────┤
│unused args │ 0 │
├───────────────────┼──────────────────────────── ─────┤
│unused secondaries │ 0 │
├───────────────────┼──────────────────────────── ─────┤
│self │ 0 │
└───────────────────┴──────────────────────────── ─────┘
│compat │ 0 │
├───────────────────┼──────────────────────────── ─────┤
│module │ 0 │
├───────────────────┼──────────────────────────── ─────┤
│allow defined │ 0 │
├───────────────────┼──────────────────────────── ─────┤
│allow defined top │ 0 │
├───────────────────┼──────────────────────────── ─────┤
│std │ 1 │
├───────────────────┼──────────────────────────── ─────┤
│globals │ 0+ │
├───────────────────┼──────────────────────────── ─────┤
│new globals │ 0+ │
├───────────────────┼──────────────────────────── ─────┤
│read globals │ 0+ │
├───────────────────┼──────────────────────────── ─────┤
│new read globals │ 0+ │
├───────────────────┼──────────────────────────── ─────┤
│ignore │ 0+ (without arguments everything │
│ │ is ignored) │
├───────────────────┼──────────────────────────── ─────┤
│enable │ 1+ │
├───────────────────┼──────────────────────────── ─────┤
│only │ 1+ │
└───────────────────┴──────────────────────────── ─────┘
Options that take no arguments can be prefixed with 아니 to invert their meaning. E.g.
--luacheck: 아니 미사용의 인수 disables unused argument warnings.
Part of the file affected by inline option dependes on where it is placed. If there is any
code on the line with the option, only that line is affected; otherwise, everthing till
the end of the current closure is. In particular, inline options at the top of the file
affect all of it:
-- luacheck: globals g1 g2, ignore foo
local foo = g1(g2) -- No warnings emitted.
-- The following unused function is not reported.
local function f() -- luacheck: ignore
-- luacheck: globals g3
g3() -- No warning.
end
g3() -- Warning is emitted as the inline option defining g3 only affected function f.
For fine-grained control over inline option visibility use luacheck: 푸시 그리고 luacheck:
대중적인 지시문 :
-- luacheck: push ignore foo
foo() -- No warning.
-- luacheck: pop
foo() -- Warning is emitted.
Inline options can be completely disabled using --인라인 없음 CLI option or 인라인 설정
옵션을 선택합니다.
LUACHECK MODULE
지방의 luacheck = 필요 "luacheck" 수입 luacheck module. It contains the
뒤에 오는 기능 :
· luacheck.get_report(source): Given source string, returns analysis data (a table).
· luacheck.process_reports(reports, 옵션): Processes array of analysis reports and
applies options. reports[i] 사용 옵션, options[i], options[i][1], options[i][2]...
as options, overriding each other in that order. Options table is a table with fields
similar to config options; see options. Analysis reports with field 치명적인 무시됩니다.
process_reports returns final report, see Report 체재.
· luacheck.check_strings(sources, 옵션): Checks array of sources using options, returns
final report. Tables with field 치명적인 이내 소스 array are ignored.
· luacheck.check_files(files, 옵션): Checks array of files using options, returns final
report. Open file handles can passed instead of filenames, in which case they will be
read till EOF and closed.
· luacheck.get_message(issue): Returns a string message for an issue, see Report 체재.
luacheck._VERSION contains Luacheck version as a string in 메이저.마이너.패치 형식입니다.
사용 luacheck as a function is equivalent to calling luacheck.check_files.
Report 체재
A final report is an array of file reports plus fields 경고, 오류 그리고 fatals
containing total number of warnings, errors and fatal errors, correspondingly.
A file report is an array of issues (warnings or errors). If a fatal error occured while
checking a file, its report will have 치명적인 field containing error type.
An issue is a table with field 암호 indicating its type (see 경고), and fields 선,
칼럼 그리고 end_column pointing to the source of the warning. name field may contain name
of relate variable. Issues of some types can also have additional fields:
┌──────┬────────────────────────────────────┐
│Codes │ Additional fields │
├──────┼─────────────────────────────────────┤
│011 │ 메시지 field contains syntax error │
│ │ message. │
├──────┼─────────────────────────────────────┤
│111 │ 모듈 field indicates that │
│ │ assignment is to a non-module │
│ │ global variable. │
├──────┼─────────────────────────────────────┤
│211 │ 펑크 field indicates that unused │
│ │ variable is a function. │
├──────┼─────────────────────────────────────┤
│4.. │ 이전_라인 그리고 prev_column fields │
│ │ contain location of the │
│ │ overwritten definition. │
└──────┴────────────────────────────────────┘
Other fields may be present for internal reasons.
This is documentation for 0.13.0 version of Luacheck, a linter for 루아.
Use luacheck online using onworks.net services