Skip to content

Commit 24dba62

Browse files
committed
Regenerated docs for 0.10.0
1 parent cf97aae commit 24dba62

16 files changed

Lines changed: 162 additions & 98 deletions

doc/_sources/cli.txt

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Command line interface
55

66
* Given a file, ``luacheck`` will check it.
77
* Given ``-``, ``luacheck`` will check stdin.
8-
* Given a directory, ``luacheck`` will check all files with ``.lua`` extension within it. This feature requires `luafilesystem <http://keplerproject.github.io/luafilesystem/>`_ (installed automatically if LuaRocks was used to install Luacheck).
8+
* Given a directory, ``luacheck`` will check all files with ``.lua`` extension within it. This feature requires `LuaFileSystem <http://keplerproject.github.io/luafilesystem/>`_ (installed automatically if LuaRocks was used to install Luacheck).
99
* Given a rockspec (a file with ``.rockspec`` extension), ``luacheck`` will check all files with ``.lua`` extension mentioned in the rockspec in ``build.install.lua``, ``build.install.bin`` and ``build.modules`` tables.
1010

1111
The output of ``luacheck`` consists of separate reports for each checked file and ends with a summary::
@@ -21,6 +21,9 @@ The output of ``luacheck`` consists of separate reports for each checked file an
2121

2222
Checking src/good_code.lua OK
2323
Checking src/python_code.lua Syntax error
24+
25+
spec/samples/python_code.lua:1:6: expected '=' near '__future__'
26+
2427
Checking src/unused_code.lua Failure
2528

2629
src/unused_code.lua:3:18: unused argument baz
@@ -55,8 +58,6 @@ Option Meaning
5558
``-u`` | ``--no-unused`` Filter out warnings related to unused variables and values.
5659
``-r`` | ``--no-redefined`` Filter out warnings related to redefined variables.
5760
``-a`` | ``--no-unused-args`` Filter out warnings related to unused arguments and loop variables.
58-
``-v`` | ``--no-unused-values`` Filter out warnings related to unused values.
59-
``--no-unset`` Filter out warnings related to unset variables.
6061
``-s`` | ``--no-unused-secondaries`` Filter out warnings related to unused variables set together with used ones.
6162

6263
See :ref:`secondaryvaluesandvariables`
@@ -91,21 +92,24 @@ Option Meaning
9192
``--enable | -o <patt> [<patt>] ...`` Do not filter out warnings matching patterns.
9293
``--only | -o <patt> [<patt>] ...`` Filter out warnings not matching patterns.
9394
``--no-inline`` Disable inline options.
94-
``-l <limit>`` | ``--limit <limit>`` Exit with 0 if there are ``<limit>`` or less warnings (default: ``0``).
9595
``--config <config>`` Path to custom configuration file (default: ``.luacheckrc``).
9696
``--no-config`` Do not look up custom configuration file.
97+
``--cache [<cache>]`` Path to cache file. (default: ``.luacheckcache``). See :ref:`cache`
98+
``--no-cache`` Do not use cache.
99+
``-j`` | ``--jobs`` Check ``<jobs>`` files in parallel. Requires `LuaLanes <http://cmr.github.io/lanes/>`_.
97100
``--formatter <formatter>`` Use custom formatter. ``<formatter>`` must be a module name or one of:
98101

99102
* ``TAP`` - Test Anything Protocol formatter;
100103
* ``JUnit`` - JUnit XML formatter;
101104
* ``plain`` - simple warning-per-line formatter;
102105
* ``default`` - standard formatter.
103-
``--codes`` Show warning codes.
104106
``-q`` | ``--quiet`` Suppress report output for files without warnings.
105107

106108
* ``-qq`` - Suppress output of warnings.
107109
* ``-qqq`` - Only output summary.
110+
``--codes`` Show warning codes.
108111
``--no-color`` Do not colorize output.
112+
``-v`` | ``--version`` Show version of luacheck and its dependencies and exit.
109113
``-h`` | ``--help`` Show help and exit.
110114
===================================== ============================================================================
111115

@@ -124,7 +128,16 @@ Pattern Matching warnings
124128
4.2/.*_ Shadowing declarations of arguments with ``_`` suffix or redefining them.
125129
======= =========================================================================
126130

131+
Unless already anchored, patterns matching variable names are anchored at both sides and patterns matching warning codes are anchored at their beginnings. This allows to filter warnings by category (e.g. ``--only 1`` focuses ``luacheck`` on global-related warnings).
132+
127133
Formatters
128134
----------
129135

130136
CLI option ``--formatter`` allows selecting a custom formatter for ``luacheck`` output. A custom formatter is a Lua module returning a function with three arguments: report as returned by ``luacheck`` module (see :ref:`report`), array of file names and table of options. Options contain values assigned to ``quiet``, ``color``, ``limit``, ``codes`` and ``formatter`` options in CLI or config. Formatter function must return a string.
137+
138+
.. _cache:
139+
140+
Caching
141+
-------
142+
143+
If LuaFileSystem is available, Luacheck can cache results of checking files. On subsequent checks, only files which have changed since the last check will be rechecked, improving run time significantly. Changing options (e.g. defining additional globals) does not invalidate cache. Caching can be enabled by using ``--cache <cache>`` option or ``cache`` config option. Using ``--cache`` without an argument or setting ``cache`` config option to ``true`` sets ``.luacheckcache`` as the cache file. Note that ``--cache`` must be used every time ``luacheck`` is run, not on the first run only.

doc/_sources/config.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ Option Type Default value
1515
====================== ======================================= ==================
1616
``color`` Boolean ``true``
1717
``codes`` Boolean ``false``
18-
``limit`` Number ``0``
18+
``formatter`` String ``"default"``
19+
``cache`` Boolean or string ``false``
20+
``jobs`` Positive integer ``1``
1921
``global`` Boolean ``true``
2022
``unused`` Boolean ``true``
2123
``redefined`` Boolean ``true``
2224
``unused_args`` Boolean ``true``
23-
``unused_values`` Boolean ``true``
24-
``unset`` Boolean ``true``
2525
``unused_secondaries`` Boolean ``true``
2626
``std`` String or array of strings ``"_G"``
2727
``globals`` Array of strings ``{}``
@@ -36,6 +36,7 @@ Option Type Default value
3636
``ignore`` Array of patterns (see :ref:`patterns`) ``{}``
3737
``enable`` Array of patterns ``{}``
3838
``only`` Array of patterns (Do not filter)
39+
``inline`` Boolean ``true``
3940
====================== ======================================= ==================
4041

4142
An example of a config which makes ``luacheck`` ensure that only globals from the portable intersection of Lua 5.1, Lua 5.2, Lua 5.3 and LuaJIT 2.0 are used, as well as disables detection of unused arguments:

doc/_sources/index.txt

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 `Luacheck <https://github.com/mpeterv/luacheck/>`_ 0.9.0, a static analyzer and a linter for `Lua <http://www.lua.org/>`_.
14+
This is documentation for `Luacheck <https://github.com/mpeterv/luacheck/>`_ 0.10.0, a static analyzer and a linter for `Lua <http://www.lua.org/>`_.

doc/_sources/inline.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,5 @@ For fine-grained control over inline option visibility use ``luacheck: push`` an
4646
foo() -- No warning.
4747
-- luacheck: pop
4848
foo() -- Warning is emitted.
49+
50+
Inline options can be completely disabled using ``--no-inline`` CLI option or ``inline`` config option.

doc/_sources/module.txt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
Luacheck module
22
===============
33

4-
``luacheck`` module is a single function. Use ``local luacheck = require "luacheck"`` to import it.
4+
Use ``local luacheck = require "luacheck"`` to import ``luacheck`` module. It contains the following functions:
55

6-
The first argument of the function should be an array. Each element should be either a file name (string) or an open file handle, in which case ``luacheck`` will read it till EOF and close it.
6+
* ``luacheck.get_report(source)``: Given source string, returns analysis data (an array) or nil and syntax error table (table with fields ``line``, ``column``, ``offset``, ``msg``).
7+
* ``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 :ref:`options`. Analysis reports with field ``error`` are ignored. ``process_reports`` returns final report, see :ref:`report`.
8+
* ``luacheck.check_strings(sources, options)``: Checks array of sources using options, returns final report. Tables in ``sources`` array are ignored.
9+
* ``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.
710

8-
The second argument, if present, should be a table of options. See :ref:`options`.
11+
``luacheck._VERSION`` contains Luacheck version as a string in ``MAJOR.MINOR.PATCH`` format.
912

10-
When checking ``n``-th file, ``luacheck`` will try to combine ``options[n]`` and entries from its array part with general options, similarly to how per file config tables overwrite main config table.
13+
Using ``luacheck`` as a function is equivalent to calling ``luacheck.check_files``.
1114

1215
.. _report:
1316

1417
Report format
1518
-------------
1619

17-
The ``luacheck`` function returns a report. A report is an array of file reports plus fields ``warnings`` and ``errors`` containing total number of warnings and errors, correspondingly.
20+
A final report is an array of file reports plus fields ``warnings`` and ``errors`` containing total number of warnings and errors, correspondingly.
1821

19-
A file report is an array of warnings. If an error occured while checking a file, its report will only have ``error`` field containing ``"I/O"`` or ``"syntax"``.
22+
A file report is an array of warnings. If an error occured while checking a file, its report will have ``error`` field containing ``"I/O"`` or ``"syntax"``. In case of syntax error, ``line`` (number), ``colunmn`` (number), ``offset`` (number) and ``msg`` (string) fields are also present.
2023

2124
A warning is a table with field ``code`` indicating the type of warning (see :doc:`warnings`), and fields ``line`` and ``column`` pointing to the source of the warning. Absence of ``code`` field indicates that the warning is related to a broken inline configuration comment; then, ``invalid`` field marks comments with invalid syntax, and ``unpaired`` field marks unpaired push/pop comments.
2225

doc/_sources/warnings.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ Code Description
2929
421 Shadowing a local variable.
3030
422 Shadowing an argument.
3131
423 Shadowing a loop variable.
32+
431 Shadowing an upvalue.
33+
432 Shadowing an upvalue argument.
34+
433 Shadowing an upvalue loop variable.
3235
511 Unreachable code.
3336
512 Loop can be executed at most once.
3437
521 Unused label.
@@ -62,8 +65,8 @@ Modules
6265

6366
Files can be marked as modules using ``-m``/``--module`` CLI option or ``module`` config option to simulate semantics of the deprecated `module <http://www.lua.org/manual/5.1/manual.html#pdf-module>`_ function. Globals implicitly defined inside a module are considired part of its interface, are not visible outside and are not reported as unused. Assignments to other globals are not allowed, even to defined ones.
6467

65-
Unused variables and values
66-
----------------------------
68+
Unused variables and values
69+
---------------------------
6770

6871
Luacheck generates warnings for all unused local variables except one named ``_``. It also detects variables which are set but never accessed or accessed but never set.
6972

@@ -109,7 +112,7 @@ Warnings related to unused secondary values and variables can be removed using `
109112
Shadowing declarations
110113
----------------------
111114

112-
Luacheck detects declarations of local variables shadowing previous declarations in the same closure, unless the variable is named ``_``. If the previous declaration is in the same scope as the new one, it is called redefining.
115+
Luacheck detects declarations of local variables shadowing previous declarations, unless the variable is named ``_``. If the previous declaration is in the same scope as the new one, it is called redefining.
113116

114117
Note that it is **not** necessary to define a new local variable when overwriting an argument:
115118

@@ -127,6 +130,8 @@ Note that it is **not** necessary to define a new local variable when overwritin
127130
Control flow and data flow issues
128131
---------------------------------
129132

133+
The following control flow and data flow issues are detected:
134+
130135
* Unreachable code and loops that can be executed at most once (e.g. due to an unconditional break);
131136
* Unused labels;
132137
* Unbalanced assignments;

0 commit comments

Comments
 (0)