LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

luacheck

static analyzer and linter for Lua

TLDR

Check a Lua file
$ luacheck [file.lua]
copy
Check all Lua files in a directory recursively
$ luacheck [directory]
copy
Check with a specific Lua standard
$ luacheck --std [lua53] [file.lua]
copy
Ignore specific warning codes
$ luacheck --ignore [211] [file.lua]
copy
Check showing warning codes in output
$ luacheck --codes [file.lua]
copy
Output in a specific format
$ luacheck --formatter [TAP|JUnit|plain|visual_studio] [file.lua]
copy
Check multiple files in parallel
$ luacheck -j [4] [file1.lua] [file2.lua]
copy
Check from stdin with a custom filename
$ cat [file.lua] | luacheck --filename [file.lua] -
copy

SYNOPSIS

luacheck [options] files...

DESCRIPTION

luacheck is a static analyzer and linter for Lua. It detects various issues including undefined globals, unused variables, unreachable code, and stylistic problems.luacheck supports multiple Lua versions and can be configured per-project via a .luacheckrc file or inline comments.

PARAMETERS

--std std

Set standard globals (lua51, lua52, lua53, lua54, luajit, ngx_lua, love, busted, min, max, none).
-g, --no-global
Exclude warnings about global variables.
-u, --no-unused
Exclude warnings about unused variables and values.
-r, --no-redefined
Exclude warnings about redefined variables.
-a, --no-unused-args
Exclude warnings about unused arguments and loop variables.
-s, --no-unused-secondaries
Exclude warnings about unused variables set alongside used ones.
-d, --allow-defined
Allow implicit global definitions via assignment.
-t, --allow-defined-top
Allow implicit global definitions at top level scope only.
-i, --ignore patt ...
Filter out warnings matching patterns.
-o, --only patt ...
Show only warnings matching patterns.
-e, --enable patt ...
Re-enable warnings matching patterns.
--globals names ...
Add custom allowed global variables.
--read-globals names ...
Add read-only global variables.
--max-line-length length
Set maximum line length (default: 120). Use --no-max-line-length to disable.
--max-cyclomatic-complexity limit
Set maximum cyclomatic complexity for functions.
--formatter fmt
Output format (default, TAP, JUnit, visual_studio, plain).
--codes
Show warning codes in output.
--ranges
Show column ranges for warnings.
-q, --quiet
Suppress output for files without warnings. Use -qq or -qqq for less output.
-j, --jobs num
Check files in parallel (requires LuaLanes).
--cache [file]
Enable caching of results (default: .luacheckcache).
--config file
Path to custom configuration file (default: .luacheckrc).
--no-config
Disable configuration file loading.
--no-color
Disable colorized output.
--exclude-files glob ...
Skip files matching these glob patterns.
--include-files glob ...
Only check files matching these glob patterns.

CONFIGURATION

$ -- .luacheckrc
std = "lua53"
globals = {"myGlobal"}
ignore = {"212"}  -- unused argument
max_line_length = 120
copy

INSTALL

sudo pacman -S luacheck
copy
sudo apk add luacheck
copy
brew install luacheck
copy

CAVEATS

Static analysis only; won't catch runtime errors. May have false positives with dynamic code. Parallel checking with -j requires the LuaLanes library.

HISTORY

luacheck was created by Peter Melnichenko as a comprehensive Lua static analysis tool, filling the gap of linting tools for Lua.

SEE ALSO

lua(1), luac(1), selene(1), stylua(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid