• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

bin/H25-Aug-2020-64

build/H25-Aug-2020-10377

docsrc/H25-Aug-2020-1,067638

scripts/H25-Aug-2020-247172

spec/H25-Aug-2020-10,2128,718

src/luacheck/H25-Aug-2020-10,4677,686

.bustedH A D25-Aug-202070 65

.gitignoreH A D25-Aug-2020180 1413

.luacheckrcH A D25-Aug-2020233 75

.luacovH A D25-Aug-202047 21

.travis.ymlH A D25-Aug-2020963 3731

CHANGELOG.mdH A D25-Aug-202022 KiB638464

LICENSEH A D25-Aug-20201.1 KiB2217

README.mdH A D25-Aug-20207.5 KiB14394

appveyor.ymlH A D25-Aug-2020628 3629

luacheck-dev-1.rockspecH A D25-Aug-20204.5 KiB8382

README.md

1# Luacheck
2
3[![Join the chat at https://gitter.im/luacheck/Lobby](https://badges.gitter.im/luacheck/Lobby.svg)](https://gitter.im/luacheck/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
5[![Build Status](https://travis-ci.org/luarocks/luacheck.png?branch=master)](https://travis-ci.org/luarocks/luacheck)
6[![Windows build status](https://ci.appveyor.com/api/projects/status/pgox2vvelagw1fux/branch/master?svg=true&passingText=Windows%20build%20passing&failingText=Windows%20build%20failing)](https://ci.appveyor.com/project/luarocks/luacheck/branch/master)
7[![codecov](https://codecov.io/gh/luarocks/luacheck/branch/master/graph/badge.svg)](https://codecov.io/gh/luarocks/luacheck)
8[![License](https://img.shields.io/badge/License-MIT-brightgreen.svg)](LICENSE)
9
10## Contents
11
12* [Overview](#overview)
13* [Installation](#installation)
14* [Basic usage](#basic-usage)
15* [Related projects](#related-projects)
16* [Documentation](#documentation)
17* [Development](#development)
18* [Building and testing](#building-and-testing)
19* [License](#license)
20
21## Overview
22
23Luacheck is a static analyzer and a linter for [Lua](http://www.lua.org). Luacheck detects various issues such as usage of undefined global variables, unused variables and values, accessing uninitialized variables, unreachable code and more. Most aspects of checking are configurable: there are options for defining custom project-related globals, for selecting set of standard globals (version of Lua standard library), for filtering warnings by type and name of related variable, etc. The options can be used on the command line, put into a config or directly into checked files as Lua comments.
24
25Luacheck supports checking Lua files using syntax of Lua 5.1, Lua 5.2, Lua 5.3 and LuaJIT. Luacheck itself is written in Lua and runs on all of mentioned Lua versions.
26
27## Installation
28
29### Using LuaRocks
30
31From your command line run the following command (using `sudo` if necessary):
32
33```
34luarocks install luacheck
35```
36
37For parallel checking Luacheck additionally requires [LuaLanes](https://github.com/LuaLanes/lanes), which can be installed using LuaRocks as well (`luarocks install lanes`).
38
39### Windows binary download
40
41For Windows there is single-file 64-bit binary distribution, bundling Lua 5.3.4, Luacheck, LuaFileSystem, and LuaLanes using [LuaStatic](https://github.com/ers35/luastatic):
42[download](https://github.com/luarocks/luacheck/releases/download/0.24.0/luacheck.exe).
43
44## Basic usage
45
46After Luacheck is installed, run `luacheck` program from the command line. Pass a list of files, [rockspecs](https://github.com/luarocks/luarocks/wiki/Rockspec-format) or directories (requires LuaFileSystem) to be checked:
47
48```
49luacheck src extra_file.lua another_file.lua
50```
51
52```
53Checking src/good_code.lua               OK
54Checking src/bad_code.lua                3 warnings
55
56    src/bad_code.lua:3:23: unused variable length argument
57    src/bad_code.lua:7:10: setting non-standard global variable embrace
58    src/bad_code.lua:8:10: variable opt was previously defined as an argument on line 7
59
60Checking src/python_code.lua             1 error
61
62    src/python_code.lua:1:6: expected '=' near '__future__'
63
64Checking extra_file.lua                  5 warnings
65
66    extra_file.lua:3:18: unused argument baz
67    extra_file.lua:4:8: unused loop variable i
68    extra_file.lua:13:7: accessing uninitialized variable a
69    extra_file.lua:14:1: value assigned to variable x is unused
70    extra_file.lua:21:7: variable z is never accessed
71
72Checking another_file.lua                2 warnings
73
74    another_file.lua:2:7: unused variable height
75    another_file.lua:3:7: accessing undefined variable heigth
76
77Total: 10 warnings / 1 error in 5 files
78```
79
80For more info, see [documentation](https://luacheck.readthedocs.io/en/stable/).
81
82## Related projects
83
84### Editor support
85
86There are a few plugins which allow using Luacheck directly inside an editor, showing warnings inline:
87
88* For Vim, [Syntastic](https://github.com/vim-syntastic/syntastic) contains [luacheck checker](https://github.com/vim-syntastic/syntastic/wiki/Lua%3A---luacheck);
89* For Sublime Text 3 there is [SublimeLinter-luacheck](https://packagecontrol.io/packages/SublimeLinter-luacheck) which requires [SublimeLinter](https://sublimelinter.readthedocs.io/en/latest/);
90* For Atom there is [linter-luacheck](https://atom.io/packages/linter-luacheck) which requires [AtomLinter](https://github.com/steelbrain/linter);
91* For Emacs, [Flycheck](http://www.flycheck.org/en/latest/) contains [luacheck checker](http://www.flycheck.org/en/latest/languages.html#lua);
92* For Brackets, there is [linter.luacheck](https://github.com/Malcolm3141/brackets-luacheck) extension;
93* For Visual Studio code there is [vscode-luacheck](https://marketplace.visualstudio.com/items?itemName=dwenegar.vscode-luacheck) extension. [vscode-lua](https://marketplace.visualstudio.com/items?itemName=trixnz.vscode-lua) extension also includes Luacheck support.
94
95If you are a plugin developer, see [recommended way of using Luacheck in a plugin](http://luacheck.readthedocs.org/en/stable/cli.html#stable-interface-for-editor-plugins-and-tools).
96
97### Other projects
98
99* [Luacheck bindings for Node.js](https://www.npmjs.com/package/luacheck);
100* [Luacheck plugin for Gulp](https://www.npmjs.com/package/gulp-luacheck).
101
102## Documentation
103
104Documentation is available [online](https://luacheck.readthedocs.io/en/stable/). If Luacheck has been installed using LuaRocks, it can be browsed offline using `luarocks doc luacheck` command.
105
106Documentation can be built using [Sphinx](http://sphinx-doc.org/): `sphinx-build docsrc doc`, the files will be found inside `doc/`.
107
108## Development
109
110Luacheck is currently in development. The latest released version is 0.24.0. The interface of the `luacheck` module may change between minor releases. The command line interface is fairly stable.
111
112Use the Luacheck issue tracker on GitHub to submit bugs, suggestions and questions. Any pull requests are welcome, too.
113
114## Building and testing
115
116After the Luacheck repo is cloned and changes are made, run `luarocks make` (using `sudo` if necessary) from its root directory to install dev version of Luacheck. To run Luacheck using sources in current directory without installing it, run `lua -e 'package.path="./src/?.lua;./src/?/init.lua;"..package.path' bin/luacheck.lua ...`. To test Luacheck, ensure that you have [busted](http://olivinelabs.com/busted/) and [luautf8](https://github.com/starwing/luautf8) installed and run `busted`.
117
118## License
119
120```
121The MIT License (MIT)
122
123Copyright (c) 2014 - 2018 Peter Melnichenko
124
125Permission is hereby granted, free of charge, to any person obtaining a copy
126of this software and associated documentation files (the "Software"), to deal
127in the Software without restriction, including without limitation the rights
128to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
129copies of the Software, and to permit persons to whom the Software is
130furnished to do so, subject to the following conditions:
131
132The above copyright notice and this permission notice shall be included in all
133copies or substantial portions of the Software.
134
135THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
136IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
137FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
138AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
139LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
140OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
141SOFTWARE.
142```
143