All Projects → mpeterv → Luacheck

mpeterv / Luacheck

Licence: mit
A tool for linting and static analysis of Lua code.

Programming Languages

lua
6591 projects

Labels

Projects that are alternatives of or similar to Luacheck

Linter Jscs
Atom JSCS linter providers
Stars: ✭ 69 (-95.01%)
Mutual labels:  linter
Lintly
Automated GitHub PR code reviewer for Python, JavaScript, CSS, and more.
Stars: ✭ 91 (-93.42%)
Mutual labels:  linter
Linter Farch
Make sure the filenames stay the same, control them! 👁
Stars: ✭ 101 (-92.69%)
Mutual labels:  linter
Stylelint
A mighty, modern linter that helps you avoid errors and enforce conventions in your styles.
Stars: ✭ 9,350 (+576.56%)
Mutual labels:  linter
Atom Linter Alex
Linter plugin using alex to catch insensitive, inconsiderate writing
Stars: ✭ 87 (-93.7%)
Mutual labels:  linter
Pre Commit Hooks
A set of useful (and documented!) git pre-commit hooks.
Stars: ✭ 95 (-93.13%)
Mutual labels:  linter
Lint Staged
🚫💩 — Run linters on git staged files
Stars: ✭ 9,492 (+586.83%)
Mutual labels:  linter
Rslint
A (WIP) Extremely fast JavaScript and TypeScript linter and Rust crate
Stars: ✭ 1,377 (-0.36%)
Mutual labels:  linter
Rubberduck
Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
Stars: ✭ 1,287 (-6.87%)
Mutual labels:  linter
Nix Linter
Linter for the Nix expression language
Stars: ✭ 100 (-92.76%)
Mutual labels:  linter
Vscode Gremlins
Gremlins tracker for Visual Studio Code: reveals invisible whitespace and other annoying characters
Stars: ✭ 78 (-94.36%)
Mutual labels:  linter
Commit Msg Linter
git commit message linter hook
Stars: ✭ 87 (-93.7%)
Mutual labels:  linter
Unimport
A linter, formatter for finding and removing unused import statements.
Stars: ✭ 96 (-93.05%)
Mutual labels:  linter
Joker
Small Clojure interpreter, linter and formatter.
Stars: ✭ 1,161 (-15.99%)
Mutual labels:  linter
Eslint Plugin I18n Json
Fully extendable eslint plugin for JSON i18n translation files.
Stars: ✭ 101 (-92.69%)
Mutual labels:  linter
Static Analysis
⚙️ A curated list of static analysis (SAST) tools for all programming languages, config files, build tools, and more.
Stars: ✭ 9,310 (+573.66%)
Mutual labels:  linter
Linter Js Standard
Atom linter plugin for JavaScript, using JavaScript Standard Style
Stars: ✭ 95 (-93.13%)
Mutual labels:  linter
Linter Write Good
An Atom linter interface for write-good.
Stars: ✭ 102 (-92.62%)
Mutual labels:  linter
Tailor
Cross-platform static analyzer and linter for Swift.
Stars: ✭ 1,370 (-0.87%)
Mutual labels:  linter
Graphql Go Tools
Tools to write high performance GraphQL applications using Go/Golang.
Stars: ✭ 96 (-93.05%)
Mutual labels:  linter

Luacheck

Join the chat at https://gitter.im/luacheck/Lobby

Build Status Windows build status codecov License

Contents

Overview

Luacheck is a static analyzer and a linter for Lua. 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.

Luacheck 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.

Installation

Using LuaRocks

From your command line run the following command (using sudo if necessary):

luarocks install luacheck

For parallel checking Luacheck additionally requires LuaLanes, which can be installed using LuaRocks as well (luarocks install lanes).

Windows binary download

For Windows there is single-file 64-bit binary distribution, bundling Lua 5.3.4, Luacheck, LuaFileSystem, and LuaLanes using LuaStatic: download.

Basic usage

After Luacheck is installed, run luacheck program from the command line. Pass a list of files, rockspecs or directories (requires LuaFileSystem) to be checked:

luacheck src extra_file.lua another_file.lua
Checking src/good_code.lua               OK
Checking src/bad_code.lua                3 warnings

    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

Checking src/python_code.lua             1 error

    src/python_code.lua:1:6: expected '=' near '__future__'

Checking extra_file.lua                  5 warnings

    extra_file.lua:3:18: unused argument baz
    extra_file.lua:4:8: unused loop variable i
    extra_file.lua:13:7: accessing uninitialized variable a
    extra_file.lua:14:1: value assigned to variable x is unused
    extra_file.lua:21:7: variable z is never accessed

Checking another_file.lua                2 warnings

    another_file.lua:2:7: unused variable height
    another_file.lua:3:7: accessing undefined variable heigth

Total: 10 warnings / 1 error in 5 files

For more info, see documentation.

Related projects

Editor support

There are a few plugins which allow using Luacheck directly inside an editor, showing warnings inline:

If you are a plugin developer, see recommended way of using Luacheck in a plugin.

Other projects

Documentation

Documentation is available online. If Luacheck has been installed using LuaRocks, it can be browsed offline using luarocks doc luacheck command.

Documentation can be built using Sphinx: sphinx-build docsrc doc, the files will be found inside doc/.

Development

Luacheck is currently in development. The latest released version is 0.23.0. The interface of the luacheck module may change between minor releases. The command line interface is fairly stable.

Use the Luacheck issue tracker on GitHub to submit bugs, suggestions and questions. Any pull requests are welcome, too.

Building and testing

After 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 and luautf8 installed and run busted.

License

The MIT License (MIT)

Copyright (c) 2014 - 2018 Peter Melnichenko

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].