Luacheck module¶
Use local luacheck = require "luacheck" to import luacheck module. It contains the following functions:
- luacheck.get_report(source): Given source string, returns analysis data (a table).
- luacheck.process_reports(reports, options): Processes array of analysis reports and applies options.- reports[i]uses- options,- 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 Config options. Analysis reports with field- fatalare ignored.- process_reportsreturns final report, see Report format.
- luacheck.check_strings(sources, options): Checks array of sources using options, returns final report. Tables with field- fatalwithin- sourcesarray are ignored.
- luacheck.check_files(files, options): 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 format.
luacheck._VERSION contains Luacheck version as a string in MAJOR.MINOR.PATCH format.
Using luacheck as a function is equivalent to calling luacheck.check_files.
Report format¶
A final report is an array of file reports plus fields warnings, errors and 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 occurred while checking a file, its report will have fatal field containing error type and msg field containing error message.
An issue is a table with field code indicating its type (see List of warnings), and fields line, column and end_column pointing to the source of the warning. name field may contain name of related variable. Issues of some types can also have additional fields:
| Codes | Additional fields | 
|---|---|
| 011 | 
 | 
| 111 | 
 | 
| 122, 142, 143 | 
 | 
| 122, 142, 143 | 
 | 
| 211 | 
 | 
| 211 | 
 | 
| 211 | 
 | 
| 314 | 
 | 
| 4.. | 
 | 
| 521 | 
 | 
| 631 | 
 | 
| 631 | 
 | 
Other fields may be present for internal reasons.