Skip to content

Commit 2f8ac84

Browse files
committed
Update docs for 0.22.0
1 parent 4c13e85 commit 2f8ac84

File tree

7 files changed

+32
-16
lines changed

7 files changed

+32
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ For Windows there is single-file 64-bit binary distribution, bundling Lua 5.3.4,
4343

4444
## Basic usage
4545

46-
After Luacheck is installed, run `luacheck` program from the command line. Pass a list of files, [rockspecs](https://github.com/keplerproject/luarocks/wiki/Rockspec-format) or directories (requires LuaFileSystem) to be checked:
46+
After 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:
4747

4848
```
4949
luacheck src extra_file.lua another_file.lua

docsrc/cli.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Command line interface
22
======================
33

4-
``luacheck`` program accepts files, directories and `rockspecs <http://www.luarocks.org/en/Rockspec_format>`_ as arguments. They can be filtered using ``--include-files`` and ``--exclude-files`` options, see below.
4+
``luacheck`` program accepts files, directories and `rockspecs <https://github.com/luarocks/luarocks/wiki/Rockspec-format>`_ as arguments. They can be filtered using ``--include-files`` and ``--exclude-files`` options, see below.
55

66
* Given a file, ``luacheck`` will check it.
77
* Given ``-``, ``luacheck`` will check stdin.
@@ -103,14 +103,16 @@ Option Meaning
103103
``-m | --module`` Limit visibility of implicitly defined globals to their files.
104104

105105
See :ref:`modules`
106-
``--max-line-length <length`` Set maximum allowed line length (default: 120).
106+
``--max-line-length <length>`` Set maximum allowed line length (default: 120).
107107
``--no-max-line-length`` Do not limit line length.
108-
``--max-code-line-length <length`` Set maximum allowed length for lines ending with code (default: 120).
108+
``--max-code-line-length <length>`` Set maximum allowed length for lines ending with code (default: 120).
109109
``--no-max-code-line-length`` Do not limit code line length.
110-
``--max-string-line-length <length`` Set maximum allowed length for lines within a string (default: 120).
110+
``--max-string-line-length <length>`` Set maximum allowed length for lines within a string (default: 120).
111111
``--no-max-string-line-length`` Do not limit string line length.
112-
``--max-comment-line-length <length`` Set maximum allowed length for comment lines (default: 120).
112+
``--max-comment-line-length <length>`` Set maximum allowed length for comment lines (default: 120).
113113
``--no-max-comment-line-length`` Do not limit comment line length.
114+
``--max-cyclomatic-complexity <limit>`` Set maximum cyclomatic complexity for functions.
115+
``--no-max-cyclomatic-complexity`` Do not limit function cyclomatic complexity (default).
114116
``--ignore | -i <patt> [<patt>] ...`` Filter out warnings matching patterns.
115117
``--enable | -e <patt> [<patt>] ...`` Do not filter out warnings matching patterns.
116118
``--only | -o <patt> [<patt>] ...`` Filter out warnings not matching patterns.
@@ -137,6 +139,7 @@ Option Meaning
137139

138140
* ``TAP`` - Test Anything Protocol formatter;
139141
* ``JUnit`` - JUnit XML formatter;
142+
* ``visual_studio`` - MSBuild/Visual Studio aware formatter;
140143
* ``plain`` - simple warning-per-line formatter;
141144
* ``default`` - standard formatter.
142145
``-q | --quiet`` Suppress report output for files without warnings.
@@ -179,7 +182,7 @@ CLI options ``--globals``, ``--new-globals``, ``--read-globals``, ``--new-read-g
179182
Sets of standard globals
180183
------------------------
181184

182-
CLI option ``--stds`` allows combining built-in sets described above using ``+``. For example, ``--std max`` is equivalent to ``--std=lua51c+lua52c+lua53c+luajit``. Leading plus sign adds new sets to default one instead of replacing it. For instance, ``--std +busted`` is suitable for checking test files that use `Busted <http://olivinelabs.com/busted/>`_ testing framework. Custom sets of globals can be defined by mutating global variable ``stds`` in config. See :ref:`custom_stds`
185+
CLI option ``--stds`` allows combining built-in sets described above using ``+``. For example, ``--std max`` is equivalent to ``--std=lua51c+lua52c+lua53c+luajit``. Leading plus sign adds new sets to current one instead of replacing it. For instance, ``--std +busted`` is suitable for checking test files that use `Busted <http://olivinelabs.com/busted/>`_ testing framework. Custom sets of globals can be defined by mutating global variable ``stds`` in config. See :ref:`custom_stds`
183186

184187
Formatters
185188
----------

docsrc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
# built documents.
4949
#
5050
# The short X.Y version.
51-
version = '0.21.2'
51+
version = '0.22.0'
5252
# The full version, including alpha/beta/rc tags.
53-
release = '0.21.2'
53+
release = '0.22.0'
5454

5555
# The language for content autogenerated by Sphinx. Refer to documentation
5656
# for a list of supported languages.

docsrc/config.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
Configuration file
22
==================
33

4-
``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 ``--config`` option, in which case it will be used during recursive loading. Config loading can be disabled using ``--no-config`` flag.
4+
``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 ``--config`` option, in which case it will be used during recursive loading. Paths within config are interpreted relatively to the directory from which it was loaded.
5+
6+
Config loading can be disabled using ``--no-config`` flag.
57

68
If neither of ``--config``, ``--no-config``, and ``--no-default-config`` options are used, ``luacheck`` will attempt to load configuration from value of ``--default-config`` option,
79
or ``%LOCALAPPDATA%\Luacheck\.luacheckrc`` on Windows, ``~/Library/Application Support/Luacheck/.luacheckrc`` on OS X/macOS, and ``$XDG_CONFIG_HOME/luacheck/.luacheckrc``
8-
or ``~/.config/luacheck/.luacheckrc`` on other systems by default.
10+
or ``~/.config/luacheck/.luacheckrc`` on other systems by default. Paths within default config are interpreted relatively to the current directory.
911

1012
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.
1113

@@ -19,8 +21,10 @@ Config options
1921
============================= ======================================== ===================
2022
Option Type Default value
2123
============================= ======================================== ===================
24+
``quiet`` Integer in range 0..3 ``0``
2225
``color`` Boolean ``true``
2326
``codes`` Boolean ``false``
27+
``ranges`` Boolean ``false``
2428
``formatter`` String or function ``"default"``
2529
``cache`` Boolean or string ``false``
2630
``jobs`` Positive integer ``1``

docsrc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ Contents:
1111
inline
1212
module
1313

14-
This is documentation for 0.21.2 version of `Luacheck <https://github.com/mpeterv/luacheck/>`_, a linter for `Lua <http://www.lua.org/>`_.
14+
This is documentation for 0.22.0 version of `Luacheck <https://github.com/mpeterv/luacheck/>`_, a linter for `Lua <https://www.lua.org/>`_.

docsrc/module.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ A file report is an array of issues (warnings or errors). If a fatal error occur
2424

2525
An issue is a table with field ``code`` indicating its type (see :doc:`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:
2626

27-
============= ============================================================================================================
27+
============= ==============================================================================================================
2828
Codes Additional fields
29-
============= ============================================================================================================
29+
============= ==============================================================================================================
3030
011 ``msg`` field contains syntax error message.
3131
111 ``module`` field indicates that assignment is to a non-module global variable.
3232
122, 142, 143 ``indirect`` field indicates that the global field was accessed using a local alias.
@@ -35,10 +35,12 @@ Codes Additional fields
3535
211 ``recursive`` field indicates that unused function is recursive.
3636
211 ``mutually_recursive`` field is set for unused mutually recursive functions.
3737
314 ``field`` field contains string representation of ununsed field or index.
38-
4.. ``prev_line`` and ``prev_column`` fields contain location of the overwritten definition.
38+
011 ``prev_line``, ``prev_column``, and ``prev_end_column`` fields may point to an extra relevant location,
39+
such as the opening unpaired bracket.
40+
4.. ``prev_line``, ``prev_column``, and ``prev_end_column`` fields contain location of the overwritten definition.
3941
521 ``label`` field contains label name.
4042
631 ``line_ending`` field contains ``"comment"`` or ``"string"`` if line ending is within a comment or a string.
4143
631 ``max_length`` field contains maximum allowed line length.
42-
============= ============================================================================================================
44+
============= ==============================================================================================================
4345

4446
Other fields may be present for internal reasons.

docsrc/warnings.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Code Description
5050
541 An empty ``do`` ``end`` block.
5151
542 An empty ``if`` branch.
5252
551 An empty statement.
53+
561 Cyclomatic complexity of a function is too high.
5354
611 A line consists of nothing but whitespace.
5455
612 A line contains trailing whitespace.
5556
613 Trailing whitespace in a string.
@@ -200,6 +201,12 @@ Empty statements
200201
In Lua 5.2+ semicolons are considered statements and can appear even when not following normal statements. Such semicolons
201202
produce Luacheck warnings as they are completely useless.
202203

204+
Cyclomatic complexity
205+
^^^^^^^^^^^^^^^^^^^^^
206+
207+
If a limit is set using ``--max-cyclomatic-complexity`` CLI option or corresponding config or inline options, Luacheck warns about functions
208+
with too high cyclomatic complexity.
209+
203210
Formatting issues (6xx)
204211
-----------------------
205212

0 commit comments

Comments
 (0)