├── .busted ├── .github └── workflows │ ├── busted.yml │ ├── deploy.yml │ ├── luacheck.yml │ └── versioning.yml ├── .gitignore ├── .luacheckrc ├── .luacov ├── .pre-commit-hooks.yaml ├── CHANGELOG.md ├── Dockerfile ├── LICENSE ├── README.md ├── action.yml ├── bin ├── luacheck.bat └── luacheck.lua ├── build ├── Makefile └── bin │ └── luacheck.lua ├── cliff.toml ├── docsrc ├── cli.rst ├── conf.py ├── config.rst ├── index.rst ├── inline.rst ├── module.rst └── warnings.rst ├── luacheck-dev-1.rockspec ├── rockspecs ├── luacheck-0.1.0-1.rockspec ├── luacheck-0.10.0-1.rockspec ├── luacheck-0.11.0-1.rockspec ├── luacheck-0.11.1-1.rockspec ├── luacheck-0.12.0-1.rockspec ├── luacheck-0.13.0-1.rockspec ├── luacheck-0.14.0-1.rockspec ├── luacheck-0.15.0-1.rockspec ├── luacheck-0.15.1-1.rockspec ├── luacheck-0.16.0-1.rockspec ├── luacheck-0.16.1-1.rockspec ├── luacheck-0.16.2-1.rockspec ├── luacheck-0.16.3-1.rockspec ├── luacheck-0.17.0-1.rockspec ├── luacheck-0.17.1-1.rockspec ├── luacheck-0.18.0-1.rockspec ├── luacheck-0.19.0-1.rockspec ├── luacheck-0.19.1-1.rockspec ├── luacheck-0.2.0-1.rockspec ├── luacheck-0.20.0-1.rockspec ├── luacheck-0.21.0-1.rockspec ├── luacheck-0.21.1-1.rockspec ├── luacheck-0.21.2-1.rockspec ├── luacheck-0.22.0-1.rockspec ├── luacheck-0.22.1-1.rockspec ├── luacheck-0.23.0-1.rockspec ├── luacheck-0.24.0-1.rockspec ├── luacheck-0.24.0-2.rockspec ├── luacheck-0.25.0-1.rockspec ├── luacheck-0.26.0-1.rockspec ├── luacheck-0.26.1-1.rockspec ├── luacheck-0.3.0-1.rockspec ├── luacheck-0.4.0-1.rockspec ├── luacheck-0.4.1-1.rockspec ├── luacheck-0.5.0-1.rockspec ├── luacheck-0.6.0-1.rockspec ├── luacheck-0.7.0-1.rockspec ├── luacheck-0.7.1-1.rockspec ├── luacheck-0.7.2-1.rockspec ├── luacheck-0.7.3-1.rockspec ├── luacheck-0.8.0-1.rockspec ├── luacheck-0.9.0-1.rockspec ├── luacheck-1.0.0-1.rockspec ├── luacheck-1.1.0-1.rockspec ├── luacheck-1.1.1-1.rockspec ├── luacheck-1.1.2-1.rockspec └── luacheck-1.2.0-1.rockspec ├── scripts ├── build-binaries.sh ├── dedicated_coverage.sh ├── gen_unicode_printability_module.sh ├── package.sh └── unicode_data_to_printability_module.lua ├── spec ├── bad_whitespace_spec.lua ├── cache_spec.lua ├── check_spec.lua ├── cli_spec.lua ├── config_spec.lua ├── configs │ ├── bad_config.luacheckrc │ ├── bad_custom_std_config.luacheckrc │ ├── cli_override_config.luacheckrc │ ├── cli_override_file_config.luacheckrc │ ├── cli_specific_config.luacheckrc │ ├── compound_operators_config.luacheckrc │ ├── config.lua │ ├── custom_fields_config.luacheckrc │ ├── custom_stds_config.luacheckrc │ ├── exclude_files_config.luacheckrc │ ├── format_opts_config.luacheckrc │ ├── global_config.luacheckrc │ ├── import_config.luacheckrc │ ├── invalid_config.luacheckrc │ ├── invalid_override_config.luacheckrc │ ├── multioverride_config.luacheckrc │ ├── override_config.luacheckrc │ ├── paths_config.luacheckrc │ ├── project │ │ ├── .luacheckrc │ │ └── nested │ │ │ ├── ab.lua │ │ │ └── nested │ │ │ └── abc.lua │ └── runtime_bad_config.luacheckrc ├── cyclomatic_complexity_spec.lua ├── decoder_spec.lua ├── empty_blocks_spec.lua ├── expand_rockspec_spec.lua ├── filter_spec.lua ├── folder │ ├── bad_config │ ├── bad_rockspec │ ├── bom │ ├── config │ ├── env_config │ ├── folder1 │ │ ├── another │ │ ├── fail │ │ └── file │ ├── folder2 │ │ └── garbage │ ├── foo │ └── rockspec ├── format_spec.lua ├── formatters │ └── custom_formatter.lua ├── fs_spec.lua ├── globals_spec.lua ├── globbing_spec.lua ├── helper.lua ├── lexer_spec.lua ├── linearize_spec.lua ├── luacheck_spec.lua ├── options_spec.lua ├── parser_spec.lua ├── projects │ └── default_stds │ │ ├── .luacheckrc │ │ ├── default_stds-scm-1.rockspec │ │ ├── nested │ │ └── spec │ │ │ └── sample_spec.lua │ │ ├── normal_file.lua │ │ ├── sample_spec.lua │ │ ├── test │ │ ├── nested_normal_file.lua │ │ └── sample_spec.lua │ │ └── tests │ │ ├── nested │ │ └── sample_spec.lua │ │ └── sample_spec.lua ├── resolve_locals_spec.lua ├── reversed_fornum_loops_spec.lua ├── rock │ ├── bin │ │ ├── rock.lua │ │ └── rock.sh │ ├── lua_modules │ │ └── something.lua │ ├── rock-dev-1.rockspec │ ├── src │ │ ├── rock.lua │ │ └── rock │ │ │ ├── mod.lua │ │ │ └── thing.c │ └── test.lua ├── rock2 │ ├── mod.lua │ ├── rock2-dev-1.rockspec │ └── spec │ │ └── rock2_spec.lua ├── samples │ ├── argparse-0.2.0.lua │ ├── bad.rockspec │ ├── bad_code.lua │ ├── bad_flow.lua │ ├── bad_whitespace.lua │ ├── compat.lua │ ├── compound_operators.lua │ ├── custom_std_inline_options.lua │ ├── defined.lua │ ├── defined2.lua │ ├── defined3.lua │ ├── defined4.lua │ ├── empty.lua │ ├── global_fields.lua │ ├── global_inline_options.lua │ ├── globals.lua │ ├── good_code.lua │ ├── indirect_globals.lua │ ├── inline_options.lua │ ├── line_length.lua │ ├── luanti.lua │ ├── python_code.lua │ ├── read_globals.lua │ ├── read_globals_inline_options.lua │ ├── redefined.lua │ ├── reversed_fornum.lua │ ├── sample.rockspec │ ├── unused_code.lua │ ├── unused_secondaries.lua │ ├── utf8.lua │ └── utf8_error.lua ├── serializer_spec.lua ├── standards_spec.lua ├── unbalanced_assignments_spec.lua ├── uninit_accesses_spec.lua ├── unreachable_code_spec.lua ├── unused_fields_spec.lua ├── unused_locals_spec.lua └── utils_spec.lua └── src └── luacheck ├── builtin_standards ├── init.lua ├── love.lua ├── luanti.lua ├── ngx.lua └── playdate.lua ├── cache.lua ├── check.lua ├── check_state.lua ├── config.lua ├── core_utils.lua ├── decoder.lua ├── expand_rockspec.lua ├── filter.lua ├── format.lua ├── fs.lua ├── globbing.lua ├── init.lua ├── lexer.lua ├── main.lua ├── multithreading.lua ├── options.lua ├── parser.lua ├── profiler.lua ├── runner.lua ├── serializer.lua ├── stages ├── detect_bad_whitespace.lua ├── detect_compound_operators.lua ├── detect_cyclomatic_complexity.lua ├── detect_empty_blocks.lua ├── detect_empty_statements.lua ├── detect_globals.lua ├── detect_reversed_fornum_loops.lua ├── detect_unbalanced_assignments.lua ├── detect_uninit_accesses.lua ├── detect_unreachable_code.lua ├── detect_unused_fields.lua ├── detect_unused_locals.lua ├── init.lua ├── linearize.lua ├── name_functions.lua ├── parse.lua ├── parse_inline_options.lua ├── resolve_locals.lua └── unwrap_parens.lua ├── standards.lua ├── unicode.lua ├── unicode_printability_boundaries.lua ├── utils.lua ├── vendor └── sha1 │ ├── LICENSE │ ├── bit32_ops.lua │ ├── bit_ops.lua │ ├── common.lua │ ├── init.lua │ ├── lua53_ops.lua │ └── pure_lua_ops.lua └── version.lua /.busted: -------------------------------------------------------------------------------- 1 | return { 2 | _all = { 3 | ["exclude-pattern"] = "sample_spec" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /.github/workflows/busted.yml: -------------------------------------------------------------------------------- 1 | name: Busted 2 | 3 | on: [ push, pull_request ] 4 | 5 | jobs: 6 | 7 | busted: 8 | strategy: 9 | fail-fast: false 10 | matrix: 11 | luaVersion: [ "5.4", "5.3", "5.2", "5.1", "luajit" ] # , "luajit-openresty" 12 | runs-on: ubuntu-22.04 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v3 16 | 17 | - name: Setup ‘lua’ 18 | uses: hishamhm/gh-actions-lua@master 19 | with: 20 | luaVersion: ${{ matrix.luaVersion }} 21 | 22 | - name: Setup ‘luarocks’ 23 | uses: hishamhm/gh-actions-luarocks@master 24 | 25 | - name: Setup dependencies 26 | run: | 27 | luarocks install --deps-only luacheck-dev-1.rockspec 28 | luarocks install busted 29 | luarocks install lanes # required for parallel execution 30 | luarocks install luautf8 # required for decoder unit test 31 | luarocks install luasocket # required for profiler unit test 32 | luarocks install luacov-coveralls 33 | 34 | - name: Run regression tests 35 | run: busted -c -v 36 | 37 | - name: Report test coverage 38 | if: success() 39 | continue-on-error: true 40 | run: luacov-coveralls -i src/luacheck -e .luarocks 41 | env: 42 | COVERALLS_REPO_TOKEN: ${{ github.token }} 43 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy 2 | 3 | on: [ push, workflow_dispatch ] 4 | 5 | jobs: 6 | 7 | affected: 8 | uses: lunarmodules/.github/.github/workflows/list_affected_rockspecs.yml@main 9 | 10 | build: 11 | needs: affected 12 | if: ${{ needs.affected.outputs.rockspecs }} 13 | uses: lunarmodules/.github/.github/workflows/test_build_rock.yml@main 14 | with: 15 | rockspecs: ${{ needs.affected.outputs.rockspecs }} 16 | 17 | upload: 18 | needs: [ affected, build ] 19 | # Only run upload if: 20 | # 1. We are on the canonical repository (no uploads from forks) 21 | # 2. The current commit is either tagged or on the default branch (the workflow will upload dev/scm rockspecs any 22 | # time they are touched, tagged ones whenever the edited rockspec and tag match) 23 | # 3. Some rockspecs were changed — this implies the commit changing the rockspec is the same one that gets tagged 24 | if: >- 25 | ${{ 26 | github.repository == 'lunarmodules/luacheck' && 27 | ( github.ref_name == 'master' || startsWith(github.ref, 'refs/tags/') ) && 28 | needs.affected.outputs.rockspecs 29 | }} 30 | uses: lunarmodules/.github/.github/workflows/upload_to_luarocks.yml@main 31 | with: 32 | rockspecs: ${{ needs.affected.outputs.rockspecs }} 33 | secrets: 34 | apikey: ${{ secrets.LUAROCKS_APIKEY }} 35 | 36 | docker: 37 | if: >- 38 | ${{ 39 | github.repository == 'lunarmodules/luacheck' && 40 | ( github.ref_name == 'master' || startsWith(github.ref, 'refs/tags/') ) 41 | }} 42 | uses: lunarmodules/.github/.github/workflows/docker_ghcr_deploy.yml@main 43 | with: 44 | username: ${{ github.actor }} 45 | tag: ${{ github.ref_name }} 46 | secrets: 47 | token: ${{ secrets.GHCR_PAT }} 48 | -------------------------------------------------------------------------------- /.github/workflows/luacheck.yml: -------------------------------------------------------------------------------- 1 | # ATTENTION 2 | # 3 | # This is *not* a typical luacheck workflow! Do not copy this to other projects! 4 | # Instead of installing luacheck from somewhere and using it on a code base, 5 | # we're actually building and running the current HEAD version on ourselves: 6 | # basically this is a combination bootstrap test and dogfooding. The upshot is 7 | # that we check both that everything works (and end-to-end test) and that the 8 | # current codebase lints against itself. This ensures we can fix a bug or make 9 | # a breaking change in luacheck without being blocked by our own CI using a 10 | # different luacheck verision. 11 | # 12 | # See the README.md file for examples suitable for use in other projects. 13 | 14 | name: Luacheck 15 | 16 | on: [ push, pull_request ] 17 | 18 | jobs: 19 | 20 | luacheck: 21 | strategy: 22 | fail-fast: false 23 | matrix: 24 | luaVersion: [ "5.4", "5.3", "5.2", "5.1", "luajit" ] # , "luajit-openresty" 25 | runs-on: ubuntu-22.04 26 | steps: 27 | - name: Checkout 28 | uses: actions/checkout@v3 29 | 30 | - name: Setup ‘lua’ 31 | uses: hishamhm/gh-actions-lua@master 32 | with: 33 | luaVersion: ${{ matrix.luaVersion }} 34 | 35 | - name: Setup ‘luarocks’ 36 | uses: hishamhm/gh-actions-luarocks@master 37 | 38 | - name: Setup dependencies 39 | run: | 40 | luarocks install --deps-only luacheck-dev-1.rockspec 41 | 42 | - name: Build ‘luacheck’ (bootstrap) 43 | run: luarocks make 44 | 45 | - name: Run ‘luacheck’ (dogfood) 46 | run: luacheck . 47 | -------------------------------------------------------------------------------- /.github/workflows/versioning.yml: -------------------------------------------------------------------------------- 1 | name: Versioning 2 | 3 | on: 4 | release: 5 | types: [ created, published, edited ] 6 | 7 | jobs: 8 | actions-tagger: 9 | runs-on: ubuntu-20.04 10 | steps: 11 | - name: Checkout 12 | uses: actions/checkout@v3 13 | - name: Update release tags 14 | uses: Actions-R-Us/actions-tagger@v2 15 | with: 16 | publish_latest_tag: true 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .luacheckcache 2 | luacov.stats.out 3 | luacov.report.out 4 | doc 5 | *.rock 6 | !build/ 7 | build/* 8 | !build/Makefile 9 | !build/bin 10 | build/bin/* 11 | !build/bin/luacheck.lua 12 | package 13 | scripts/UnicodeData-* 14 | docsrc/.doctrees 15 | -------------------------------------------------------------------------------- /.luacheckrc: -------------------------------------------------------------------------------- 1 | std = "min" 2 | cache = true 3 | include_files = {"src", "spec/*.lua", "scripts/*.lua", "*.rockspec", "*.luacheckrc"} 4 | exclude_files = {"src/luacheck/vendor"} 5 | 6 | files["src/luacheck/unicode_printability_boundaries.lua"].max_line_length = false 7 | -------------------------------------------------------------------------------- /.luacov: -------------------------------------------------------------------------------- 1 | return require "spec.helper".luacov_config("") 2 | -------------------------------------------------------------------------------- /.pre-commit-hooks.yaml: -------------------------------------------------------------------------------- 1 | - id: luacheck 2 | name: Luacheck 3 | description: Lint and static analysis of Lua code 4 | entry: luacheck 5 | language: lua 6 | types: [lua] 7 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | #syntax=docker/dockerfile:1.2 2 | 3 | FROM akorn/luarocks:lua5.4-alpine AS builder 4 | 5 | RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing \ 6 | dumb-init gcc libc-dev 7 | 8 | COPY ./ /src 9 | WORKDIR /src 10 | 11 | RUN luarocks --tree /pkgdir/usr/local make 12 | RUN find /pkgdir -type f -exec sed -i -e 's!/pkgdir!!g' {} \; 13 | 14 | FROM akorn/lua:5.4-alpine AS final 15 | 16 | RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing \ 17 | dumb-init 18 | 19 | LABEL org.opencontainers.image.title="Luacheck" 20 | LABEL org.opencontainers.image.description="A containerized version of Luacheck, a tool for linting and static analysis of Lua code" 21 | LABEL org.opencontainers.image.authors="Caleb Maclennan " 22 | LABEL org.opencontainers.image.licenses="MIT" 23 | LABEL org.opencontainers.image.url="https://github.com/lunarmodules/luacheck/pkgs/container/luacheck" 24 | LABEL org.opencontainers.image.source="https://github.com/lunarmodules/luacheck" 25 | 26 | COPY --from=builder /pkgdir / 27 | RUN luacheck --version 28 | 29 | WORKDIR /data 30 | 31 | ENTRYPOINT ["luacheck", "--no-cache"] 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 - 2018 Peter Melnichenko 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: Luacheck 2 | description: Luacheck 3 | inputs: 4 | args: 5 | description: Arguments passed to luacheck 6 | required: false 7 | default: "." 8 | runs: 9 | using: docker 10 | image: docker://ghcr.io/lunarmodules/luacheck:v1.2.0 11 | entrypoint: sh 12 | args: 13 | - -c 14 | - luacheck ${{ inputs.args }} 15 | branding: 16 | icon: check 17 | color: yellow 18 | -------------------------------------------------------------------------------- /bin/luacheck.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | lua.exe "%~dp0\luacheck.lua" %* 3 | -------------------------------------------------------------------------------- /bin/luacheck.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | require "luacheck.main" 3 | -------------------------------------------------------------------------------- /build/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for (cross)compiling luacheck binaries. 2 | # Do not use directly, run scripts/build-binaries.sh instead. 3 | 4 | LUA_VERSION= 5.4.4 5 | LFS_VERSION= 1.8.0-1 6 | ARGPARSE_VERSION= 0.7.1-1 7 | LANES_VERSION= 3.16.0-0 8 | 9 | LUA_DIR= lua-$(LUA_VERSION) 10 | LFS_DIR= luafilesystem-$(LFS_VERSION)/luafilesystem 11 | ARGPARSE_DIR= argparse-$(ARGPARSE_VERSION)/argparse-$(ARGPARSE_VERSION:-1=) 12 | LANES_DIR= lanes-$(LANES_VERSION)/lanes 13 | 14 | BASE_CC= gcc 15 | BASE_AR= ar rc 16 | BASE_RANLIB= ranlib 17 | BASE_STRIP= strip 18 | BASE_NM= nm 19 | 20 | CROSS= 21 | CC= $(CROSS)$(BASE_CC) 22 | CFLAGS= -O2 -Wall -Wextra 23 | AR= $(CROSS)$(BASE_AR) 24 | NM= $(CROSS)$(BASE_NM) 25 | RANLIB= $(CROSS)$(BASE_RANLIB) 26 | STRIP= $(CROSS)$(BASE_STRIP) 27 | 28 | SUFFIX= 29 | TARGET= bin/luacheck$(SUFFIX) 30 | 31 | LUA_O= $(patsubst %.c,%.o,$(filter-out $(addprefix $(LUA_DIR)/src/,lua.c luac.c print.c),$(wildcard $(LUA_DIR)/src/*.c))) 32 | LUA_A= $(LUA_DIR)/src/liblua.a 33 | LFS_O= $(patsubst %.c,%.o,$(wildcard $(LFS_DIR)/src/*.c)) 34 | LFS_A= $(LFS_DIR)/src/lfs.a 35 | LANES_O= $(patsubst %.c,%.o,$(wildcard $(LANES_DIR)/src/*.c)) 36 | LANES_A= $(LANES_DIR)/src/lanes.a 37 | 38 | default: $(TARGET) 39 | 40 | $(LUA_DIR): 41 | @echo 42 | @echo "=== Downloading Lua $(LUA_VERSION) ===" 43 | @echo 44 | curl "https://www.lua.org/ftp/$(LUA_DIR).tar.gz" | tar xz 45 | 46 | $(LFS_DIR): 47 | @echo 48 | @echo "=== Downloading LuaFileSystem $(LFS_VERSION) ===" 49 | @echo 50 | luarocks unpack luafilesystem $(LFS_VERSION) 51 | 52 | $(ARGPARSE_DIR): 53 | @echo 54 | @echo "=== Downloading argparse $(ARGPARSE_VERSION) ===" 55 | @echo 56 | luarocks unpack argparse $(ARGPARSE_VERSION) 57 | 58 | $(LANES_DIR): 59 | @echo 60 | @echo "=== Downloading Lanes $(LANES_VERSION) ===" 61 | @echo 62 | luarocks unpack lanes $(LANES_VERSION) 63 | 64 | fetch: $(LUA_DIR) $(LFS_DIR) $(ARGPARSE_DIR) $(LANES_DIR) 65 | 66 | $(LUA_O): CFLAGS+= $(if $(LINUX),-DLUA_USE_POSIX) 67 | $(LUA_A): $(LUA_O) 68 | $(LFS_O): CFLAGS+= -I$(LUA_DIR)/src 69 | $(LFS_A): $(LFS_O) 70 | $(LANES_O): CFLAGS+= -I$(LUA_DIR)/src 71 | $(LANES_A): $(LANES_O) 72 | 73 | %.a: 74 | $(AR) $@ $^ 75 | $(RANLIB) $@ 76 | 77 | $(TARGET): $(LUA_A) $(LFS_A) $(LANES_A) 78 | cp $(LUA_A) . 79 | cp $(LFS_A) . 80 | cp $(ARGPARSE_DIR)/src/argparse.lua . 81 | cp $(LANES_A) . 82 | cp $(LANES_DIR)/src/lanes.lua . 83 | cp -r ../src/luacheck . 84 | cp -f bin/luacheck.lua bin/luacheck_bin.lua 85 | CC=$(CC) NM=$(NM) RANLIB=$(RANLIB) luastatic bin/luacheck_bin.lua luacheck/*.lua luacheck/*/*.lua luacheck/*/*/*.lua argparse.lua lanes.lua $(LUA_A) $(LFS_A) $(LANES_A) -lm $(if $(LINUX),-lpthread) -I$(LUA_DIR)/src 86 | rm luacheck_bin.luastatic.c 87 | $(STRIP) luacheck_bin* 88 | mv luacheck_bin* $(TARGET) 89 | 90 | clean: 91 | rm -f $(TARGET) luacheck.luastatic.c 92 | rm -f $(LUA_O) $(LUA_A) $(LFS_O) $(LFS_A) $(LANES_O) $(LANES_A) 93 | rm -f argparse.lua lanes.lua lfs.a lanes.a liblua.a 94 | rm -rf luacheck 95 | rm -f luacheck_bin* 96 | 97 | .PHONY: default fetch clean 98 | -------------------------------------------------------------------------------- /build/bin/luacheck.lua: -------------------------------------------------------------------------------- 1 | -- Version of bin/luacheck.lua for use in Luacheck binaries. 2 | 3 | -- Do not load modules from filesystem in case a bundled module is broken. 4 | package.path = "" 5 | package.cpath = "" 6 | 7 | require "luacheck.main" 8 | -------------------------------------------------------------------------------- /cliff.toml: -------------------------------------------------------------------------------- 1 | [git] 2 | commit_parsers = [ 3 | { message = "^feat", group = "Features" }, 4 | { message = "^fix", group = "Bug Fixes" }, 5 | { message = "^doc.*!:", group = "Documentation", skip = false }, 6 | { message = "^doc", group = "Documentation", skip = true }, 7 | { message = "^perf", group = "Performance" }, 8 | { message = "^refactor.*!:", group = "Refactor", skip = false }, 9 | { message = "^refactor", group = "Refactor", skip = true }, 10 | { message = "^style", group = "Styling", skip = true }, 11 | { message = "^test", group = "Testing", skip = true }, 12 | { message = "^chore\\(release\\): prepare for", skip = true }, 13 | { message = "^chore.*!:", group = "Miscellaneous Tasks", skip = false }, 14 | { message = "^chore", group = "Miscellaneous Tasks", skip = true }, 15 | { body = ".*security", group = "Security"}, 16 | ] 17 | filter_commits = true 18 | tag_pattern = "v[0-9]*" 19 | sort_commits = "newest" 20 | -------------------------------------------------------------------------------- /docsrc/index.rst: -------------------------------------------------------------------------------- 1 | Luacheck documentation 2 | ====================== 3 | 4 | Contents: 5 | 6 | .. toctree:: 7 | 8 | warnings 9 | cli 10 | config 11 | inline 12 | module 13 | 14 | This is documentation for version |version| of `Luacheck `_, a linter for `Lua `_. 15 | -------------------------------------------------------------------------------- /docsrc/inline.rst: -------------------------------------------------------------------------------- 1 | Inline options 2 | ============== 3 | 4 | Luacheck supports setting some options directly in the checked files using inline configuration comments. These inline options have the highest priority, overwriting both config options and CLI options. 5 | 6 | An inline configuration comment is a short comment starting with ``luacheck:`` label, possibly after some whitespace. The body of the comment should contain comma separated options, where option invocation consists of its name plus space separated arguments. It can also contain notes enclosed in balanced parentheses, which are ignored. The following options are supported: 7 | 8 | ======================= ==================================================================== 9 | Option Number of arguments 10 | ======================= ==================================================================== 11 | global 0 12 | unused 0 13 | redefined 0 14 | unused args 0 15 | unused secondaries 0 16 | self 0 17 | compat 0 18 | module 0 19 | allow defined 0 20 | allow defined top 0 21 | max line length 1 (with ``no`` and no arguments disables line length checks) 22 | max code line length 1 (with ``no`` and no arguments disables code line length checks) 23 | max string line length 1 (with ``no`` and no arguments disables string line length checks) 24 | max comment line length 1 (with ``no`` and no arguments disables comment line length checks) 25 | std 1 26 | globals 0+ 27 | new globals 0+ 28 | read globals 0+ 29 | new read globals 0+ 30 | not globals 0+ 31 | ignore 0+ (without arguments everything is ignored) 32 | enable 1+ 33 | only 1+ 34 | ======================= ==================================================================== 35 | 36 | Options that take no arguments can be prefixed with ``no`` to invert their meaning. E.g. ``--luacheck: no unused args`` disables unused argument warnings. 37 | 38 | Part of the file affected by inline option dependes on where it is placed. If there is any code on the line with the option, only that line is affected; otherwise, everything till the end of the current closure is. In particular, inline options at the top of the file affect all of it: 39 | 40 | .. code-block:: lua 41 | :linenos: 42 | 43 | -- luacheck: globals g1 g2, ignore foo 44 | local foo = g1(g2) -- No warnings emitted. 45 | 46 | -- The following unused function is not reported. 47 | local function f() -- luacheck: ignore 48 | -- luacheck: globals g3 49 | g3() -- No warning. 50 | end 51 | 52 | g3() -- Warning is emitted as the inline option defining g3 only affected function f. 53 | 54 | For fine-grained control over inline option visibility use ``luacheck: push`` and ``luacheck: pop`` directives: 55 | 56 | .. code-block:: lua 57 | :linenos: 58 | 59 | -- luacheck: push ignore foo 60 | foo() -- No warning. 61 | -- luacheck: pop 62 | foo() -- Warning is emitted. 63 | -------------------------------------------------------------------------------- /docsrc/module.rst: -------------------------------------------------------------------------------- 1 | Luacheck module 2 | =============== 3 | 4 | Use ``local luacheck = require "luacheck"`` to import ``luacheck`` module. It contains the following functions: 5 | 6 | * ``luacheck.get_report(source)``: Given source string, returns analysis data (a table). 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 ``fatal`` 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 with field ``fatal`` within ``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. 10 | * ``luacheck.get_message(issue)``: Returns a string message for an issue, see :ref:`report`. 11 | 12 | ``luacheck._VERSION`` contains Luacheck version as a string in ``MAJOR.MINOR.PATCH`` format. 13 | 14 | Using ``luacheck`` as a function is equivalent to calling ``luacheck.check_files``. 15 | 16 | .. _report: 17 | 18 | Report format 19 | ------------- 20 | 21 | A final report is an array of file reports plus fields ``warnings``, ``errors`` and ``fatals`` containing total number of warnings, errors and fatal errors, correspondingly. 22 | 23 | A file report is an array of issues (warnings or errors). If a fatal error occurred while checking a file, its report will have ``fatal`` field containing error type and ``msg`` field containing error message. 24 | 25 | 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: 26 | 27 | ============= ============================================================================================================== 28 | Codes Additional fields 29 | ============= ============================================================================================================== 30 | 011 ``msg`` field contains syntax error message. 31 | 111 ``module`` field indicates that assignment is to a non-module global variable. 32 | 122, 142, 143 ``indirect`` field indicates that the global field was accessed using a local alias. 33 | 122, 142, 143 ``field`` field contains string representation of related global field. 34 | 211 ``func`` field indicates that unused variable is a function. 35 | 211 ``recursive`` field indicates that unused function is recursive. 36 | 211 ``mutually_recursive`` field is set for unused mutually recursive functions. 37 | 314 ``field`` field contains string representation of ununsed field or index. 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. 41 | 521 ``label`` field contains label name. 42 | 631 ``line_ending`` field contains ``"comment"`` or ``"string"`` if line ending is within a comment or a string. 43 | 631 ``max_length`` field contains maximum allowed line length. 44 | ============= ============================================================================================================== 45 | 46 | Other fields may be present for internal reasons. 47 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.1.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.1.0-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck.git", 5 | tag = "0.1.0" 6 | } 7 | description = { 8 | summary = "A simple static analyzer", 9 | detailed = [[ 10 | luacheck only looks for three things: non-standard global variables, unused local variables and redefinitions of existing local variables in the same scope. 11 | 12 | luacheck provides a command-line interface as well as a small library which can be used from another Lua program. 13 | ]], 14 | homepage = "https://github.com/mpeterv/luacheck", 15 | license = "MIT/X11" 16 | } 17 | dependencies = { 18 | "lua >= 5.1, < 5.3", 19 | "metalua-parser >= 0.7.3-2", 20 | "checks >= 1.0", 21 | "argparse >= 0.2.0", 22 | "ansicolors >= 1.0-1" 23 | } 24 | build = { 25 | type = "builtin", 26 | modules = { 27 | luacheck = "src/luacheck.lua", 28 | ["luacheck.scan"] = "src/luacheck/scan.lua", 29 | ["luacheck.check"] = "src/luacheck/check.lua", 30 | ["luacheck.format"] = "src/luacheck/format.lua" 31 | }, 32 | install = { 33 | bin = { 34 | luacheck = "bin/luacheck.lua" 35 | } 36 | }, 37 | copy_directories = {"spec", "doc"} 38 | } 39 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.10.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.10.0-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck", 5 | tag = "0.10.0" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 24 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 25 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 26 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 27 | ["luacheck.check"] = "src/luacheck/check.lua", 28 | ["luacheck.parser"] = "src/luacheck/parser.lua", 29 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 30 | ["luacheck.filter"] = "src/luacheck/filter.lua", 31 | ["luacheck.options"] = "src/luacheck/options.lua", 32 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 33 | ["luacheck.stds"] = "src/luacheck/stds.lua", 34 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 35 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 36 | ["luacheck.cache"] = "src/luacheck/cache.lua", 37 | ["luacheck.format"] = "src/luacheck/format.lua", 38 | ["luacheck.version"] = "src/luacheck/version.lua", 39 | ["luacheck.fs"] = "src/luacheck/fs.lua", 40 | ["luacheck.utils"] = "src/luacheck/utils.lua", 41 | ["luacheck.argparse"] = "src/luacheck/argparse.lua" 42 | }, 43 | install = { 44 | bin = { 45 | luacheck = "bin/luacheck.lua" 46 | } 47 | }, 48 | copy_directories = {"spec", "doc"} 49 | } 50 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.11.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.11.0-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck", 5 | tag = "0.11.0" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.main"] = "src/luacheck/main.lua", 24 | ["luacheck.config"] = "src/luacheck/config.lua", 25 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 26 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 27 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 28 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 29 | ["luacheck.check"] = "src/luacheck/check.lua", 30 | ["luacheck.parser"] = "src/luacheck/parser.lua", 31 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 32 | ["luacheck.filter"] = "src/luacheck/filter.lua", 33 | ["luacheck.options"] = "src/luacheck/options.lua", 34 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 35 | ["luacheck.stds"] = "src/luacheck/stds.lua", 36 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 37 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 38 | ["luacheck.cache"] = "src/luacheck/cache.lua", 39 | ["luacheck.format"] = "src/luacheck/format.lua", 40 | ["luacheck.version"] = "src/luacheck/version.lua", 41 | ["luacheck.fs"] = "src/luacheck/fs.lua", 42 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 43 | ["luacheck.utils"] = "src/luacheck/utils.lua", 44 | ["luacheck.argparse"] = "src/luacheck/argparse.lua" 45 | }, 46 | install = { 47 | bin = { 48 | luacheck = "bin/luacheck.lua" 49 | } 50 | }, 51 | copy_directories = {"spec", "doc"} 52 | } 53 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.11.1-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.11.1-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck", 5 | tag = "0.11.1" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.main"] = "src/luacheck/main.lua", 24 | ["luacheck.config"] = "src/luacheck/config.lua", 25 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 26 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 27 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 28 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 29 | ["luacheck.check"] = "src/luacheck/check.lua", 30 | ["luacheck.parser"] = "src/luacheck/parser.lua", 31 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 32 | ["luacheck.filter"] = "src/luacheck/filter.lua", 33 | ["luacheck.options"] = "src/luacheck/options.lua", 34 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 35 | ["luacheck.stds"] = "src/luacheck/stds.lua", 36 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 37 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 38 | ["luacheck.cache"] = "src/luacheck/cache.lua", 39 | ["luacheck.format"] = "src/luacheck/format.lua", 40 | ["luacheck.version"] = "src/luacheck/version.lua", 41 | ["luacheck.fs"] = "src/luacheck/fs.lua", 42 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 43 | ["luacheck.utils"] = "src/luacheck/utils.lua", 44 | ["luacheck.argparse"] = "src/luacheck/argparse.lua" 45 | }, 46 | install = { 47 | bin = { 48 | luacheck = "bin/luacheck.lua" 49 | } 50 | }, 51 | copy_directories = {"spec", "doc"} 52 | } 53 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.12.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.12.0-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck", 5 | tag = "0.12.0" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.main"] = "src/luacheck/main.lua", 24 | ["luacheck.config"] = "src/luacheck/config.lua", 25 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 26 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 27 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 28 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 29 | ["luacheck.check"] = "src/luacheck/check.lua", 30 | ["luacheck.parser"] = "src/luacheck/parser.lua", 31 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 32 | ["luacheck.filter"] = "src/luacheck/filter.lua", 33 | ["luacheck.options"] = "src/luacheck/options.lua", 34 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 35 | ["luacheck.stds"] = "src/luacheck/stds.lua", 36 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 37 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 38 | ["luacheck.cache"] = "src/luacheck/cache.lua", 39 | ["luacheck.format"] = "src/luacheck/format.lua", 40 | ["luacheck.version"] = "src/luacheck/version.lua", 41 | ["luacheck.fs"] = "src/luacheck/fs.lua", 42 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 43 | ["luacheck.utils"] = "src/luacheck/utils.lua", 44 | ["luacheck.argparse"] = "src/luacheck/argparse.lua" 45 | }, 46 | install = { 47 | bin = { 48 | luacheck = "bin/luacheck.lua" 49 | } 50 | }, 51 | copy_directories = {"spec", "doc"} 52 | } 53 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.13.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.13.0-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck", 5 | tag = "0.13.0" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.main"] = "src/luacheck/main.lua", 24 | ["luacheck.config"] = "src/luacheck/config.lua", 25 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 26 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 27 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 28 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 29 | ["luacheck.check"] = "src/luacheck/check.lua", 30 | ["luacheck.parser"] = "src/luacheck/parser.lua", 31 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 32 | ["luacheck.filter"] = "src/luacheck/filter.lua", 33 | ["luacheck.options"] = "src/luacheck/options.lua", 34 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 35 | ["luacheck.stds"] = "src/luacheck/stds.lua", 36 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 37 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 38 | ["luacheck.cache"] = "src/luacheck/cache.lua", 39 | ["luacheck.format"] = "src/luacheck/format.lua", 40 | ["luacheck.version"] = "src/luacheck/version.lua", 41 | ["luacheck.fs"] = "src/luacheck/fs.lua", 42 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 43 | ["luacheck.utils"] = "src/luacheck/utils.lua", 44 | ["luacheck.argparse"] = "src/luacheck/argparse.lua" 45 | }, 46 | install = { 47 | bin = { 48 | luacheck = "bin/luacheck.lua" 49 | } 50 | }, 51 | copy_directories = {"spec", "doc"} 52 | } 53 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.14.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.14.0-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck", 5 | tag = "0.14.0" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.main"] = "src/luacheck/main.lua", 24 | ["luacheck.config"] = "src/luacheck/config.lua", 25 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 26 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 27 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 28 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 29 | ["luacheck.check"] = "src/luacheck/check.lua", 30 | ["luacheck.parser"] = "src/luacheck/parser.lua", 31 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 32 | ["luacheck.filter"] = "src/luacheck/filter.lua", 33 | ["luacheck.options"] = "src/luacheck/options.lua", 34 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 35 | ["luacheck.stds"] = "src/luacheck/stds.lua", 36 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 37 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 38 | ["luacheck.cache"] = "src/luacheck/cache.lua", 39 | ["luacheck.format"] = "src/luacheck/format.lua", 40 | ["luacheck.version"] = "src/luacheck/version.lua", 41 | ["luacheck.fs"] = "src/luacheck/fs.lua", 42 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 43 | ["luacheck.utils"] = "src/luacheck/utils.lua", 44 | ["luacheck.argparse"] = "src/luacheck/argparse.lua" 45 | }, 46 | install = { 47 | bin = { 48 | luacheck = "bin/luacheck.lua" 49 | } 50 | }, 51 | copy_directories = {"spec", "doc"} 52 | } 53 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.15.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.15.0-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck", 5 | tag = "0.15.0" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.main"] = "src/luacheck/main.lua", 24 | ["luacheck.config"] = "src/luacheck/config.lua", 25 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 26 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 27 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 28 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 29 | ["luacheck.check"] = "src/luacheck/check.lua", 30 | ["luacheck.parser"] = "src/luacheck/parser.lua", 31 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 32 | ["luacheck.filter"] = "src/luacheck/filter.lua", 33 | ["luacheck.options"] = "src/luacheck/options.lua", 34 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 35 | ["luacheck.stds"] = "src/luacheck/stds.lua", 36 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 37 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 38 | ["luacheck.cache"] = "src/luacheck/cache.lua", 39 | ["luacheck.format"] = "src/luacheck/format.lua", 40 | ["luacheck.version"] = "src/luacheck/version.lua", 41 | ["luacheck.fs"] = "src/luacheck/fs.lua", 42 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 43 | ["luacheck.utils"] = "src/luacheck/utils.lua", 44 | ["luacheck.argparse"] = "src/luacheck/argparse.lua" 45 | }, 46 | install = { 47 | bin = { 48 | luacheck = "bin/luacheck.lua" 49 | } 50 | }, 51 | copy_directories = {"spec", "doc"} 52 | } 53 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.15.1-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.15.1-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck", 5 | tag = "0.15.1" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.main"] = "src/luacheck/main.lua", 24 | ["luacheck.config"] = "src/luacheck/config.lua", 25 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 26 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 27 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 28 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 29 | ["luacheck.check"] = "src/luacheck/check.lua", 30 | ["luacheck.parser"] = "src/luacheck/parser.lua", 31 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 32 | ["luacheck.filter"] = "src/luacheck/filter.lua", 33 | ["luacheck.options"] = "src/luacheck/options.lua", 34 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 35 | ["luacheck.stds"] = "src/luacheck/stds.lua", 36 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 37 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 38 | ["luacheck.cache"] = "src/luacheck/cache.lua", 39 | ["luacheck.format"] = "src/luacheck/format.lua", 40 | ["luacheck.version"] = "src/luacheck/version.lua", 41 | ["luacheck.fs"] = "src/luacheck/fs.lua", 42 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 43 | ["luacheck.utils"] = "src/luacheck/utils.lua", 44 | ["luacheck.argparse"] = "src/luacheck/argparse.lua" 45 | }, 46 | install = { 47 | bin = { 48 | luacheck = "bin/luacheck.lua" 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.16.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.16.0-1" 3 | source = { 4 | url = "git+https://github.com/mpeterv/luacheck.git", 5 | tag = "0.16.0" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 24 | ["luacheck.argparse"] = "src/luacheck/argparse.lua", 25 | ["luacheck.cache"] = "src/luacheck/cache.lua", 26 | ["luacheck.check"] = "src/luacheck/check.lua", 27 | ["luacheck.config"] = "src/luacheck/config.lua", 28 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 29 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 30 | ["luacheck.filter"] = "src/luacheck/filter.lua", 31 | ["luacheck.format"] = "src/luacheck/format.lua", 32 | ["luacheck.fs"] = "src/luacheck/fs.lua", 33 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 34 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 35 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 36 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 37 | ["luacheck.main"] = "src/luacheck/main.lua", 38 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 39 | ["luacheck.options"] = "src/luacheck/options.lua", 40 | ["luacheck.parser"] = "src/luacheck/parser.lua", 41 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 42 | ["luacheck.stds"] = "src/luacheck/stds.lua", 43 | ["luacheck.utils"] = "src/luacheck/utils.lua", 44 | ["luacheck.version"] = "src/luacheck/version.lua" 45 | }, 46 | install = { 47 | bin = { 48 | luacheck = "bin/luacheck.lua" 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.16.1-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.16.1-1" 3 | source = { 4 | url = "git+https://github.com/mpeterv/luacheck.git", 5 | tag = "0.16.1" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 24 | ["luacheck.argparse"] = "src/luacheck/argparse.lua", 25 | ["luacheck.cache"] = "src/luacheck/cache.lua", 26 | ["luacheck.check"] = "src/luacheck/check.lua", 27 | ["luacheck.config"] = "src/luacheck/config.lua", 28 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 29 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 30 | ["luacheck.filter"] = "src/luacheck/filter.lua", 31 | ["luacheck.format"] = "src/luacheck/format.lua", 32 | ["luacheck.fs"] = "src/luacheck/fs.lua", 33 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 34 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 35 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 36 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 37 | ["luacheck.main"] = "src/luacheck/main.lua", 38 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 39 | ["luacheck.options"] = "src/luacheck/options.lua", 40 | ["luacheck.parser"] = "src/luacheck/parser.lua", 41 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 42 | ["luacheck.stds"] = "src/luacheck/stds.lua", 43 | ["luacheck.utils"] = "src/luacheck/utils.lua", 44 | ["luacheck.version"] = "src/luacheck/version.lua" 45 | }, 46 | install = { 47 | bin = { 48 | luacheck = "bin/luacheck.lua" 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.16.2-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.16.2-1" 3 | source = { 4 | url = "git+https://github.com/mpeterv/luacheck.git", 5 | tag = "0.16.2" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 24 | ["luacheck.argparse"] = "src/luacheck/argparse.lua", 25 | ["luacheck.cache"] = "src/luacheck/cache.lua", 26 | ["luacheck.check"] = "src/luacheck/check.lua", 27 | ["luacheck.config"] = "src/luacheck/config.lua", 28 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 29 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 30 | ["luacheck.filter"] = "src/luacheck/filter.lua", 31 | ["luacheck.format"] = "src/luacheck/format.lua", 32 | ["luacheck.fs"] = "src/luacheck/fs.lua", 33 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 34 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 35 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 36 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 37 | ["luacheck.main"] = "src/luacheck/main.lua", 38 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 39 | ["luacheck.options"] = "src/luacheck/options.lua", 40 | ["luacheck.parser"] = "src/luacheck/parser.lua", 41 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 42 | ["luacheck.stds"] = "src/luacheck/stds.lua", 43 | ["luacheck.utils"] = "src/luacheck/utils.lua", 44 | ["luacheck.version"] = "src/luacheck/version.lua" 45 | }, 46 | install = { 47 | bin = { 48 | luacheck = "bin/luacheck.lua" 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.16.3-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.16.3-1" 3 | source = { 4 | url = "git+https://github.com/mpeterv/luacheck.git", 5 | tag = "0.16.3" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 24 | ["luacheck.argparse"] = "src/luacheck/argparse.lua", 25 | ["luacheck.cache"] = "src/luacheck/cache.lua", 26 | ["luacheck.check"] = "src/luacheck/check.lua", 27 | ["luacheck.config"] = "src/luacheck/config.lua", 28 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 29 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 30 | ["luacheck.filter"] = "src/luacheck/filter.lua", 31 | ["luacheck.format"] = "src/luacheck/format.lua", 32 | ["luacheck.fs"] = "src/luacheck/fs.lua", 33 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 34 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 35 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 36 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 37 | ["luacheck.main"] = "src/luacheck/main.lua", 38 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 39 | ["luacheck.options"] = "src/luacheck/options.lua", 40 | ["luacheck.parser"] = "src/luacheck/parser.lua", 41 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 42 | ["luacheck.stds"] = "src/luacheck/stds.lua", 43 | ["luacheck.utils"] = "src/luacheck/utils.lua", 44 | ["luacheck.version"] = "src/luacheck/version.lua" 45 | }, 46 | install = { 47 | bin = { 48 | luacheck = "bin/luacheck.lua" 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.17.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.17.0-1" 3 | source = { 4 | url = "git+https://github.com/mpeterv/luacheck.git", 5 | tag = "0.17.0" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 24 | ["luacheck.argparse"] = "src/luacheck/argparse.lua", 25 | ["luacheck.cache"] = "src/luacheck/cache.lua", 26 | ["luacheck.check"] = "src/luacheck/check.lua", 27 | ["luacheck.config"] = "src/luacheck/config.lua", 28 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 29 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 30 | ["luacheck.filter"] = "src/luacheck/filter.lua", 31 | ["luacheck.format"] = "src/luacheck/format.lua", 32 | ["luacheck.fs"] = "src/luacheck/fs.lua", 33 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 34 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 35 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 36 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 37 | ["luacheck.main"] = "src/luacheck/main.lua", 38 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 39 | ["luacheck.options"] = "src/luacheck/options.lua", 40 | ["luacheck.parser"] = "src/luacheck/parser.lua", 41 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 42 | ["luacheck.stds"] = "src/luacheck/stds.lua", 43 | ["luacheck.utils"] = "src/luacheck/utils.lua", 44 | ["luacheck.version"] = "src/luacheck/version.lua", 45 | ["luacheck.whitespace"] = "src/luacheck/whitespace.lua" 46 | }, 47 | install = { 48 | bin = { 49 | luacheck = "bin/luacheck.lua" 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.17.1-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.17.1-1" 3 | source = { 4 | url = "git+https://github.com/mpeterv/luacheck.git", 5 | tag = "0.17.1" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 24 | ["luacheck.argparse"] = "src/luacheck/argparse.lua", 25 | ["luacheck.cache"] = "src/luacheck/cache.lua", 26 | ["luacheck.check"] = "src/luacheck/check.lua", 27 | ["luacheck.config"] = "src/luacheck/config.lua", 28 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 29 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 30 | ["luacheck.filter"] = "src/luacheck/filter.lua", 31 | ["luacheck.format"] = "src/luacheck/format.lua", 32 | ["luacheck.fs"] = "src/luacheck/fs.lua", 33 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 34 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 35 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 36 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 37 | ["luacheck.main"] = "src/luacheck/main.lua", 38 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 39 | ["luacheck.options"] = "src/luacheck/options.lua", 40 | ["luacheck.parser"] = "src/luacheck/parser.lua", 41 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 42 | ["luacheck.stds"] = "src/luacheck/stds.lua", 43 | ["luacheck.utils"] = "src/luacheck/utils.lua", 44 | ["luacheck.version"] = "src/luacheck/version.lua", 45 | ["luacheck.whitespace"] = "src/luacheck/whitespace.lua" 46 | }, 47 | install = { 48 | bin = { 49 | luacheck = "bin/luacheck.lua" 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.18.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.18.0-1" 3 | source = { 4 | url = "git+https://github.com/mpeterv/luacheck.git", 5 | tag = "0.18.0" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 24 | ["luacheck.argparse"] = "src/luacheck/argparse.lua", 25 | ["luacheck.cache"] = "src/luacheck/cache.lua", 26 | ["luacheck.check"] = "src/luacheck/check.lua", 27 | ["luacheck.config"] = "src/luacheck/config.lua", 28 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 29 | ["luacheck.detect_globals"] = "src/luacheck/detect_globals.lua", 30 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 31 | ["luacheck.filter"] = "src/luacheck/filter.lua", 32 | ["luacheck.format"] = "src/luacheck/format.lua", 33 | ["luacheck.fs"] = "src/luacheck/fs.lua", 34 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 35 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 36 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 37 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 38 | ["luacheck.main"] = "src/luacheck/main.lua", 39 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 40 | ["luacheck.options"] = "src/luacheck/options.lua", 41 | ["luacheck.parser"] = "src/luacheck/parser.lua", 42 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 43 | ["luacheck.stds"] = "src/luacheck/stds.lua", 44 | ["luacheck.utils"] = "src/luacheck/utils.lua", 45 | ["luacheck.version"] = "src/luacheck/version.lua", 46 | ["luacheck.whitespace"] = "src/luacheck/whitespace.lua" 47 | }, 48 | install = { 49 | bin = { 50 | luacheck = "bin/luacheck.lua" 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.19.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.19.0-1" 3 | source = { 4 | url = "git+https://github.com/mpeterv/luacheck.git", 5 | tag = "0.19.0" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 24 | ["luacheck.argparse"] = "src/luacheck/argparse.lua", 25 | ["luacheck.builtin_standards"] = "src/luacheck/builtin_standards.lua", 26 | ["luacheck.cache"] = "src/luacheck/cache.lua", 27 | ["luacheck.check"] = "src/luacheck/check.lua", 28 | ["luacheck.config"] = "src/luacheck/config.lua", 29 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 30 | ["luacheck.detect_globals"] = "src/luacheck/detect_globals.lua", 31 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 32 | ["luacheck.filter"] = "src/luacheck/filter.lua", 33 | ["luacheck.format"] = "src/luacheck/format.lua", 34 | ["luacheck.fs"] = "src/luacheck/fs.lua", 35 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 36 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 37 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 38 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 39 | ["luacheck.main"] = "src/luacheck/main.lua", 40 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 41 | ["luacheck.options"] = "src/luacheck/options.lua", 42 | ["luacheck.parser"] = "src/luacheck/parser.lua", 43 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 44 | ["luacheck.standards"] = "src/luacheck/standards.lua", 45 | ["luacheck.utils"] = "src/luacheck/utils.lua", 46 | ["luacheck.version"] = "src/luacheck/version.lua", 47 | ["luacheck.whitespace"] = "src/luacheck/whitespace.lua" 48 | }, 49 | install = { 50 | bin = { 51 | luacheck = "bin/luacheck.lua" 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.19.1-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.19.1-1" 3 | source = { 4 | url = "git+https://github.com/mpeterv/luacheck.git", 5 | tag = "0.19.1" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 24 | ["luacheck.argparse"] = "src/luacheck/argparse.lua", 25 | ["luacheck.builtin_standards"] = "src/luacheck/builtin_standards.lua", 26 | ["luacheck.cache"] = "src/luacheck/cache.lua", 27 | ["luacheck.check"] = "src/luacheck/check.lua", 28 | ["luacheck.config"] = "src/luacheck/config.lua", 29 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 30 | ["luacheck.detect_globals"] = "src/luacheck/detect_globals.lua", 31 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 32 | ["luacheck.filter"] = "src/luacheck/filter.lua", 33 | ["luacheck.format"] = "src/luacheck/format.lua", 34 | ["luacheck.fs"] = "src/luacheck/fs.lua", 35 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 36 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 37 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 38 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 39 | ["luacheck.main"] = "src/luacheck/main.lua", 40 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 41 | ["luacheck.options"] = "src/luacheck/options.lua", 42 | ["luacheck.parser"] = "src/luacheck/parser.lua", 43 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 44 | ["luacheck.standards"] = "src/luacheck/standards.lua", 45 | ["luacheck.utils"] = "src/luacheck/utils.lua", 46 | ["luacheck.version"] = "src/luacheck/version.lua", 47 | ["luacheck.whitespace"] = "src/luacheck/whitespace.lua" 48 | }, 49 | install = { 50 | bin = { 51 | luacheck = "bin/luacheck.lua" 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.2.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.2.0-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck.git", 5 | tag = "0.2.0" 6 | } 7 | description = { 8 | summary = "A simple static analyzer", 9 | detailed = [[ 10 | luacheck only looks for three things: non-standard global variables, unused local variables and redefinitions of existing local variables in the same scope. 11 | 12 | luacheck provides a command-line interface as well as a small library which can be used from another Lua program. 13 | ]], 14 | homepage = "https://github.com/mpeterv/luacheck", 15 | license = "MIT/X11" 16 | } 17 | dependencies = { 18 | "lua >= 5.1, < 5.3", 19 | "metalua-parser >= 0.7.3-2", 20 | "checks >= 1.0", 21 | "argparse >= 0.2.0", 22 | "ansicolors >= 1.0-1" 23 | } 24 | build = { 25 | type = "builtin", 26 | modules = { 27 | luacheck = "src/luacheck.lua", 28 | ["luacheck.scan"] = "src/luacheck/scan.lua", 29 | ["luacheck.check"] = "src/luacheck/check.lua", 30 | ["luacheck.get_report"] = "src/luacheck/get_report.lua", 31 | ["luacheck.format"] = "src/luacheck/format.lua" 32 | }, 33 | install = { 34 | bin = { 35 | luacheck = "bin/luacheck.lua" 36 | } 37 | }, 38 | copy_directories = {"spec", "doc"} 39 | } 40 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.20.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.20.0-1" 3 | source = { 4 | url = "git+https://github.com/mpeterv/luacheck.git", 5 | tag = "0.20.0" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 24 | ["luacheck.argparse"] = "src/luacheck/argparse.lua", 25 | ["luacheck.builtin_standards"] = "src/luacheck/builtin_standards.lua", 26 | ["luacheck.cache"] = "src/luacheck/cache.lua", 27 | ["luacheck.check"] = "src/luacheck/check.lua", 28 | ["luacheck.config"] = "src/luacheck/config.lua", 29 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 30 | ["luacheck.detect_globals"] = "src/luacheck/detect_globals.lua", 31 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 32 | ["luacheck.filter"] = "src/luacheck/filter.lua", 33 | ["luacheck.format"] = "src/luacheck/format.lua", 34 | ["luacheck.fs"] = "src/luacheck/fs.lua", 35 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 36 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 37 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 38 | ["luacheck.lfs_fs"] = "src/luacheck/lfs_fs.lua", 39 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 40 | ["luacheck.love_standard"] = "src/luacheck/love_standard.lua", 41 | ["luacheck.lua_fs"] = "src/luacheck/lua_fs.lua", 42 | ["luacheck.main"] = "src/luacheck/main.lua", 43 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 44 | ["luacheck.options"] = "src/luacheck/options.lua", 45 | ["luacheck.parser"] = "src/luacheck/parser.lua", 46 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 47 | ["luacheck.standards"] = "src/luacheck/standards.lua", 48 | ["luacheck.utils"] = "src/luacheck/utils.lua", 49 | ["luacheck.version"] = "src/luacheck/version.lua", 50 | ["luacheck.whitespace"] = "src/luacheck/whitespace.lua" 51 | }, 52 | install = { 53 | bin = { 54 | luacheck = "bin/luacheck.lua" 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.21.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.21.0-1" 3 | source = { 4 | url = "git+https://github.com/mpeterv/luacheck.git", 5 | tag = "0.21.0" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 24 | ["luacheck.argparse"] = "src/luacheck/argparse.lua", 25 | ["luacheck.builtin_standards"] = "src/luacheck/builtin_standards.lua", 26 | ["luacheck.cache"] = "src/luacheck/cache.lua", 27 | ["luacheck.check"] = "src/luacheck/check.lua", 28 | ["luacheck.config"] = "src/luacheck/config.lua", 29 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 30 | ["luacheck.detect_globals"] = "src/luacheck/detect_globals.lua", 31 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 32 | ["luacheck.filter"] = "src/luacheck/filter.lua", 33 | ["luacheck.format"] = "src/luacheck/format.lua", 34 | ["luacheck.fs"] = "src/luacheck/fs.lua", 35 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 36 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 37 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 38 | ["luacheck.lfs_fs"] = "src/luacheck/lfs_fs.lua", 39 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 40 | ["luacheck.love_standard"] = "src/luacheck/love_standard.lua", 41 | ["luacheck.lua_fs"] = "src/luacheck/lua_fs.lua", 42 | ["luacheck.main"] = "src/luacheck/main.lua", 43 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 44 | ["luacheck.ngx_standard"] = "src/luacheck/ngx_standard.lua", 45 | ["luacheck.options"] = "src/luacheck/options.lua", 46 | ["luacheck.parser"] = "src/luacheck/parser.lua", 47 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 48 | ["luacheck.standards"] = "src/luacheck/standards.lua", 49 | ["luacheck.utils"] = "src/luacheck/utils.lua", 50 | ["luacheck.version"] = "src/luacheck/version.lua", 51 | ["luacheck.whitespace"] = "src/luacheck/whitespace.lua" 52 | }, 53 | install = { 54 | bin = { 55 | luacheck = "bin/luacheck.lua" 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.21.1-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.21.1-1" 3 | source = { 4 | url = "git+https://github.com/mpeterv/luacheck.git", 5 | tag = "0.21.1" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 24 | ["luacheck.argparse"] = "src/luacheck/argparse.lua", 25 | ["luacheck.builtin_standards"] = "src/luacheck/builtin_standards.lua", 26 | ["luacheck.cache"] = "src/luacheck/cache.lua", 27 | ["luacheck.check"] = "src/luacheck/check.lua", 28 | ["luacheck.config"] = "src/luacheck/config.lua", 29 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 30 | ["luacheck.detect_globals"] = "src/luacheck/detect_globals.lua", 31 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 32 | ["luacheck.filter"] = "src/luacheck/filter.lua", 33 | ["luacheck.format"] = "src/luacheck/format.lua", 34 | ["luacheck.fs"] = "src/luacheck/fs.lua", 35 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 36 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 37 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 38 | ["luacheck.lfs_fs"] = "src/luacheck/lfs_fs.lua", 39 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 40 | ["luacheck.love_standard"] = "src/luacheck/love_standard.lua", 41 | ["luacheck.lua_fs"] = "src/luacheck/lua_fs.lua", 42 | ["luacheck.main"] = "src/luacheck/main.lua", 43 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 44 | ["luacheck.ngx_standard"] = "src/luacheck/ngx_standard.lua", 45 | ["luacheck.options"] = "src/luacheck/options.lua", 46 | ["luacheck.parser"] = "src/luacheck/parser.lua", 47 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 48 | ["luacheck.standards"] = "src/luacheck/standards.lua", 49 | ["luacheck.utils"] = "src/luacheck/utils.lua", 50 | ["luacheck.version"] = "src/luacheck/version.lua", 51 | ["luacheck.whitespace"] = "src/luacheck/whitespace.lua" 52 | }, 53 | install = { 54 | bin = { 55 | luacheck = "bin/luacheck.lua" 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.21.2-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.21.2-1" 3 | source = { 4 | url = "git+https://github.com/mpeterv/luacheck.git", 5 | tag = "0.21.2" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 24 | ["luacheck.argparse"] = "src/luacheck/argparse.lua", 25 | ["luacheck.builtin_standards"] = "src/luacheck/builtin_standards.lua", 26 | ["luacheck.cache"] = "src/luacheck/cache.lua", 27 | ["luacheck.check"] = "src/luacheck/check.lua", 28 | ["luacheck.config"] = "src/luacheck/config.lua", 29 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 30 | ["luacheck.detect_globals"] = "src/luacheck/detect_globals.lua", 31 | ["luacheck.detect_uninit_access"] = "src/luacheck/detect_uninit_access.lua", 32 | ["luacheck.detect_unreachable_code"] = "src/luacheck/detect_unreachable_code.lua", 33 | ["luacheck.detect_unused_rec_funcs"] = "src/luacheck/detect_unused_rec_funcs.lua", 34 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 35 | ["luacheck.filter"] = "src/luacheck/filter.lua", 36 | ["luacheck.format"] = "src/luacheck/format.lua", 37 | ["luacheck.fs"] = "src/luacheck/fs.lua", 38 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 39 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 40 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 41 | ["luacheck.lfs_fs"] = "src/luacheck/lfs_fs.lua", 42 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 43 | ["luacheck.love_standard"] = "src/luacheck/love_standard.lua", 44 | ["luacheck.lua_fs"] = "src/luacheck/lua_fs.lua", 45 | ["luacheck.main"] = "src/luacheck/main.lua", 46 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 47 | ["luacheck.ngx_standard"] = "src/luacheck/ngx_standard.lua", 48 | ["luacheck.options"] = "src/luacheck/options.lua", 49 | ["luacheck.parser"] = "src/luacheck/parser.lua", 50 | ["luacheck.standards"] = "src/luacheck/standards.lua", 51 | ["luacheck.utils"] = "src/luacheck/utils.lua", 52 | ["luacheck.version"] = "src/luacheck/version.lua", 53 | ["luacheck.whitespace"] = "src/luacheck/whitespace.lua" 54 | }, 55 | install = { 56 | bin = { 57 | luacheck = "bin/luacheck.lua" 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.22.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.22.0-1" 3 | source = { 4 | url = "git+https://github.com/mpeterv/luacheck.git", 5 | tag = "0.22.0" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT" 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.argparse"] = "src/luacheck/argparse.lua", 24 | ["luacheck.builtin_standards"] = "src/luacheck/builtin_standards.lua", 25 | ["luacheck.cache"] = "src/luacheck/cache.lua", 26 | ["luacheck.check"] = "src/luacheck/check.lua", 27 | ["luacheck.config"] = "src/luacheck/config.lua", 28 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 29 | ["luacheck.detect_bad_whitespace"] = "src/luacheck/detect_bad_whitespace.lua", 30 | ["luacheck.detect_cyclomatic_complexity"] = "src/luacheck/detect_cyclomatic_complexity.lua", 31 | ["luacheck.detect_globals"] = "src/luacheck/detect_globals.lua", 32 | ["luacheck.detect_uninit_access"] = "src/luacheck/detect_uninit_access.lua", 33 | ["luacheck.detect_unreachable_code"] = "src/luacheck/detect_unreachable_code.lua", 34 | ["luacheck.detect_unused_locals"] = "src/luacheck/detect_unused_locals.lua", 35 | ["luacheck.detect_unused_rec_funcs"] = "src/luacheck/detect_unused_rec_funcs.lua", 36 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 37 | ["luacheck.filter"] = "src/luacheck/filter.lua", 38 | ["luacheck.format"] = "src/luacheck/format.lua", 39 | ["luacheck.fs"] = "src/luacheck/fs.lua", 40 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 41 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 42 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 43 | ["luacheck.lfs_fs"] = "src/luacheck/lfs_fs.lua", 44 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 45 | ["luacheck.love_standard"] = "src/luacheck/love_standard.lua", 46 | ["luacheck.lua_fs"] = "src/luacheck/lua_fs.lua", 47 | ["luacheck.main"] = "src/luacheck/main.lua", 48 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 49 | ["luacheck.name_functions"] = "src/luacheck/name_functions.lua", 50 | ["luacheck.ngx_standard"] = "src/luacheck/ngx_standard.lua", 51 | ["luacheck.options"] = "src/luacheck/options.lua", 52 | ["luacheck.parser"] = "src/luacheck/parser.lua", 53 | ["luacheck.resolve_locals"] = "src/luacheck/resolve_locals.lua", 54 | ["luacheck.runner"] = "src/luacheck/runner.lua", 55 | ["luacheck.standards"] = "src/luacheck/standards.lua", 56 | ["luacheck.utils"] = "src/luacheck/utils.lua", 57 | ["luacheck.version"] = "src/luacheck/version.lua" 58 | }, 59 | install = { 60 | bin = { 61 | luacheck = "bin/luacheck.lua" 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.22.1-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.22.1-1" 3 | source = { 4 | url = "git+https://github.com/mpeterv/luacheck.git", 5 | tag = "0.22.1" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT" 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.argparse"] = "src/luacheck/argparse.lua", 24 | ["luacheck.builtin_standards"] = "src/luacheck/builtin_standards.lua", 25 | ["luacheck.cache"] = "src/luacheck/cache.lua", 26 | ["luacheck.check"] = "src/luacheck/check.lua", 27 | ["luacheck.config"] = "src/luacheck/config.lua", 28 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 29 | ["luacheck.detect_bad_whitespace"] = "src/luacheck/detect_bad_whitespace.lua", 30 | ["luacheck.detect_cyclomatic_complexity"] = "src/luacheck/detect_cyclomatic_complexity.lua", 31 | ["luacheck.detect_globals"] = "src/luacheck/detect_globals.lua", 32 | ["luacheck.detect_uninit_access"] = "src/luacheck/detect_uninit_access.lua", 33 | ["luacheck.detect_unreachable_code"] = "src/luacheck/detect_unreachable_code.lua", 34 | ["luacheck.detect_unused_locals"] = "src/luacheck/detect_unused_locals.lua", 35 | ["luacheck.detect_unused_rec_funcs"] = "src/luacheck/detect_unused_rec_funcs.lua", 36 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 37 | ["luacheck.filter"] = "src/luacheck/filter.lua", 38 | ["luacheck.format"] = "src/luacheck/format.lua", 39 | ["luacheck.fs"] = "src/luacheck/fs.lua", 40 | ["luacheck.globbing"] = "src/luacheck/globbing.lua", 41 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 42 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 43 | ["luacheck.lfs_fs"] = "src/luacheck/lfs_fs.lua", 44 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 45 | ["luacheck.love_standard"] = "src/luacheck/love_standard.lua", 46 | ["luacheck.lua_fs"] = "src/luacheck/lua_fs.lua", 47 | ["luacheck.main"] = "src/luacheck/main.lua", 48 | ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", 49 | ["luacheck.name_functions"] = "src/luacheck/name_functions.lua", 50 | ["luacheck.ngx_standard"] = "src/luacheck/ngx_standard.lua", 51 | ["luacheck.options"] = "src/luacheck/options.lua", 52 | ["luacheck.parser"] = "src/luacheck/parser.lua", 53 | ["luacheck.resolve_locals"] = "src/luacheck/resolve_locals.lua", 54 | ["luacheck.runner"] = "src/luacheck/runner.lua", 55 | ["luacheck.standards"] = "src/luacheck/standards.lua", 56 | ["luacheck.utils"] = "src/luacheck/utils.lua", 57 | ["luacheck.version"] = "src/luacheck/version.lua" 58 | }, 59 | install = { 60 | bin = { 61 | luacheck = "bin/luacheck.lua" 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.3.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.3.0-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck.git", 5 | tag = "0.3.0" 6 | } 7 | description = { 8 | summary = "A simple static analyzer", 9 | detailed = [[ 10 | luacheck only looks for three things: non-standard global variables, unused local variables and redefinitions of existing local variables in the same scope. 11 | 12 | luacheck provides a command-line interface as well as a small library which can be used from another Lua program. 13 | ]], 14 | homepage = "https://github.com/mpeterv/luacheck", 15 | license = "MIT/X11" 16 | } 17 | dependencies = { 18 | "lua >= 5.1, < 5.3", 19 | "metalua-parser >= 0.7.3-2", 20 | "checks >= 1.0", 21 | "argparse >= 0.2.0", 22 | "ansicolors >= 1.0-1" 23 | } 24 | build = { 25 | type = "builtin", 26 | modules = { 27 | luacheck = "src/luacheck.lua", 28 | ["luacheck.scan"] = "src/luacheck/scan.lua", 29 | ["luacheck.check"] = "src/luacheck/check.lua", 30 | ["luacheck.get_report"] = "src/luacheck/get_report.lua", 31 | ["luacheck.format"] = "src/luacheck/format.lua" 32 | }, 33 | install = { 34 | bin = { 35 | luacheck = "bin/luacheck.lua" 36 | } 37 | }, 38 | copy_directories = {"spec", "doc"} 39 | } 40 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.4.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.4.0-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck.git", 5 | tag = "0.4.0" 6 | } 7 | description = { 8 | summary = "A simple static analyzer", 9 | detailed = [[ 10 | luacheck only looks for three things: non-standard global variables, unused local variables and redefinitions of existing local variables in the same scope. 11 | 12 | luacheck provides a command-line interface as well as a small library which can be used from another Lua program. 13 | ]], 14 | homepage = "https://github.com/mpeterv/luacheck", 15 | license = "MIT/X11" 16 | } 17 | dependencies = { 18 | "lua >= 5.1, < 5.3", 19 | "metalua-parser >= 0.7.3-2", 20 | "checks >= 1.0", 21 | "argparse >= 0.2.0", 22 | "ansicolors >= 1.0-1" 23 | } 24 | build = { 25 | type = "builtin", 26 | modules = { 27 | luacheck = "src/luacheck.lua", 28 | ["luacheck.scan"] = "src/luacheck/scan.lua", 29 | ["luacheck.check"] = "src/luacheck/check.lua", 30 | ["luacheck.get_report"] = "src/luacheck/get_report.lua", 31 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 32 | ["luacheck.format"] = "src/luacheck/format.lua" 33 | }, 34 | install = { 35 | bin = { 36 | luacheck = "bin/luacheck.lua" 37 | } 38 | }, 39 | copy_directories = {"spec", "doc"} 40 | } 41 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.4.1-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.4.1-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck.git", 5 | branch = "0.4.x", 6 | tag = "0.4.1" 7 | } 8 | description = { 9 | summary = "A simple static analyzer", 10 | detailed = [[ 11 | luacheck only looks for three things: non-standard global variables, unused local variables and redefinitions of existing local variables in the same scope. 12 | 13 | luacheck provides a command-line interface as well as a small library which can be used from another Lua program. 14 | ]], 15 | homepage = "https://github.com/mpeterv/luacheck", 16 | license = "MIT/X11" 17 | } 18 | dependencies = { 19 | "lua >= 5.1, < 5.3", 20 | "metalua-parser >= 0.7.3-2", 21 | "checks >= 1.0", 22 | "argparse >= 0.3.0", 23 | "ansicolors >= 1.0-1" 24 | } 25 | build = { 26 | type = "builtin", 27 | modules = { 28 | luacheck = "src/luacheck.lua", 29 | ["luacheck.scan"] = "src/luacheck/scan.lua", 30 | ["luacheck.check"] = "src/luacheck/check.lua", 31 | ["luacheck.get_report"] = "src/luacheck/get_report.lua", 32 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 33 | ["luacheck.format"] = "src/luacheck/format.lua" 34 | }, 35 | install = { 36 | bin = { 37 | luacheck = "bin/luacheck.lua" 38 | } 39 | }, 40 | copy_directories = {"spec", "doc"} 41 | } 42 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.5.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.5.0-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck.git", 5 | tag = "0.5.0" 6 | } 7 | description = { 8 | summary = "A simple static analyzer for Lua", 9 | detailed = [[ 10 | Luacheck is a tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua applications. 11 | 12 | Luacheck provides a command line interface as well as a Lua module which can be used by other programs. 13 | ]], 14 | homepage = "https://github.com/mpeterv/luacheck", 15 | license = "MIT/X11" 16 | } 17 | dependencies = { 18 | "lua >= 5.1, < 5.3", 19 | "metalua-parser >= 0.7.3-2", 20 | "checks >= 1.0", 21 | "argparse >= 0.3.0", 22 | "ansicolors >= 1.0-1", 23 | "luafilesystem >= 1.6.2" 24 | } 25 | build = { 26 | type = "builtin", 27 | modules = { 28 | luacheck = "src/luacheck.lua", 29 | ["luacheck.scan"] = "src/luacheck/scan.lua", 30 | ["luacheck.check"] = "src/luacheck/check.lua", 31 | ["luacheck.filter"] = "src/luacheck/filter.lua", 32 | ["luacheck.options"] = "src/luacheck/options.lua", 33 | ["luacheck.stds"] = "src/luacheck/stds.lua", 34 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 35 | ["luacheck.utils"] = "src/luacheck/utils.lua", 36 | ["luacheck.format"] = "src/luacheck/format.lua" 37 | }, 38 | install = { 39 | bin = { 40 | luacheck = "bin/luacheck.lua" 41 | } 42 | }, 43 | copy_directories = {"spec", "doc"} 44 | } 45 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.6.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.6.0-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck.git", 5 | tag = "0.6.0" 6 | } 7 | description = { 8 | summary = "A simple static analyzer for Lua", 9 | detailed = [[ 10 | Luacheck is a tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT/X11" 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "argparse >= 0.3.0", 18 | "ansicolors >= 1.0-1", 19 | "luafilesystem >= 1.6.2" 20 | } 21 | build = { 22 | type = "builtin", 23 | modules = { 24 | luacheck = "src/luacheck.lua", 25 | ["luacheck.scan"] = "src/luacheck/scan.lua", 26 | ["luacheck.check"] = "src/luacheck/check.lua", 27 | ["luacheck.parser"] = "src/luacheck/parser.lua", 28 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 29 | ["luacheck.filter"] = "src/luacheck/filter.lua", 30 | ["luacheck.options"] = "src/luacheck/options.lua", 31 | ["luacheck.stds"] = "src/luacheck/stds.lua", 32 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 33 | ["luacheck.utils"] = "src/luacheck/utils.lua", 34 | ["luacheck.format"] = "src/luacheck/format.lua" 35 | }, 36 | install = { 37 | bin = { 38 | luacheck = "bin/luacheck.lua" 39 | } 40 | }, 41 | copy_directories = {"spec", "doc"} 42 | } 43 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.7.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.7.0-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck.git", 5 | tag = "0.7.0" 6 | } 7 | description = { 8 | summary = "A simple static analyzer for Lua", 9 | detailed = [[ 10 | Luacheck is a tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT/X11" 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "argparse >= 0.3.0", 18 | "ansicolors >= 1.0-1", 19 | "luafilesystem >= 1.6.2" 20 | } 21 | build = { 22 | type = "builtin", 23 | modules = { 24 | luacheck = "src/luacheck.lua", 25 | ["luacheck.scan"] = "src/luacheck/scan.lua", 26 | ["luacheck.check"] = "src/luacheck/check.lua", 27 | ["luacheck.parser"] = "src/luacheck/parser.lua", 28 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 29 | ["luacheck.filter"] = "src/luacheck/filter.lua", 30 | ["luacheck.options"] = "src/luacheck/options.lua", 31 | ["luacheck.stds"] = "src/luacheck/stds.lua", 32 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 33 | ["luacheck.utils"] = "src/luacheck/utils.lua", 34 | ["luacheck.format"] = "src/luacheck/format.lua" 35 | }, 36 | install = { 37 | bin = { 38 | luacheck = "bin/luacheck.lua" 39 | } 40 | }, 41 | copy_directories = {"spec", "doc"} 42 | } 43 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.7.1-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.7.1-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck.git", 5 | tag = "0.7.1" 6 | } 7 | description = { 8 | summary = "A simple static analyzer for Lua", 9 | detailed = [[ 10 | Luacheck is a tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT/X11" 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "argparse >= 0.3.0", 18 | "ansicolors >= 1.0-1", 19 | "luafilesystem >= 1.6.2" 20 | } 21 | build = { 22 | type = "builtin", 23 | modules = { 24 | luacheck = "src/luacheck.lua", 25 | ["luacheck.scan"] = "src/luacheck/scan.lua", 26 | ["luacheck.check"] = "src/luacheck/check.lua", 27 | ["luacheck.parser"] = "src/luacheck/parser.lua", 28 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 29 | ["luacheck.filter"] = "src/luacheck/filter.lua", 30 | ["luacheck.options"] = "src/luacheck/options.lua", 31 | ["luacheck.stds"] = "src/luacheck/stds.lua", 32 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 33 | ["luacheck.utils"] = "src/luacheck/utils.lua", 34 | ["luacheck.format"] = "src/luacheck/format.lua" 35 | }, 36 | install = { 37 | bin = { 38 | luacheck = "bin/luacheck.lua" 39 | } 40 | }, 41 | copy_directories = {"spec", "doc"} 42 | } 43 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.7.2-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.7.2-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck.git", 5 | tag = "0.7.2" 6 | } 7 | description = { 8 | summary = "A simple static analyzer for Lua", 9 | detailed = [[ 10 | Luacheck is a tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT/X11" 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "argparse >= 0.3.0", 18 | "ansicolors >= 1.0-1", 19 | "luafilesystem >= 1.6.2" 20 | } 21 | build = { 22 | type = "builtin", 23 | modules = { 24 | luacheck = "src/luacheck.lua", 25 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 26 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 27 | ["luacheck.check"] = "src/luacheck/check.lua", 28 | ["luacheck.parser"] = "src/luacheck/parser.lua", 29 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 30 | ["luacheck.filter"] = "src/luacheck/filter.lua", 31 | ["luacheck.options"] = "src/luacheck/options.lua", 32 | ["luacheck.stds"] = "src/luacheck/stds.lua", 33 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 34 | ["luacheck.utils"] = "src/luacheck/utils.lua", 35 | ["luacheck.format"] = "src/luacheck/format.lua" 36 | }, 37 | install = { 38 | bin = { 39 | luacheck = "bin/luacheck.lua" 40 | } 41 | }, 42 | copy_directories = {"spec", "doc"} 43 | } 44 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.7.3-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.7.3-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck.git", 5 | tag = "0.7.3" 6 | } 7 | description = { 8 | summary = "A simple static analyzer for Lua", 9 | detailed = [[ 10 | Luacheck is a tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT/X11" 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "argparse >= 0.3.0", 18 | "ansicolors >= 1.0-1", 19 | "luafilesystem >= 1.6.2" 20 | } 21 | build = { 22 | type = "builtin", 23 | modules = { 24 | luacheck = "src/luacheck.lua", 25 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 26 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 27 | ["luacheck.check"] = "src/luacheck/check.lua", 28 | ["luacheck.parser"] = "src/luacheck/parser.lua", 29 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 30 | ["luacheck.filter"] = "src/luacheck/filter.lua", 31 | ["luacheck.options"] = "src/luacheck/options.lua", 32 | ["luacheck.stds"] = "src/luacheck/stds.lua", 33 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 34 | ["luacheck.utils"] = "src/luacheck/utils.lua", 35 | ["luacheck.format"] = "src/luacheck/format.lua" 36 | }, 37 | install = { 38 | bin = { 39 | luacheck = "bin/luacheck.lua" 40 | } 41 | }, 42 | copy_directories = {"spec", "doc"} 43 | } 44 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.8.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.8.0-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck.git", 5 | tag = "0.8.0" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT/X11" 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 24 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 25 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 26 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 27 | ["luacheck.check"] = "src/luacheck/check.lua", 28 | ["luacheck.parser"] = "src/luacheck/parser.lua", 29 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 30 | ["luacheck.filter"] = "src/luacheck/filter.lua", 31 | ["luacheck.options"] = "src/luacheck/options.lua", 32 | ["luacheck.stds"] = "src/luacheck/stds.lua", 33 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 34 | ["luacheck.format"] = "src/luacheck/format.lua", 35 | ["luacheck.utils"] = "src/luacheck/utils.lua", 36 | ["luacheck.argparse"] = "src/luacheck/argparse.lua" 37 | }, 38 | install = { 39 | bin = { 40 | luacheck = "bin/luacheck.lua" 41 | } 42 | }, 43 | copy_directories = {"spec", "doc"} 44 | } 45 | -------------------------------------------------------------------------------- /rockspecs/luacheck-0.9.0-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luacheck" 2 | version = "0.9.0-1" 3 | source = { 4 | url = "git://github.com/mpeterv/luacheck.git", 5 | tag = "0.9.0" 6 | } 7 | description = { 8 | summary = "A static analyzer and a linter for Lua", 9 | detailed = [[ 10 | Luacheck is a command-line tool for linting and static analysis of Lua code. It is able to spot usage of undefined global variables, unused local variables and a few other typical problems within Lua programs. 11 | ]], 12 | homepage = "https://github.com/mpeterv/luacheck", 13 | license = "MIT " 14 | } 15 | dependencies = { 16 | "lua >= 5.1, < 5.4", 17 | "luafilesystem >= 1.6.3" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | luacheck = "src/luacheck/init.lua", 23 | ["luacheck.linearize"] = "src/luacheck/linearize.lua", 24 | ["luacheck.analyze"] = "src/luacheck/analyze.lua", 25 | ["luacheck.reachability"] = "src/luacheck/reachability.lua", 26 | ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", 27 | ["luacheck.check"] = "src/luacheck/check.lua", 28 | ["luacheck.parser"] = "src/luacheck/parser.lua", 29 | ["luacheck.lexer"] = "src/luacheck/lexer.lua", 30 | ["luacheck.filter"] = "src/luacheck/filter.lua", 31 | ["luacheck.options"] = "src/luacheck/options.lua", 32 | ["luacheck.inline_options"] = "src/luacheck/inline_options.lua", 33 | ["luacheck.stds"] = "src/luacheck/stds.lua", 34 | ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", 35 | ["luacheck.format"] = "src/luacheck/format.lua", 36 | ["luacheck.utils"] = "src/luacheck/utils.lua", 37 | ["luacheck.argparse"] = "src/luacheck/argparse.lua" 38 | }, 39 | install = { 40 | bin = { 41 | luacheck = "bin/luacheck.lua" 42 | } 43 | }, 44 | copy_directories = {"spec", "doc"} 45 | } 46 | -------------------------------------------------------------------------------- /scripts/build-binaries.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eu 3 | set -o pipefail 4 | 5 | # Builds the following binaries: 6 | # * luacheck (Linux x86-64) 7 | # * luacheck32 (Linux x86) 8 | # * luacheck.exe (Windows x86-64) 9 | # * luacheck32.exe (Windows x86) 10 | # Should be executed from root Luacheck directory. 11 | # Resulting binaries will be in `build/bin/`. 12 | 13 | cd build 14 | 15 | make fetch 16 | 17 | function build { 18 | label="$1" 19 | shift 20 | 21 | echo 22 | echo "=== Building Luacheck ($label) ===" 23 | echo 24 | 25 | make clean "$@" 26 | make "-j$(nproc)" "$@" 27 | } 28 | 29 | build "Linux x86-64" LINUX=1 30 | #build "Linux x86" LINUX=1 "BASE_CC=gcc -m32" SUFFIX=32 31 | build "Windows x86-64" CROSS=x86_64-w64-mingw32- SUFFIX=.exe 32 | build "Windows x86" CROSS=i686-w64-mingw32- SUFFIX=32.exe 33 | -------------------------------------------------------------------------------- /scripts/dedicated_coverage.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eu 3 | set -o pipefail 4 | 5 | # Collects test coverage for luacheck modules with associated spec files. 6 | # Runs spec files from the arguments or all spec files. 7 | # Each module can be covered only from its own spec file. 8 | # Should be executed from root Luacheck directory. 9 | 10 | declare -A spec_to_module 11 | spec_to_module[spec/bad_whitespace_spec.lua]=src/luacheck/stages/detect_bad_whitespace.lua 12 | spec_to_module[spec/cache_spec.lua]=src/luacheck/cache.lua 13 | spec_to_module[spec/check_spec.lua]=src/luacheck/check.lua 14 | spec_to_module[spec/config_spec.lua]=src/luacheck/config.lua 15 | spec_to_module[spec/decoder_spec.lua]=src/luacheck/decoder.lua 16 | spec_to_module[spec/empty_blocks_spec.lua]="src/luacheck/stages/detect_empty_blocks.lua" 17 | spec_to_module[spec/expand_rockspec_spec.lua]=src/luacheck/expand_rockspec.lua 18 | spec_to_module[spec/filter_spec.lua]=src/luacheck/filter.lua 19 | spec_to_module[spec/format_spec.lua]=src/luacheck/format.lua 20 | spec_to_module[spec/fs_spec.lua]=src/luacheck/fs.lua 21 | spec_to_module[spec/globbing_spec.lua]=src/luacheck/globbing.lua 22 | spec_to_module[spec/luacheck_spec.lua]=src/luacheck/init.lua 23 | spec_to_module[spec/lexer_spec.lua]=src/luacheck/lexer.lua 24 | spec_to_module[spec/cli_spec.lua]=src/luacheck/main.lua 25 | spec_to_module[spec/options_spec.lua]=src/luacheck/options.lua 26 | spec_to_module[spec/parser_spec.lua]=src/luacheck/parser.lua 27 | spec_to_module[spec/serializer_spec.lua]=src/luacheck/serializer.lua 28 | spec_to_module[spec/cyclomatic_complexity_spec.lua]=src/luacheck/stages/detect_cyclomatic_complexity.lua 29 | spec_to_module[spec/globals_spec.lua]=src/luacheck/stages/detect_globals.lua 30 | spec_to_module[spec/reversed_fornum_loops_spec.lua]=src/luacheck/stages/detect_reversed_fornum_loops.lua 31 | spec_to_module[spec/unbalanced_assignments_spec.lua]=src/luacheck/stages/detect_unbalanced_assignments.lua 32 | spec_to_module[spec/uninit_accesses_spec.lua]=src/luacheck/stages/detect_uninit_accesses.lua 33 | spec_to_module[spec/unreachable_code_spec.lua]=src/luacheck/stages/detect_unreachable_code.lua 34 | spec_to_module[spec/unused_fields_spec.lua]=src/luacheck/stages/detect_unused_fields.lua 35 | spec_to_module[spec/unused_locals_spec.lua]=src/luacheck/stages/detect_unused_locals.lua 36 | spec_to_module[spec/linearize_spec.lua]=src/luacheck/stages/linearize.lua 37 | spec_to_module[spec/resolve_locals_spec.lua]=src/luacheck/stages/resolve_locals.lua 38 | spec_to_module[spec/standards_spec.lua]=src/luacheck/standards.lua 39 | spec_to_module[spec/utils_spec.lua]=src/luacheck/utils.lua 40 | 41 | if [ $# -eq 0 ]; then 42 | specs="$(sort <<< "${!spec_to_module[@]}")" 43 | else 44 | specs="$@" 45 | fi 46 | 47 | { 48 | echo Spec Module Hits Missed Coverage 49 | 50 | for spec in $specs; do 51 | if [ -v spec_to_module[$spec] ]; then 52 | module="${spec_to_module[$spec]}" 53 | 54 | rm -f luacov.stats.out 55 | rm -f luacov.report.out 56 | 57 | echo "busted -c $spec" >&2 58 | busted -c "$spec" >&2 || true 59 | luacov 60 | echo -n "$spec " 61 | grep -P "$module +[^ ]+ +[^ ]+ +[^ ]+" luacov.report.out || echo "$module 0 0 0.00%" 62 | echo >&2 63 | else 64 | echo "No associated module for spec $spec" >&2 65 | fi 66 | done 67 | } | column -t 68 | -------------------------------------------------------------------------------- /scripts/gen_unicode_printability_module.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eu 3 | set -o pipefail 4 | 5 | # Generates luacheck.unicode_printability_boundaries module given Unicode version. 6 | # Should be executed from root Luacheck directory. 7 | 8 | url="https://www.unicode.org/Public/$1/ucd/UnicodeData.txt" 9 | cache="scripts/UnicodeData-$1.txt" 10 | 11 | if [ ! -e "$cache" ]; then 12 | wget -O "$cache" "$url" 13 | fi 14 | 15 | ( 16 | echo "-- Autogenerated using data from $url"; 17 | lua scripts/unicode_data_to_printability_module.lua < "$cache" 18 | ) > src/luacheck/unicode_printability_boundaries.lua 19 | -------------------------------------------------------------------------------- /scripts/package.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eu 3 | set -o pipefail 4 | 5 | # Creates rockspec and source rock for a new Luacheck release given version number. 6 | # Should be executed from root Luacheck directory. 7 | # Resulting rockspec and rock will be in `package/`. 8 | 9 | version="$1" 10 | 11 | rm -rf package 12 | mkdir package 13 | cd package 14 | 15 | 16 | echo 17 | echo "=== Creating rockspec for Luacheck $version ===" 18 | echo 19 | 20 | luarocks new-version ../luacheck-dev-1.rockspec --tag="$version" 21 | 22 | echo 23 | echo "=== Copying Luacheck files ===" 24 | echo 25 | 26 | mkdir luacheck 27 | cp -r ../src luacheck 28 | mkdir luacheck/bin 29 | cp ../bin/luacheck.lua luacheck/bin 30 | cp -r ../doc luacheck 31 | cp ../README.md ../CHANGELOG.md ../LICENSE luacheck 32 | 33 | echo 34 | echo "=== Packing source rock for Luacheck $version ===" 35 | echo 36 | 37 | zip -r luacheck-"$version"-1.src.rock luacheck luacheck-"$version"-1.rockspec 38 | 39 | cd .. 40 | -------------------------------------------------------------------------------- /scripts/unicode_data_to_printability_module.lua: -------------------------------------------------------------------------------- 1 | -- Reads Unicode character data in UnicodeData.txt format from stdin. 2 | -- Prints a Lua module retuning an array of first codepoints of 3 | -- each continuous block of codepoints that are all printable or all not printable. 4 | -- See https://unicode.org/reports/tr44/ 5 | 6 | local category_printabilities = { 7 | Lu = true, 8 | Ll = true, 9 | Lt = true, 10 | Lm = true, 11 | Lo = true, 12 | Mn = true, 13 | Mc = true, 14 | Me = true, 15 | Nd = true, 16 | Nl = true, 17 | No = true, 18 | Pc = true, 19 | Pd = true, 20 | Ps = true, 21 | Pe = true, 22 | Pi = true, 23 | Pf = true, 24 | Po = true, 25 | Sm = true, 26 | Sc = true, 27 | Sk = true, 28 | So = true, 29 | Zs = true, 30 | Zl = false, 31 | Zp = false, 32 | Cc = false, 33 | Cf = false, 34 | Cs = false, 35 | Co = false, 36 | Cn = false 37 | } 38 | 39 | local codepoint_printabilities = {} 40 | local max_codepoint = 0 41 | 42 | local range_start_codepoint 43 | 44 | for line in io.lines() do 45 | local codepoint_hex, name, category = assert(line:match("^([^;]+);([^;]+);([^;]+)")) 46 | local codepoint = assert(tonumber("0x" .. codepoint_hex)) 47 | local printability = category_printabilities[category] 48 | assert(printability ~= nil) 49 | 50 | if name:find(", First>$") then 51 | assert(not range_start_codepoint) 52 | range_start_codepoint = codepoint 53 | elseif name:find(", Last>$") then 54 | assert(range_start_codepoint and range_start_codepoint >= range_start_codepoint) 55 | 56 | for range_codepoint = range_start_codepoint, codepoint do 57 | codepoint_printabilities[range_codepoint] = printability 58 | end 59 | 60 | range_start_codepoint = nil 61 | else 62 | codepoint_printabilities[codepoint] = printability 63 | end 64 | 65 | max_codepoint = math.max(max_codepoint, codepoint) 66 | end 67 | 68 | assert(not range_start_codepoint) 69 | 70 | local parts = {"return {"} 71 | local prev_printability = true 72 | 73 | -- Iterate up to a non-existent codepoint to ensure that the last required codepoint is printed. 74 | for codepoint = 0, max_codepoint + 1 do 75 | local printability = codepoint_printabilities[codepoint] or false 76 | 77 | if printability ~= prev_printability then 78 | table.insert(parts, ("%d,"):format(codepoint)) 79 | end 80 | 81 | prev_printability = printability 82 | end 83 | 84 | table.insert(parts, "}") 85 | print(table.concat(parts)) 86 | 87 | -------------------------------------------------------------------------------- /spec/bad_whitespace_spec.lua: -------------------------------------------------------------------------------- 1 | local helper = require "spec.helper" 2 | 3 | local function assert_warnings(warnings, src) 4 | assert.same(warnings, helper.get_stage_warnings("detect_bad_whitespace", src)) 5 | end 6 | 7 | describe("bad whitespace detection", function() 8 | it("detects lines with only whitespace", function() 9 | assert_warnings({ 10 | {code = "611", line = 1, column = 1, end_column = 4}, 11 | {code = "611", line = 3, column = 1, end_column = 1} 12 | }, " \n--[[\n \n]]\n") 13 | end) 14 | 15 | it("detects trailing whitespace with different warnings code depending on line ending type", function() 16 | assert_warnings({ 17 | {code = "612", line = 1, column = 8, end_column = 9}, 18 | {code = "613", line = 2, column = 13, end_column = 13}, 19 | {code = "612", line = 3, column = 8, end_column = 8}, 20 | {code = "614", line = 4, column = 11, end_column = 14} 21 | }, "local a \nlocal b = [[ \nthing]] \nlocal c --\t\t\t\t\nlocal d\n") 22 | end) 23 | 24 | it("detects spaces followed by tabs", function() 25 | assert_warnings({ 26 | {code = "621", line = 1, column = 1, end_column = 5} 27 | }, " \t \tlocal foo\n\t\t local bar\n") 28 | end) 29 | 30 | it("does not warn on spaces followed by tabs if the line has only whitespace", function() 31 | assert_warnings({ 32 | {code = "611", line = 1, column = 1, end_column = 7} 33 | }, " \t \t \n") 34 | end) 35 | 36 | it("can detect both trailing whitespace and inconsistent indentation on the same line", function() 37 | assert_warnings({ 38 | {code = "621", line = 1, column = 1, end_column = 2}, 39 | {code = "612", line = 1, column = 10, end_column = 10} 40 | }, " \tlocal a \n") 41 | end) 42 | 43 | it("handles lack of trailing newline", function() 44 | assert_warnings({ 45 | {code = "611", line = 2, column = 1, end_column = 5} 46 | }, "local a\n ") 47 | 48 | assert_warnings({ 49 | {code = "612", line = 2, column = 8, end_column = 12} 50 | }, "local a\nlocal b ") 51 | 52 | assert_warnings({ 53 | {code = "621", line = 1, column = 1, end_column = 2}, 54 | {code = "614", line = 1, column = 13, end_column = 16} 55 | }, " \tlocal a -- ") 56 | end) 57 | 58 | it("provides correct column ranges in presence of two-byte line endings", function() 59 | assert_warnings({ 60 | {code = "612", line = 1, column = 10, end_column = 13}, 61 | {code = "621", line = 2, column = 1, end_column = 4}, 62 | {code = "611", line = 3, column = 1, end_column = 3} 63 | }, "local foo \r\n \tlocal bar\n\r ") 64 | end) 65 | 66 | it("provides correct column ranges in presence of utf8", function() 67 | assert_warnings({ 68 | {code = "612", line = 1, column = 17, end_column = 20}, 69 | {code = "611", line = 2, column = 1, end_column = 4}, 70 | {code = "621", line = 3, column = 1, end_column = 4}, 71 | {code = "614", line = 3, column = 20, end_column = 24}, 72 | }, "local foo = '\204\128\204\130' \n \n \tlocal bar -- \240\144\128\128\224\166\152 \n") 73 | end) 74 | end) 75 | -------------------------------------------------------------------------------- /spec/cache_spec.lua: -------------------------------------------------------------------------------- 1 | local cache = require "luacheck.cache" 2 | local fs = require "luacheck.fs" 3 | local lfs = require "lfs" 4 | local sha1 = require "luacheck.vendor.sha1" 5 | 6 | setup(function() 7 | 8 | end) 9 | 10 | describe("cache", function() 11 | describe("get_default_dir", function() 12 | it("returns a string", function() 13 | assert.is_string(cache.get_default_dir()) 14 | end) 15 | end) 16 | 17 | describe("new", function() 18 | it("returns nil, error message on failure to init cache", function() 19 | local c, err = cache.new("LICENSE") 20 | assert.is_nil(c) 21 | assert.is_string(err) 22 | end) 23 | 24 | it("returns Cache object on success", function() 25 | local c = cache.new("src") 26 | assert.is_table(c) 27 | end) 28 | end) 29 | 30 | describe("Cache", function() 31 | local filename = "spec/caches/file.lua" 32 | local normalized_filename = fs.normalize(fs.join(fs.get_current_dir(), filename)) 33 | local cache_dir = "spec/caches" 34 | local cache_filename = fs.join(cache_dir, sha1.sha1(normalized_filename)) 35 | 36 | local c 37 | 38 | before_each(function() 39 | c = cache.new(cache_dir) 40 | assert.is_table(c) 41 | end) 42 | 43 | after_each(function() 44 | os.remove(filename) 45 | 46 | if lfs.attributes(cache_filename, "mode") == "directory" then 47 | lfs.rmdir(cache_filename) 48 | else 49 | os.remove(cache_filename) 50 | end 51 | end) 52 | 53 | local function make_report(code) 54 | return { 55 | warnings = { 56 | code and {code = code} 57 | }, 58 | inline_options = {}, 59 | line_lengths = {} 60 | } 61 | end 62 | 63 | describe("put", function() 64 | it("returns nil on failure to store cache", function() 65 | lfs.mkdir(cache_filename) 66 | local ok = c:put(filename, make_report()) 67 | assert.is_nil(ok) 68 | end) 69 | 70 | it("returns true on successfull cache store", function() 71 | local ok = c:put(filename, make_report()) 72 | assert.is_true(ok) 73 | end) 74 | end) 75 | 76 | describe("get", function() 77 | it("returns nil on cache miss", function() 78 | local report, err = c:get(filename) 79 | assert.is_nil(report) 80 | assert.is_nil(err) 81 | end) 82 | 83 | it("returns nil on outdated cache", function() 84 | assert.is_true(c:put(filename, make_report())) 85 | io.open(filename, "w"):close() 86 | assert.is_true(lfs.touch(filename, os.time() + 100000)) 87 | local report, err = c:get(filename) 88 | assert.is_nil(report) 89 | assert.is_nil(err) 90 | end) 91 | 92 | it("returns report on success", function() 93 | local original_report = make_report("111") 94 | assert.is_true(c:put(filename, original_report)) 95 | io.open(filename, "w"):close() 96 | assert.is_true(lfs.touch(filename, os.time() - 100000)) 97 | local cached_report = c:get(filename) 98 | assert.same(original_report, cached_report) 99 | end) 100 | end) 101 | end) 102 | end) 103 | -------------------------------------------------------------------------------- /spec/configs/bad_config.luacheckrc: -------------------------------------------------------------------------------- 1 | -- let's talk about ruby 2 | def method_missing(*args); args.join(" "); end 3 | -- wat 4 | -------------------------------------------------------------------------------- /spec/configs/bad_custom_std_config.luacheckrc: -------------------------------------------------------------------------------- 1 | stds.my_std = { 2 | read_globals = { 3 | foo = { 4 | fields = { 5 | 1, 2, 3 6 | } 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /spec/configs/cli_override_config.luacheckrc: -------------------------------------------------------------------------------- 1 | global = true 2 | globals = {"print", "setfenv", "rawlen"} 3 | -------------------------------------------------------------------------------- /spec/configs/cli_override_file_config.luacheckrc: -------------------------------------------------------------------------------- 1 | files["spec/samples/compat.lua"] = { 2 | global = true, 3 | globals = {"print", "setfenv", "rawlen"} 4 | } 5 | -------------------------------------------------------------------------------- /spec/configs/cli_specific_config.luacheckrc: -------------------------------------------------------------------------------- 1 | color = false 2 | codes = true 3 | formatter = function(report, file_names, options) 4 | return ([[ 5 | Files: %d 6 | Warnings: %d 7 | Errors: %d 8 | Quiet: %d 9 | Color: %s 10 | Codes: %s]]):format(#file_names, report.warnings, report.errors, options.quiet, 11 | options.color and "true" or "false", options.codes and "true" or "false") 12 | end 13 | -------------------------------------------------------------------------------- /spec/configs/compound_operators_config.luacheckrc: -------------------------------------------------------------------------------- 1 | operators = {"+=", "-=", "*=", "/="} 2 | -------------------------------------------------------------------------------- /spec/configs/config.lua: -------------------------------------------------------------------------------- 1 | return { 2 | std = "lua52" 3 | } 4 | -------------------------------------------------------------------------------- /spec/configs/custom_fields_config.luacheckrc: -------------------------------------------------------------------------------- 1 | stds = { 2 | my_server = { 3 | read_globals = { 4 | server = { 5 | fields = { 6 | bar = {read_only = false}, 7 | baz = {}, 8 | sessions = {read_only = false, other_fields = true} 9 | } 10 | } 11 | } 12 | } 13 | } 14 | 15 | read_globals = { 16 | server = { 17 | fields = { 18 | bar = {}, 19 | baz = {read_only = false}, 20 | sessions = {read_only = false, other_fields = true} 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spec/configs/custom_stds_config.luacheckrc: -------------------------------------------------------------------------------- 1 | stds = { 2 | my_std = {read_globals = {"print", "setfenv"}}, 3 | other_std = {read_globals = {"tostring", "setfenv"}} 4 | } 5 | 6 | std = "my_std" 7 | -------------------------------------------------------------------------------- /spec/configs/exclude_files_config.luacheckrc: -------------------------------------------------------------------------------- 1 | exclude_files = {"spec/samples/defined?.lua", "**/bad*.lua"} 2 | std = "min" 3 | -------------------------------------------------------------------------------- /spec/configs/format_opts_config.luacheckrc: -------------------------------------------------------------------------------- 1 | quiet = 1 2 | ranges = true 3 | codes = true 4 | -------------------------------------------------------------------------------- /spec/configs/global_config.luacheckrc: -------------------------------------------------------------------------------- 1 | globals = {"print", "setfenv", "rawlen"} 2 | -------------------------------------------------------------------------------- /spec/configs/import_config.luacheckrc: -------------------------------------------------------------------------------- 1 | codes = true 2 | std = "lua51" 3 | 4 | return require "spec.configs.config" 5 | -------------------------------------------------------------------------------- /spec/configs/invalid_config.luacheckrc: -------------------------------------------------------------------------------- 1 | ignore = "211" 2 | -------------------------------------------------------------------------------- /spec/configs/invalid_override_config.luacheckrc: -------------------------------------------------------------------------------- 1 | ignore = {"211"} 2 | 3 | files["spec/foo.lua"].enable = "211" 4 | -------------------------------------------------------------------------------- /spec/configs/multioverride_config.luacheckrc: -------------------------------------------------------------------------------- 1 | unused = false 2 | 3 | files["spec/samples/"] = { 4 | unused_args = true, 5 | enable = {"31"}, 6 | ignore = {"213"} 7 | } 8 | 9 | files["spec/samples/*_code.lua"] = { 10 | enable = {"213"} 11 | } 12 | -------------------------------------------------------------------------------- /spec/configs/override_config.luacheckrc: -------------------------------------------------------------------------------- 1 | files["spec/samples/bad_code.lua"] = { 2 | redefined = false, 3 | compat = true 4 | } 5 | 6 | files["spec/samples/unused_code.lua"].unused = false 7 | -------------------------------------------------------------------------------- /spec/configs/paths_config.luacheckrc: -------------------------------------------------------------------------------- 1 | cache = "something.luacheckcache" 2 | formatter = "helper.fmt" 3 | include_files = {"foo", "bar"} 4 | exclude_files = {"foo/thing"} 5 | -------------------------------------------------------------------------------- /spec/configs/project/.luacheckrc: -------------------------------------------------------------------------------- 1 | files["nested/ab.lua"].ignore = {"a"} 2 | files["nested/nested/"].enable = {"a"} 3 | files["nested/nested/"].ignore = {"b"} 4 | -------------------------------------------------------------------------------- /spec/configs/project/nested/ab.lua: -------------------------------------------------------------------------------- 1 | print(a, b) 2 | -------------------------------------------------------------------------------- /spec/configs/project/nested/nested/abc.lua: -------------------------------------------------------------------------------- 1 | print(a, b, c) 2 | -------------------------------------------------------------------------------- /spec/configs/runtime_bad_config.luacheckrc: -------------------------------------------------------------------------------- 1 | (nil)() 2 | -------------------------------------------------------------------------------- /spec/decoder_spec.lua: -------------------------------------------------------------------------------- 1 | local decoder = require "luacheck.decoder" 2 | local lua_utf8 = require "lua-utf8" 3 | 4 | local function assert_encoding(encoding, ...) 5 | local lib = encoding == "utf8" and lua_utf8 or string 6 | local length = select("#", ...) 7 | local bytes = lib.char(...) 8 | local chars = decoder.decode(bytes) 9 | 10 | local label_parts = {"("} 11 | 12 | for index = 1, length do 13 | table.insert(label_parts, ("\\u{%X}"):format((select(index, ...)))) 14 | end 15 | 16 | table.insert(label_parts, ")") 17 | local label = table.concat(label_parts) 18 | 19 | assert.equals(length, chars:get_length(), ":get_length" .. label) 20 | 21 | for from = 1, length do 22 | for to = from, length do 23 | assert.equals(lib.sub(bytes, from, to), chars:get_substring(from, to), ":get_substring" .. label) 24 | end 25 | end 26 | 27 | local iter, state, var 28 | 29 | if encoding == "utf8" then 30 | iter, state = lua_utf8.next, bytes 31 | else 32 | iter, state, var = ipairs({...}) 33 | end 34 | 35 | local index = 1 36 | 37 | for offset, codepoint in iter, state, var do 38 | assert.equals(codepoint, chars:get_codepoint(index), ":get_codepoint" .. label) 39 | 40 | local from, to, match = chars:find("(.)", index) 41 | assert.equals(offset, from, ":find" .. label) 42 | assert.equals(offset, to, ":find" .. label) 43 | assert.equals(bytes:sub(offset, offset), match, ":find" .. label) 44 | index = index + 1 45 | end 46 | end 47 | 48 | describe("decoder", function() 49 | it("decodes valid codepoints correctly", function() 50 | -- Checking literally all codepoints is very slow with coverage enabled, pick only a few. 51 | for base = 0, 0x10FFFF, 0x800 do 52 | for offset = 0, 0x100, 41 do 53 | local codepoint1 = base + offset 54 | local codepoint2 = codepoint1 + 9 55 | assert_encoding("utf8", codepoint1, codepoint2) 56 | end 57 | end 58 | end) 59 | 60 | it("falls back to latin1 on invalid utf8", function() 61 | -- Bad first byte. 62 | assert_encoding("latin1", 0xC0, 0x80, 0x80, 0x80) 63 | assert_encoding("latin1", 0x00, 0xF8, 0x80, 0x80, 0x80) 64 | 65 | -- Two bytes, bad continuation byte. 66 | assert_encoding("latin1", 0x00, 0xC0, 0x00, 0xC0, 0x80) 67 | assert_encoding("latin1", 0x00, 0xC0, 0xFF, 0xC0, 0x80) 68 | 69 | -- Three bytes, bad first continuation byte. 70 | assert_encoding("latin1", 0x00, 0xE0, 0x00, 0xC0, 0x80) 71 | assert_encoding("latin1", 0x00, 0xE0, 0xFF, 0xC0, 0x80) 72 | 73 | -- Three bytes, bad second continuation byte. 74 | assert_encoding("latin1", 0x00, 0xE0, 0x80, 0x00, 0xC0, 0x80) 75 | assert_encoding("latin1", 0x00, 0xE0, 0x80, 0xFF, 0xC0, 0x80) 76 | 77 | -- Four bytes, bad first continuation byte. 78 | assert_encoding("latin1", 0x00, 0xF0, 0x00, 0xC0, 0x80) 79 | assert_encoding("latin1", 0x00, 0xF0, 0xFF, 0xC0, 0x80) 80 | 81 | -- Four bytes, bad second continuation byte. 82 | assert_encoding("latin1", 0x00, 0xF0, 0x80, 0x00, 0xC0, 0x80) 83 | assert_encoding("latin1", 0x00, 0xF0, 0x80, 0xFF, 0xC0, 0x80) 84 | 85 | -- Four bytes, bad third continuation byte. 86 | assert_encoding("latin1", 0x00, 0xF0, 0x80, 0x80, 0x00, 0xC0, 0x80) 87 | assert_encoding("latin1", 0x00, 0xF0, 0x80, 0x80, 0xFF, 0xC0, 0x80) 88 | 89 | -- Codepoint too large. 90 | assert_encoding("latin1", 0xF7, 0x80, 0x80, 0x80, 0x00) 91 | end) 92 | end) 93 | -------------------------------------------------------------------------------- /spec/empty_blocks_spec.lua: -------------------------------------------------------------------------------- 1 | local helper = require "spec.helper" 2 | 3 | local function assert_warnings(warnings, src) 4 | assert.same(warnings, helper.get_stage_warnings("detect_empty_blocks", src)) 5 | end 6 | 7 | describe("empty block detection", function() 8 | it("detects empty blocks", function() 9 | assert_warnings({ 10 | {code = "541", line = 1, column = 1, end_column = 6}, 11 | {code = "542", line = 3, column = 8, end_column = 11}, 12 | {code = "542", line = 5, column = 12, end_column = 15}, 13 | {code = "542", line = 7, column = 1, end_column = 4} 14 | }, [[ 15 | do end 16 | 17 | if ... then 18 | 19 | elseif ... then 20 | 21 | else 22 | 23 | end 24 | 25 | if ... then 26 | somehing() 27 | else 28 | something_else() 29 | end 30 | 31 | do something() end 32 | 33 | while ... do end 34 | repeat until ... 35 | ]]) 36 | end) 37 | 38 | it("detects empty blocks in nested blocks and functions", function() 39 | assert_warnings({ 40 | {code = "541", line = 4, column = 10, end_column = 15}, 41 | {code = "541", line = 7, column = 13, end_column = 18}, 42 | {code = "541", line = 12, column = 22, end_column = 27}, 43 | {code = "542", line = 14, column = 27, end_column = 30} 44 | }, [[ 45 | do 46 | while x do 47 | if y then 48 | do end 49 | else 50 | repeat 51 | do end 52 | 53 | function t() 54 | for i = 1, 10 do 55 | for _, v in ipairs(tab) do 56 | do end 57 | 58 | if c then end 59 | end 60 | end 61 | end 62 | until z 63 | end 64 | end 65 | end 66 | ]]) 67 | end) 68 | end) 69 | -------------------------------------------------------------------------------- /spec/expand_rockspec_spec.lua: -------------------------------------------------------------------------------- 1 | local expand_rockspec = require "luacheck.expand_rockspec" 2 | local fs = require "luacheck.fs" 3 | local P = fs.normalize 4 | 5 | describe("expand_rockspec", function() 6 | it("returns sorted array of lua files related to a rock", function() 7 | assert.same({ 8 | "bar.lua", 9 | "baz.lua", 10 | "bin.lua", 11 | "foo.lua" 12 | }, expand_rockspec("spec/folder/rockspec")) 13 | end) 14 | 15 | it("autodetects modules for rockspecs without build table", function() 16 | assert.same({ 17 | P"spec/rock/src/rock.lua", 18 | P"spec/rock/src/rock/mod.lua", 19 | P"spec/rock/bin/rock.lua" 20 | }, expand_rockspec("spec/rock/rock-dev-1.rockspec")) 21 | end) 22 | 23 | it("autodetects modules for rockspecs without build.modules table", function() 24 | assert.same({ 25 | P"spec/rock2/mod.lua" 26 | }, expand_rockspec("spec/rock2/rock2-dev-1.rockspec")) 27 | end) 28 | 29 | it("returns nil, \"I/O\" for non-existent paths", function() 30 | local ok, err = expand_rockspec("spec/folder/non-existent") 31 | assert.is_nil(ok) 32 | assert.equal("I/O", err) 33 | end) 34 | 35 | it("returns nil, \"syntax\" for rockspecs with syntax errors", function() 36 | local ok, err = expand_rockspec("spec/folder/bad_config") 37 | assert.is_nil(ok) 38 | assert.equal("syntax", err) 39 | end) 40 | 41 | it("returns nil, \"runtime\" for rockspecs with run-time errors", function() 42 | local ok, err = expand_rockspec("spec/folder/bad_rockspec") 43 | assert.is_nil(ok) 44 | assert.equal("runtime", err) 45 | end) 46 | end) 47 | -------------------------------------------------------------------------------- /spec/folder/bad_config: -------------------------------------------------------------------------------- 1 | foo = `bar` 2 | -------------------------------------------------------------------------------- /spec/folder/bad_rockspec: -------------------------------------------------------------------------------- 1 | build "builtin" 2 | -------------------------------------------------------------------------------- /spec/folder/bom: -------------------------------------------------------------------------------- 1 | foo 2 | bar 3 | -------------------------------------------------------------------------------- /spec/folder/config: -------------------------------------------------------------------------------- 1 | foo = "bar" 2 | -------------------------------------------------------------------------------- /spec/folder/env_config: -------------------------------------------------------------------------------- 1 | foo = bar() 2 | -------------------------------------------------------------------------------- /spec/folder/folder1/another: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lunarmodules/luacheck/7dd65be108334cc1b380fece1a4422be050daa6a/spec/folder/folder1/another -------------------------------------------------------------------------------- /spec/folder/folder1/fail: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lunarmodules/luacheck/7dd65be108334cc1b380fece1a4422be050daa6a/spec/folder/folder1/fail -------------------------------------------------------------------------------- /spec/folder/folder1/file: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lunarmodules/luacheck/7dd65be108334cc1b380fece1a4422be050daa6a/spec/folder/folder1/file -------------------------------------------------------------------------------- /spec/folder/folder2/garbage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lunarmodules/luacheck/7dd65be108334cc1b380fece1a4422be050daa6a/spec/folder/folder2/garbage -------------------------------------------------------------------------------- /spec/folder/foo: -------------------------------------------------------------------------------- 1 | contents 2 | -------------------------------------------------------------------------------- /spec/folder/rockspec: -------------------------------------------------------------------------------- 1 | build = { 2 | type = "builtin", 3 | modules = { 4 | foo = "foo.lua", 5 | bar = "bar.lua", 6 | qu = "qu.c" 7 | }, 8 | install = { 9 | lua = { 10 | baz = "baz.lua" 11 | }, 12 | bin = { 13 | bin = "bin.lua" 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spec/formatters/custom_formatter.lua: -------------------------------------------------------------------------------- 1 | return function(report, file_names, options) 2 | return ([[ 3 | Files: %d 4 | Formatter: %s 5 | Quiet: %d 6 | Color: %s 7 | Codes: %s]]):format(#file_names, options.formatter, options.quiet, 8 | tostring(options.color), tostring(options.codes)) 9 | end 10 | -------------------------------------------------------------------------------- /spec/fs_spec.lua: -------------------------------------------------------------------------------- 1 | local fs = require "luacheck.fs" 2 | local utils = require "luacheck.utils" 3 | local P = fs.normalize 4 | 5 | describe("fs", function() 6 | describe("is_dir", function() 7 | it("returns true for directories", function() 8 | assert.is_true(fs.is_dir("spec/folder")) 9 | end) 10 | 11 | it("returns false for files", function() 12 | assert.is_false(fs.is_dir("spec/folder/foo")) 13 | end) 14 | 15 | it("returns false for non-existent paths", function() 16 | assert.is_false(fs.is_dir("spec/folder/non-existent")) 17 | end) 18 | end) 19 | 20 | describe("is_file", function() 21 | it("returns true for files", function() 22 | assert.is_true(fs.is_file("spec/folder/foo")) 23 | end) 24 | 25 | it("returns false for directories", function() 26 | assert.is_false(fs.is_file("spec/folder")) 27 | end) 28 | 29 | it("returns false for non-existent paths", function() 30 | assert.is_false(fs.is_file("spec/folder/non-existent")) 31 | end) 32 | end) 33 | 34 | describe("extract_files", function() 35 | it("returns sorted list of files in a directory matching pattern", function() 36 | assert.same({ 37 | P"spec/folder/folder1/fail", 38 | P"spec/folder/folder1/file", 39 | P"spec/folder/foo" 40 | }, fs.extract_files(P"spec/folder", "^f")) 41 | end) 42 | end) 43 | 44 | describe("get_mtime", function() 45 | it("returns modification time as a number", function() 46 | assert.number(fs.get_mtime("spec/folder/foo")) 47 | end) 48 | 49 | it("returns nil for non-existent files", function() 50 | assert.is_nil(fs.get_mtime("spec/folder/non-existent")) 51 | end) 52 | end) 53 | 54 | describe("get_current_dir", function() 55 | it("returns absolute path to current directory with trailing directory separator", function() 56 | local current_dir = fs.get_current_dir() 57 | assert.string(current_dir) 58 | assert.matches(utils.dir_sep .. "$", current_dir) 59 | assert.not_equal("", (fs.split_base(current_dir))) 60 | assert.is_true(fs.is_file(current_dir .. "spec/folder/foo")) 61 | end) 62 | end) 63 | 64 | describe("find_file", function() 65 | it("finds file in a directory", function() 66 | local path = P(fs.get_current_dir() .. "spec/folder") 67 | assert.equal(path, fs.find_file(path, "foo")) 68 | end) 69 | 70 | it("finds file in a parent directory", function() 71 | local path = P(fs.get_current_dir() .. "spec/folder") 72 | assert.equal(path, fs.find_file(fs.join(path, "folder1"), "foo")) 73 | end) 74 | 75 | it("returns nil if can't find file", function() 76 | assert.is_nil( 77 | fs.find_file(fs.get_current_dir(), "this file shouldn't exist or it will make luacheck testsuite break")) 78 | end) 79 | end) 80 | end) 81 | -------------------------------------------------------------------------------- /spec/globbing_spec.lua: -------------------------------------------------------------------------------- 1 | local globbing = require "luacheck.globbing" 2 | local fs = require "luacheck.fs" 3 | 4 | local cur_dir = fs.get_current_dir() 5 | 6 | local function check_match(expected_result, glob, path) 7 | glob = fs.normalize(fs.join(cur_dir, glob)) 8 | path = fs.normalize(fs.join(cur_dir, path)) 9 | assert.equal(expected_result, globbing.match(glob, path)) 10 | end 11 | 12 | describe("globbing", function() 13 | describe("match", function() 14 | it("returns true on literal match", function() 15 | check_match(true, "foo/bar", "foo/bar") 16 | end) 17 | 18 | it("returns true on literal match after normalization", function() 19 | check_match(true, "foo//bar/baz/..", "./foo/bar/") 20 | end) 21 | 22 | it("returns false for on literal mismatch", function() 23 | check_match(false, "foo/bar", "foo/baz") 24 | end) 25 | 26 | it("accepts subdirectory matches", function() 27 | check_match(true, "foo/bar", "foo/bar/baz") 28 | end) 29 | 30 | it("understands wildcards", function() 31 | check_match(true, "*", "foo") 32 | check_match(true, "foo/*r", "foo/bar") 33 | check_match(true, "foo/*r", "foo/bar/baz") 34 | check_match(false, "foo/*r", "foo/baz") 35 | end) 36 | 37 | it("understands optional characters", function() 38 | check_match(false, "?", "foo") 39 | check_match(true, "???", "foo") 40 | check_match(true, "????", "foo") 41 | check_match(true, "f?o/?a?", "foo/bar") 42 | check_match(false, "f?o/?a?", "foo/abc") 43 | end) 44 | 45 | it("understands ranges and classes", function() 46 | check_match(true, "[d-h]o[something]", "foo") 47 | check_match(false, "[d-h]o[somewhere]", "bar") 48 | check_match(false, "[.-h]o[i-z]", "bar") 49 | end) 50 | 51 | it("accepts closing bracket as first class character", function() 52 | check_match(true, "[]]", "]") 53 | check_match(false, "[]]", "[") 54 | check_match(true, "[]foo][]foo][]foo]", "foo") 55 | end) 56 | 57 | it("accepts dash as first or last class character", function() 58 | check_match(true, "[-]", "-") 59 | check_match(false, "[-]", "+") 60 | check_match(true, "[---]", "-") 61 | end) 62 | 63 | it("understands negation", function() 64 | check_match(true, "[!foo][!bar][!baz]", "boo") 65 | check_match(false, "[!foo][!bar][!baz]", "far") 66 | check_match(false, "[!a-z]", "g") 67 | end) 68 | 69 | it("understands recursive globbing using **", function() 70 | check_match(true, "**/*.lua", "foo.lua") 71 | check_match(true, "**/*.lua", "foo/bar.lua") 72 | check_match(false, "foo/**/*.lua", "bar.lua") 73 | check_match(false, "foo/**/*.lua", "foo.lua") 74 | check_match(true, "foo/**/bar/*.lua", "foo/bar/baz.lua") 75 | check_match(true, "foo/**/bar/*.lua", "foo/foo2/foo3/bar/baz.lua") 76 | check_match(false, "foo/**/bar/*.lua", "foo/baz.lua") 77 | check_match(false, "foo/**/bar/*.lua", "bar/baz.lua") 78 | end) 79 | end) 80 | end) 81 | -------------------------------------------------------------------------------- /spec/helper.lua: -------------------------------------------------------------------------------- 1 | local helper = {} 2 | 3 | local function get_lua() 4 | local index = -1 5 | local res = "lua" 6 | 7 | while arg[index] do 8 | res = arg[index] 9 | index = index - 1 10 | end 11 | 12 | return res 13 | end 14 | 15 | local dir_sep = package.config:sub(1, 1) 16 | 17 | -- Return path to root directory when run from `path`. 18 | local function antipath(path) 19 | local _, level = path:gsub("[/\\]", "") 20 | return (".."..dir_sep):rep(level) 21 | end 22 | 23 | function helper.luacov_config(prefix) 24 | return { 25 | statsfile = prefix.."luacov.stats.out", 26 | modules = { 27 | luacheck = "src/luacheck/init.lua", 28 | ["luacheck.*"] = "src", 29 | ["luacheck.*.*"] = "src", 30 | ["luacheck.*.*.*"] = "src" 31 | }, 32 | exclude = { 33 | "bin/luacheck$" 34 | } 35 | } 36 | end 37 | 38 | local luacov = package.loaded["luacov.runner"] 39 | local lua 40 | 41 | -- Returns command that runs `luacheck` executable from `loc_path`. 42 | function helper.luacheck_command(loc_path) 43 | lua = lua or get_lua() 44 | loc_path = loc_path or "." 45 | local prefix = antipath(loc_path) 46 | local cmd = ("cd %s && %s"):format(loc_path, lua) 47 | 48 | -- Extend package.path to allow loading this helper and luacheck modules. 49 | cmd = cmd..(' -e "package.path=[[%s?.lua;%ssrc%s?.lua;%ssrc%s?%sinit.lua;]]..package.path"'):format( 50 | prefix, prefix, dir_sep, prefix, dir_sep, dir_sep) 51 | 52 | if luacov then 53 | -- Launch luacov. 54 | cmd = cmd..(' -e "require[[luacov.runner]](require[[spec.helper]].luacov_config([[%s]]))"'):format(prefix) 55 | end 56 | 57 | return ("%s %sbin%sluacheck.lua"):format(cmd, prefix, dir_sep) 58 | end 59 | 60 | function helper.get_chstate_after_stage(target_stage_name, source) 61 | -- Luacov isn't yet started when helper is required, defer requiring luacheck 62 | -- modules so that their main chunks get covered. 63 | local check_state = require "luacheck.check_state" 64 | local stages = require "luacheck.stages" 65 | 66 | local chstate = check_state.new(source) 67 | 68 | for index, stage_name in ipairs(stages.names) do 69 | stages.modules[index].run(chstate) 70 | 71 | if stage_name == target_stage_name then 72 | return chstate 73 | end 74 | 75 | chstate.warnings = {} 76 | end 77 | 78 | error("no stage " .. target_stage_name, 0) 79 | end 80 | 81 | function helper.get_stage_warnings(target_stage_name, source) 82 | local core_utils = require "luacheck.core_utils" 83 | 84 | local chstate = helper.get_chstate_after_stage(target_stage_name, source) 85 | core_utils.sort_by_location(chstate.warnings) 86 | return chstate.warnings 87 | end 88 | 89 | return helper 90 | -------------------------------------------------------------------------------- /spec/projects/default_stds/.luacheckrc: -------------------------------------------------------------------------------- 1 | std = "min" 2 | 3 | files["**/test/**/*_spec.lua"] = { 4 | std = "none" 5 | } 6 | 7 | local shared_options = {ignore = {"ignored"}} 8 | 9 | files["**/spec/**/*_spec.lua"] = shared_options 10 | files["normal_file.lua"] = shared_options 11 | 12 | local function sink() end 13 | 14 | sink(it, version, math, newproxy) 15 | -------------------------------------------------------------------------------- /spec/projects/default_stds/default_stds-scm-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "default_stds" 2 | version = "scm-1" 3 | source = { 4 | url = "https://example.com" 5 | } 6 | description = { 7 | summary = "example", 8 | detailed = "example", 9 | homepage = "https://example.com", 10 | license = "MIT" 11 | } 12 | dependencies = {} 13 | it("is a rockspec")(newproxy, math, new_globals) 14 | -------------------------------------------------------------------------------- /spec/projects/default_stds/nested/spec/sample_spec.lua: -------------------------------------------------------------------------------- 1 | it("is a test in a nested directory")(newproxy, math, version, read_globals) 2 | ignored() 3 | -------------------------------------------------------------------------------- /spec/projects/default_stds/normal_file.lua: -------------------------------------------------------------------------------- 1 | it("is just a normal file")(newproxy, math, version, read_globals) 2 | ignored() 3 | -------------------------------------------------------------------------------- /spec/projects/default_stds/sample_spec.lua: -------------------------------------------------------------------------------- 1 | it("is not really a test")(newproxy, math, version, read_globals) 2 | -------------------------------------------------------------------------------- /spec/projects/default_stds/test/nested_normal_file.lua: -------------------------------------------------------------------------------- 1 | it("is a normal file in a nested directory")(newproxy, math, version, read_globals) 2 | -------------------------------------------------------------------------------- /spec/projects/default_stds/test/sample_spec.lua: -------------------------------------------------------------------------------- 1 | it("is a test in a test directory")(newproxy, math, version, read_globals) 2 | -------------------------------------------------------------------------------- /spec/projects/default_stds/tests/nested/sample_spec.lua: -------------------------------------------------------------------------------- 1 | it("is a test in a very nested directory")(newproxy, math, version, read_globals) 2 | -------------------------------------------------------------------------------- /spec/projects/default_stds/tests/sample_spec.lua: -------------------------------------------------------------------------------- 1 | it("is a test")(newproxy, math, version, read_globals) 2 | -------------------------------------------------------------------------------- /spec/reversed_fornum_loops_spec.lua: -------------------------------------------------------------------------------- 1 | local helper = require "spec.helper" 2 | 3 | local function assert_warnings(warnings, src) 4 | assert.same(warnings, helper.get_stage_warnings("detect_reversed_fornum_loops", src)) 5 | end 6 | 7 | describe("reversed fornum loop detection", function() 8 | it("does not detect anything wrong if not going down from #(expr)", function() 9 | assert_warnings({}, [[ 10 | for i = -10, 1 do 11 | print(i) 12 | end 13 | ]]) 14 | end) 15 | 16 | it("does not detect anything wrong if limit may be greater than 1", function() 17 | assert_warnings({}, [[ 18 | for i = #t, 2 do 19 | print(i) 20 | end 21 | 22 | for i = #t, x do 23 | print(i) 24 | end 25 | ]]) 26 | end) 27 | 28 | it("does not detect anything wrong if step may be negative", function() 29 | assert_warnings({}, [[ 30 | for i = #t, 1, -1 do 31 | print(i) 32 | end 33 | 34 | for i = #t, 1, x do 35 | print(i) 36 | end 37 | ]]) 38 | end) 39 | 40 | it("detects reversed loops going from #(expr) to limit less than or equal to 1", function() 41 | assert_warnings({ 42 | {code = "571", line = 1, column = 1, end_column = 16, limit = "1"}, 43 | {code = "571", line = 5, column = 1, end_column = 23, limit = "0"}, 44 | {code = "571", line = 9, column = 1, end_column = 32, limit = "-123.456"} 45 | }, [[ 46 | for i = #t, 1 do 47 | print(t[i]) 48 | end 49 | 50 | for i = #"abcdef", 0 do 51 | print(something) 52 | end 53 | 54 | for i = #(...), -123.456, 567 do 55 | print(something) 56 | end 57 | ]]) 58 | end) 59 | 60 | it("detects reversed loops in nested statements and functions", function() 61 | assert_warnings({ 62 | {code = "571", line = 7, column = 13, end_column = 28, limit = "1"}, 63 | {code = "571", line = 8, column = 16, end_column = 31, limit = "1"}, 64 | {code = "571", line = 10, column = 22, end_column = 43, limit = "1"} 65 | }, [[ 66 | do 67 | print("thing") 68 | 69 | while true do 70 | repeat 71 | for i, v in ipairs(t) do 72 | for i = #a, 1 do 73 | for i = #b, 1 do 74 | function xyz() 75 | for i = #"thing", 1 do 76 | print("thing") 77 | end 78 | end 79 | end 80 | end 81 | end 82 | until foo 83 | end 84 | end 85 | ]]) 86 | end) 87 | end) 88 | -------------------------------------------------------------------------------- /spec/rock/bin/rock.lua: -------------------------------------------------------------------------------- 1 | -- nothing 2 | -------------------------------------------------------------------------------- /spec/rock/bin/rock.sh: -------------------------------------------------------------------------------- 1 | # nothing 2 | -------------------------------------------------------------------------------- /spec/rock/lua_modules/something.lua: -------------------------------------------------------------------------------- 1 | -- nothing 2 | -------------------------------------------------------------------------------- /spec/rock/rock-dev-1.rockspec: -------------------------------------------------------------------------------- 1 | rockspec_format = "3.0" 2 | package = "rock" 3 | version = "dev-1" 4 | source = { 5 | url = "https://github.com/rockman/rock" 6 | } 7 | description = { 8 | license = "MIT" 9 | } 10 | dependencies = { 11 | "lua >= 5.1" 12 | } 13 | test_dependencies = { 14 | "busted = 2.0.rc12-1" 15 | } 16 | test = { 17 | type = "busted" 18 | } 19 | -------------------------------------------------------------------------------- /spec/rock/src/rock.lua: -------------------------------------------------------------------------------- 1 | -- nothing 2 | -------------------------------------------------------------------------------- /spec/rock/src/rock/mod.lua: -------------------------------------------------------------------------------- 1 | -- nothing 2 | -------------------------------------------------------------------------------- /spec/rock/src/rock/thing.c: -------------------------------------------------------------------------------- 1 | // nothing 2 | -------------------------------------------------------------------------------- /spec/rock/test.lua: -------------------------------------------------------------------------------- 1 | -- nothing 2 | -------------------------------------------------------------------------------- /spec/rock2/mod.lua: -------------------------------------------------------------------------------- 1 | -- nothing 2 | -------------------------------------------------------------------------------- /spec/rock2/rock2-dev-1.rockspec: -------------------------------------------------------------------------------- 1 | rockspec_format = "3.0" 2 | package = "rock2" 3 | version = "dev-1" 4 | source = { 5 | url = "https://github.com/rockman/rock2" 6 | } 7 | description = { 8 | license = "MIT" 9 | } 10 | dependencies = { 11 | "lua >= 5.1" 12 | } 13 | test_dependencies = { 14 | "busted = 2.0.rc12-1" 15 | } 16 | build = {} 17 | test = { 18 | type = "busted" 19 | } 20 | -------------------------------------------------------------------------------- /spec/rock2/spec/rock2_spec.lua: -------------------------------------------------------------------------------- 1 | -- nothing 2 | -------------------------------------------------------------------------------- /spec/samples/bad.rockspec: -------------------------------------------------------------------------------- 1 | bad("???") -------------------------------------------------------------------------------- /spec/samples/bad_code.lua: -------------------------------------------------------------------------------- 1 | package.loaded[...] = {} 2 | 3 | local function helper(...) 4 | -- NYI 5 | end 6 | 7 | function embrace(opt) 8 | local opt = opt or "default" 9 | return hepler(opt.."?") 10 | end 11 | -------------------------------------------------------------------------------- /spec/samples/bad_flow.lua: -------------------------------------------------------------------------------- 1 | if io.read("*n") == "exit" then 2 | 3 | else 4 | local a, b 5 | 6 | do 7 | -- print(something) 8 | end 9 | 10 | for _ = 1, 10 do 11 | if io.read("*n") == "foobar" then 12 | a, b = 1 13 | print(a, b) 14 | break 15 | else 16 | a, b = 1, 2, 3 17 | print(a, b) 18 | break 19 | end 20 | 21 | print("How could this happen?") 22 | end 23 | end 24 | 25 | while true do 26 | if package.loaded.foo then 27 | return 4 28 | else 29 | print(5) 30 | break 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /spec/samples/bad_whitespace.lua: -------------------------------------------------------------------------------- 1 | -- Examples of whitespace formatting violations 2 | 3 | local function trailing_whitespace_in_code() 4 | return "This is awful" 5 | end 6 | 7 | local function trailing_whitespace_in_comment() 8 | -- Less awful, but... 9 | return "Still bad" 10 | end 11 | 12 | local function trailing_whitespace_in_long_strings() 13 | return [[ 14 | It gets worse 15 | Much worse 16 | ]] 17 | --[[ Same in long comments 18 | ]] 19 | end 20 | 21 | local function trailing_whitespace_mixed() 22 | return "Not much better" -- You bet! 23 | end 24 | 25 | local function whitespace_only_lines() 26 | 27 | 28 | 29 | 30 | return "Lost in space" 31 | end 32 | 33 | local function inconsistent_indentation() 34 | return "Don't do this" 35 | end 36 | 37 | return { -- fake "module" table 38 | trailing_whitespace_in_code, 39 | trailing_whitespace_in_comment, 40 | trailing_whitespace_in_long_strings, 41 | trailing_whitespace_mixed, 42 | whitespace_only_lines, 43 | inconsistent_indentation, 44 | } 45 | -------------------------------------------------------------------------------- /spec/samples/compat.lua: -------------------------------------------------------------------------------- 1 | (setfenv and rawlen)(setfenv and rawlen) 2 | -------------------------------------------------------------------------------- /spec/samples/compound_operators.lua: -------------------------------------------------------------------------------- 1 | local i = 0 2 | i += 10 3 | i -= 5 4 | local function func() 5 | i /= 5 6 | end 7 | func() 8 | local t = {} 9 | t.a = i 10 | t.a *= 2 11 | return t 12 | -------------------------------------------------------------------------------- /spec/samples/custom_std_inline_options.lua: -------------------------------------------------------------------------------- 1 | -- luacheck: push 2 | -- luacheck: std +busted 3 | tostring(setfenv, print(it)) 4 | -- luacheck: pop 5 | -- luacheck: std other_std 6 | tostring(setfenv, print(it)) 7 | -------------------------------------------------------------------------------- /spec/samples/defined.lua: -------------------------------------------------------------------------------- 1 | foo = {} 2 | 3 | function foo.bar() 4 | baz() 5 | end 6 | -------------------------------------------------------------------------------- /spec/samples/defined2.lua: -------------------------------------------------------------------------------- 1 | foo.bar() 2 | -------------------------------------------------------------------------------- /spec/samples/defined3.lua: -------------------------------------------------------------------------------- 1 | foo = {} 2 | foo = {} 3 | bar = {} 4 | -------------------------------------------------------------------------------- /spec/samples/defined4.lua: -------------------------------------------------------------------------------- 1 | function foo() 2 | foo = 1 3 | bar = {} 4 | end 5 | -------------------------------------------------------------------------------- /spec/samples/empty.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lunarmodules/luacheck/7dd65be108334cc1b380fece1a4422be050daa6a/spec/samples/empty.lua -------------------------------------------------------------------------------- /spec/samples/global_fields.lua: -------------------------------------------------------------------------------- 1 | local t = table 2 | local upsert = t.upsert 3 | local update = upsert 4 | print(update.something) 5 | 6 | upsert = t.insert 7 | upsert() 8 | upsert.foo = "bar" 9 | 10 | package.loaded.hello = true 11 | package.loaded[package] = true 12 | 13 | local s1 = "find" 14 | local s2 = "gfind" 15 | 16 | -- luacheck: push std max 17 | print(string[s1]) 18 | print(string[s2]) 19 | -- luacheck: pop 20 | 21 | -- luacheck: push std min 22 | print(string[s1]) 23 | print(string[s2]) 24 | -- luacheck: pop 25 | 26 | -- luacheck: not globals string.find 27 | print(string[s1]) 28 | 29 | -- luacheck: globals nest.nest.nest 30 | nest.nest = "nest" 31 | 32 | print(server) 33 | print(server.sessions) 34 | server.foo = "bar" 35 | server.bar[_G] = "baz" 36 | server.baz = "abcd" 37 | print(server.baz.abcd) 38 | server.sessions["hey"] = "you" 39 | 40 | -- luacheck: std +my_server 41 | server.bar = 1 42 | server.baz = 2 43 | -------------------------------------------------------------------------------- /spec/samples/global_inline_options.lua: -------------------------------------------------------------------------------- 1 | -- luacheck: allow defined top 2 | foo = 4 3 | print(foo) 4 | bar = 6 -- luacheck: ignore 131 5 | 6 | function f() 7 | baz = 5 8 | -- luacheck: allow defined 9 | qu = 4 10 | print(qu) 11 | end 12 | 13 | -- luacheck: module, globals external 14 | quu = 7 15 | print(external) 16 | 17 | local function g() -- luacheck: ignore 18 | external = 8 19 | end 20 | -------------------------------------------------------------------------------- /spec/samples/globals.lua: -------------------------------------------------------------------------------- 1 | print(setfenv(rawlen(tostring))) 2 | -------------------------------------------------------------------------------- /spec/samples/good_code.lua: -------------------------------------------------------------------------------- 1 | local embracer = {} 2 | 3 | local function helper() 4 | -- NYI wontfix 5 | end 6 | 7 | function embracer.embrace(opt) 8 | opt = opt or "default" 9 | return helper(opt.."?") 10 | end 11 | 12 | return embracer 13 | -------------------------------------------------------------------------------- /spec/samples/indirect_globals.lua: -------------------------------------------------------------------------------- 1 | local t = table 2 | local g = global 3 | local t_concat 4 | t_concat = t.concat 5 | t_concat.foo.bar = g:method(g, global) 6 | -------------------------------------------------------------------------------- /spec/samples/inline_options.lua: -------------------------------------------------------------------------------- 1 | -- luacheck: ignore 4 2 | -- luacheck: ignore foo bar 3 | foo() 4 | bar() 5 | 6 | local function f(a) -- luacheck: no unused args 7 | -- luacheck: globals baz 8 | foo() 9 | bar() 10 | baz() 11 | qu() -- luacheck: globals qu 12 | qu() 13 | end 14 | 15 | baz() -- luacheck should ignore this comment 16 | 17 | -- luacheck: push ignore 2/f 18 | local f 19 | -- luacheck: push ignore 2/g 20 | local g 21 | -- luacheck: pop 22 | local f, g 23 | -- luacheck: pop 24 | local f, g 25 | 26 | -- luacheck: push 27 | local function f() --luacheck: ignore 28 | -- luacheck: pop 29 | end 30 | 31 | -- luacheck: ignore 5 32 | do end 33 | -- luacheck: enable 54 34 | do end 35 | if false then end 36 | -------------------------------------------------------------------------------- /spec/samples/line_length.lua: -------------------------------------------------------------------------------- 1 | -- luacheck: only 63 2 | local aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 | ------------------------------------------------------------------------------------------------------------------------------------------ comments can be long, too 4 | 5 | -- luacheck: push no max code line length 6 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = "readable code" 7 | string = [[ 8 | looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong 9 | ]] 10 | normal = "still normal" 11 | 12 | -- luacheck: push max line length 40 13 | this_overrides_code_line_specific_option = true 14 | -- luacheck: pop 15 | 16 | -- luacheck: pop 17 | 18 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = "unreadable" 19 | -- luacheck: max line length 80 20 | -- luacheck: max string line length 100 21 | -- luacheck: max comment line length 120 22 | local i_code_in_ed_in_a_terminal_with_default_width_and_i_dont_like_long_lines = true 23 | local really = false 24 | string2 = [[kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk94 25 | ]] 26 | string3 = [[kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk105 27 | ]] 28 | code() -- comment kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk105 29 | --[[ comment kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk125 30 | ]] 31 | -------------------------------------------------------------------------------- /spec/samples/luanti.lua: -------------------------------------------------------------------------------- 1 | local _ = core 2 | local _ = core.get_current_modname() 3 | -------------------------------------------------------------------------------- /spec/samples/python_code.lua: -------------------------------------------------------------------------------- 1 | from __future__ import braces 2 | 3 | -------------------------------------------------------------------------------- /spec/samples/read_globals.lua: -------------------------------------------------------------------------------- 1 | string = "foo" 2 | table.append = table.insert 3 | _ENV = nil 4 | foo = "4"; print(foo) 5 | bar = "5"; print(bar) 6 | baz[4] = "6"; print(baz) 7 | -------------------------------------------------------------------------------- /spec/samples/read_globals_inline_options.lua: -------------------------------------------------------------------------------- 1 | -- luacheck: read globals foo bar 2 | foo(bar, baz) 3 | foo, bar, baz, baz[1] = false, true, nil, 5 -- luacheck: ignore 111/foo 121/ba. 4 | -- luacheck: globals bar baz 5 | foo, bar, baz = 678, 829, 914 6 | -------------------------------------------------------------------------------- /spec/samples/redefined.lua: -------------------------------------------------------------------------------- 1 | local a = {} 2 | 3 | function a:b(...) 4 | local a, self = 4 5 | 6 | do 7 | local a = (...)(a) 8 | each(a, function() local self = self[5]; return self.bar end) 9 | end 10 | 11 | print(a[1]) 12 | end 13 | 14 | return a 15 | -------------------------------------------------------------------------------- /spec/samples/reversed_fornum.lua: -------------------------------------------------------------------------------- 1 | for i = #(...), -1.5 do 2 | print(i) 3 | end 4 | -------------------------------------------------------------------------------- /spec/samples/sample.rockspec: -------------------------------------------------------------------------------- 1 | build = { 2 | type = "builtin", 3 | modules = { 4 | good = "spec/samples/good_code.lua", 5 | bad = "spec/samples/bad_code.lua", 6 | not_even_a_module = some_global 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /spec/samples/unused_code.lua: -------------------------------------------------------------------------------- 1 | -- Foo is unused- only accessed circularly 2 | local foo = {} 3 | 4 | function foo.bar(baz) 5 | for i=1, 5 do 6 | local q 7 | 8 | for a, b, c in pairs(foo) do 9 | print(4) 10 | end 11 | end 12 | end 13 | 14 | foo[foo] = 1 15 | foo[1] = foo 16 | foo[foo] = foo 17 | foo.meta = function() 18 | return function() print(foo) end 19 | end 20 | 21 | local x = 5 22 | x = 6 23 | x = 7; print(x) 24 | 25 | local y = 5; 26 | (function() print(y) end)() 27 | y = 6 28 | 29 | local z = 5; 30 | (function() z = 4 end)() 31 | z = 6 32 | 33 | -- Function call: RHS of the assignment 3 lines down isn't *only* a circular reference 34 | local t = {} 35 | function t.func() print(t) return {val = 1} end 36 | t[t] = t.func().val + 1 37 | 38 | -- Method call: RHS of the assignment 3 lines down isn't *only* a circular reference 39 | local s = {} 40 | function s:func() print(self) return {val = 1} end 41 | s[s] = s:func().val + 1 42 | 43 | -- False negative: luacheck can't (yet) track more complicated function assignments 44 | local q = {} 45 | local function func() print(q) end 46 | q.func = func 47 | -------------------------------------------------------------------------------- /spec/samples/unused_secondaries.lua: -------------------------------------------------------------------------------- 1 | local function f() end 2 | 3 | local a, b = f() 4 | f(b) 5 | 6 | local x, y, z = f(), f() 7 | f(y) 8 | 9 | local t, o = {} 10 | o = 5 11 | print(o) 12 | o, t[1] = f() 13 | f(t) 14 | -------------------------------------------------------------------------------- /spec/samples/utf8.lua: -------------------------------------------------------------------------------- 1 | -- 嗨,你好嗎? 2 | math["분야 명"] = math["値"] 3 | --[[комментарий]] local t = { 4 | ["päällekkäinen nimi a​b"] = 1, 5 | ["päällekkäinen nimi a​b"] = 2 6 | } 7 | 8 | -- líne an-fhada a choinníonn dul ag dul agus ag dul agus ag dul agus ag dul ach nach bhfuil 120 carachtar ann. Y diwed 9 | -------------------------------------------------------------------------------- /spec/samples/utf8_error.lua: -------------------------------------------------------------------------------- 1 | -- 嗨,你好嗎? 2 | --[[GÆT]] ошибка =( 3 | -------------------------------------------------------------------------------- /spec/serializer_spec.lua: -------------------------------------------------------------------------------- 1 | local serializer = require "luacheck.serializer" 2 | 3 | describe("serializer", function() 4 | describe("dump_result", function() 5 | -- luacheck: no max line length 6 | 7 | it("returns serialized result", function() 8 | assert.same( 9 | [[return {{{"111",5,100,102,"foo",{"faa"}},{"211",4,1,3,"bar",nil,true},{"011",nil,100000,nil,"near '\"'"}},{}}]], 10 | serializer.dump_check_result({ 11 | warnings = { 12 | {code = "111", name = "foo", indexing = {"faa"}, line = 5, column = 100, end_column = 102}, 13 | {code = "211", name = "bar", line = 4, column = 1, end_column = 3, secondary = true}, 14 | {code = "011", column = 100000, msg = "near '\"'"} 15 | }, 16 | inline_options = {} 17 | }) 18 | ) 19 | end) 20 | 21 | it("puts repeating string values into locals", function() 22 | assert.same( 23 | [[local A,B="111","foo";return {{{A,5,100,nil,B},{A,6,100,nil,B},{"011",nil,100000,nil,"near '\"'"}},{},{}}]], 24 | serializer.dump_check_result({ 25 | warnings = { 26 | {code = "111", name = "foo", line = 5, column = 100}, 27 | {code = "111", name = "foo", line = 6, column = 100, secondary = true}, 28 | {code = "011", column = 100000, msg = "near '\"'"} 29 | }, 30 | inline_options = {}, 31 | line_lengths = {} 32 | }) 33 | ) 34 | end) 35 | 36 | it("uses at most 52 locals", function() 37 | local warnings = {} 38 | local expected_parts1 = {"local A"} 39 | local expected_parts2 = {'="111"'} 40 | local expected_parts3 = {";return {{"} 41 | 42 | local function add_char(b) 43 | local c = string.char(b) 44 | table.insert(warnings, {code = "111", name = c}) 45 | table.insert(warnings, {code = "111", name = c}) 46 | table.insert(expected_parts1, "," .. c) 47 | table.insert(expected_parts2, ',"' .. c .. '"') 48 | table.insert(expected_parts3, ('{A,nil,nil,nil,%s},{A,nil,nil,nil,%s},'):format(c, c)) 49 | end 50 | 51 | local function add_extra(name) 52 | table.insert(warnings, {code = "111", name = name}) 53 | table.insert(warnings, {code = "111", name = name}) 54 | table.insert(expected_parts3, ('{A,nil,nil,nil,"%s"},{A,nil,nil,nil,"%s"},'):format(name, name)) 55 | end 56 | 57 | for b = ("B"):byte(), ("Z"):byte() do 58 | add_char(b) 59 | end 60 | 61 | for b = ("a"):byte(), ("z"):byte() do 62 | add_char(b) 63 | end 64 | 65 | add_extra("extra1") 66 | add_extra("extra2") 67 | 68 | local expected_part1 = table.concat(expected_parts1) 69 | local expected_part2 = table.concat(expected_parts2) 70 | local expected_part3 = table.concat(expected_parts3):sub(1, -2) 71 | local expected = expected_part1 .. expected_part2 .. expected_part3 .. "},{},{}}" 72 | 73 | assert.same(expected, 74 | serializer.dump_check_result({ 75 | warnings = warnings, 76 | inline_options = {}, 77 | line_lengths = {} 78 | }) 79 | ) 80 | end) 81 | 82 | it("handles error result", function() 83 | assert.same('return {{{"011",2,4,nil,"message"}},{},{}}', serializer.dump_check_result({ 84 | warnings = { 85 | {code = "011", line = 2, column = 4, msg = "message"} 86 | }, 87 | inline_options = {}, 88 | line_lengths = {} 89 | })) 90 | end) 91 | end) 92 | end) 93 | -------------------------------------------------------------------------------- /spec/unbalanced_assignments_spec.lua: -------------------------------------------------------------------------------- 1 | local helper = require "spec.helper" 2 | 3 | local function assert_warnings(warnings, src) 4 | assert.same(warnings, helper.get_stage_warnings("detect_unbalanced_assignments", src)) 5 | end 6 | 7 | describe("unbalanced assignment detection", function() 8 | it("detects unbalanced assignments", function() 9 | assert_warnings({ 10 | {code = "532", line = 4, column = 1, end_column = 8}, 11 | {code = "531", line = 5, column = 1, end_column = 14} 12 | }, [[ 13 | local a, b = 4; (...)(a) 14 | 15 | a, b = (...)(); (...)(a, b) 16 | a, b = 5; (...)(a, b) 17 | a, b = 1, 2, 3; (...)(a, b) 18 | local c, d 19 | ]]) 20 | end) 21 | 22 | it("detects unbalanced assignments in nested blocks and functions", function() 23 | assert_warnings({ 24 | {code = "532", line = 6, column = 10, end_column = 17}, 25 | {code = "532", line = 9, column = 13, end_column = 20}, 26 | {code = "532", line = 14, column = 22, end_column = 29}, 27 | {code = "531", line = 17, column = 25, end_column = 38} 28 | }, [[ 29 | do 30 | local a, b, c, d 31 | 32 | while x do 33 | if y then 34 | a, b = 1 35 | else 36 | repeat 37 | a, b = 1 38 | 39 | function t() 40 | for i = 1, 10 do 41 | for _, v in ipairs(tab) do 42 | a, b = 1 43 | 44 | if c then 45 | a, b = 1, 2, 3 46 | end 47 | end 48 | end 49 | end 50 | until z 51 | end 52 | end 53 | end 54 | ]]) 55 | end) 56 | end) 57 | -------------------------------------------------------------------------------- /spec/uninit_accesses_spec.lua: -------------------------------------------------------------------------------- 1 | local helper = require "spec.helper" 2 | 3 | local function assert_warnings(warnings, src) 4 | assert.same(warnings, helper.get_stage_warnings("detect_uninit_accesses", src)) 5 | end 6 | 7 | describe("uninitalized access detection", function() 8 | it("detects accessing uninitialized variables", function() 9 | assert_warnings({ 10 | {code = "321", name = "a", line = 6, column = 12, end_column = 12} 11 | }, [[ 12 | local a 13 | 14 | if ... then 15 | a = 5 16 | else 17 | a = get(a) 18 | end 19 | 20 | return a 21 | ]]) 22 | end) 23 | 24 | it("detects accessing uninitialized variables in unreachable functions", function() 25 | assert_warnings({ 26 | {code = "321", name = "a", line = 12, column = 20, end_column = 20} 27 | }, [[ 28 | return function() 29 | return function() 30 | do return end 31 | 32 | return function(x) 33 | local a 34 | 35 | if x then 36 | a = 1 37 | return a + 2 38 | else 39 | return a + 1 40 | end 41 | end 42 | end 43 | end 44 | ]]) 45 | end) 46 | 47 | it("detects mutating uninitialized variables", function() 48 | assert_warnings({ 49 | {code = "341", name = "a", line = 4, column = 4, end_column = 4} 50 | }, [[ 51 | local a 52 | 53 | if ... then 54 | a.k = 5 55 | else 56 | a = get(5) 57 | end 58 | 59 | return a 60 | ]]) 61 | end) 62 | 63 | it("detects accessing uninitialized variables in nested functions", function() 64 | assert_warnings({ 65 | {code = "321", name = "a", line = 7, column = 12, end_column = 12} 66 | }, [[ 67 | return function() return function(...) 68 | local a 69 | 70 | if ... then 71 | a = 5 72 | else 73 | a = get(a) 74 | end 75 | 76 | return a 77 | end end 78 | ]]) 79 | end) 80 | 81 | it("handles accesses with no reaching values", function() 82 | assert_warnings({}, [[ 83 | local var = "foo" 84 | (...)(var) 85 | do return end 86 | (...)(var) 87 | ]]) 88 | end) 89 | 90 | it("handles upvalue accesses with no reaching values", function() 91 | assert_warnings({}, [[ 92 | local var = "foo" 93 | (...)(var) 94 | do return end 95 | (...)(function() 96 | return var 97 | end) 98 | ]]) 99 | end) 100 | 101 | it("handles upvalue accesses with no reaching values in a nested function", function() 102 | assert_warnings({}, [[ 103 | return function(...) 104 | local var = "foo" 105 | (...)(var) 106 | do return end 107 | (...)(function() 108 | return var 109 | end) 110 | end 111 | ]]) 112 | end) 113 | 114 | it("does not detect accessing unitialized variables incorrectly in loops", function() 115 | assert_warnings({}, [[ 116 | local a 117 | 118 | while not a do 119 | a = get() 120 | end 121 | 122 | return a 123 | ]]) 124 | end) 125 | end) 126 | -------------------------------------------------------------------------------- /spec/unreachable_code_spec.lua: -------------------------------------------------------------------------------- 1 | local helper = require "spec.helper" 2 | 3 | local function assert_warnings(warnings, src) 4 | assert.same(warnings, helper.get_stage_warnings("detect_unreachable_code", src)) 5 | end 6 | 7 | describe("unreachable code detection", function() 8 | it("detects unreachable code", function() 9 | assert_warnings({ 10 | {code = "511", line = 2, column = 1, end_column = 24} 11 | }, [[ 12 | do return end 13 | if ... then return 6 end 14 | return 3 15 | ]]) 16 | 17 | assert_warnings({ 18 | {code = "511", line = 7, column = 1, end_column = 11}, 19 | {code = "511", line = 13, column = 1, end_column = 8} 20 | }, [[ 21 | if ... then 22 | return 4 23 | else 24 | return 6 25 | end 26 | 27 | if ... then 28 | return 7 29 | else 30 | return 8 31 | end 32 | 33 | return 3 34 | ]]) 35 | end) 36 | 37 | it("detects unreachable code with literal conditions", function() 38 | assert_warnings({ 39 | {code = "511", line = 4, column = 1, end_column = 6} 40 | }, [[ 41 | while true do 42 | (...)() 43 | end 44 | return 45 | ]]) 46 | 47 | assert_warnings({}, [[ 48 | repeat 49 | if ... then 50 | break 51 | end 52 | until false 53 | return 54 | ]]) 55 | 56 | assert_warnings({ 57 | {code = "511", line = 6, column = 1, end_column = 6} 58 | }, [[ 59 | repeat 60 | if nil then 61 | break 62 | end 63 | until false 64 | return 65 | ]]) 66 | end) 67 | 68 | it("detects unreachable expressions", function() 69 | assert_warnings({ 70 | {code = "511", line = 3, column = 7, end_column = 9} 71 | }, [[ 72 | repeat 73 | return 74 | until ... 75 | ]]) 76 | 77 | assert_warnings({ 78 | {code = "511", line = 3, column = 8, end_column = 10} 79 | }, [[ 80 | if true then 81 | (...)() 82 | elseif ... then 83 | (...)() 84 | end 85 | ]]) 86 | end) 87 | 88 | it("detects unreachable functions", function() 89 | assert_warnings({ 90 | {code = "511", line = 3, column = 1, end_column = 16} 91 | }, [[ 92 | local f = nil 93 | do return end 94 | function f() end 95 | ]]) 96 | end) 97 | 98 | it("detects unreachable code in nested function", function() 99 | assert_warnings({ 100 | {code = "511", line = 4, column = 7, end_column = 12} 101 | }, [[ 102 | return function() 103 | return function() 104 | do return end 105 | return 106 | end 107 | end 108 | ]]) 109 | end) 110 | 111 | it("detects unreachable code in unreachable nested function", function() 112 | assert_warnings({ 113 | {code = "511", line = 4, column = 4, end_column = 20}, 114 | {code = "511", line = 6, column = 7, end_column = 12} 115 | }, [[ 116 | return function() 117 | do return end 118 | 119 | return function() 120 | do return end 121 | return 122 | end 123 | end 124 | ]]) 125 | end) 126 | end) 127 | -------------------------------------------------------------------------------- /spec/unused_fields_spec.lua: -------------------------------------------------------------------------------- 1 | local helper = require "spec.helper" 2 | 3 | local function assert_warnings(warnings, src) 4 | assert.same(warnings, helper.get_stage_warnings("detect_unused_fields", src)) 5 | end 6 | 7 | describe("unused field detection", function() 8 | it("detects unused fields in table literals", function() 9 | assert_warnings({ 10 | {code = "314", field = "key", line = 3, column = 5, end_column = 9, 11 | overwritten_line = 7, overwritten_column = 4, overwritten_end_column = 6}, 12 | {code = "314", field = "2", index = true, line = 6, column = 4, end_column = 4, 13 | overwritten_line = 9, overwritten_column = 5, overwritten_end_column = 9}, 14 | {code = "314", field = "key", line = 7, column = 4, end_column = 6, 15 | overwritten_line = 8, overwritten_column = 4, overwritten_end_column = 6}, 16 | {code = "314", field = "0.2e1", line = 9, column = 5, end_column = 9, 17 | overwritten_line = 10, overwritten_column = 5, overwritten_end_column = 5} 18 | }, [[ 19 | local x, y, z = 1, 2, 3 20 | return { 21 | ["key"] = 4, 22 | [z] = 7, 23 | 1, 24 | y, 25 | key = x, 26 | key = 0, 27 | [0.2e1] = 6, 28 | [2] = 7 29 | } 30 | ]]) 31 | end) 32 | 33 | it("detects unused fields in nested table literals", function() 34 | assert_warnings({ 35 | {code = "314", field = "a", line = 2, column = 5, end_column = 5, 36 | overwritten_line = 2, overwritten_column = 12, overwritten_end_column = 12}, 37 | {code = "314", field = "b", line = 3, column = 11, end_column = 11, 38 | overwritten_line = 3, overwritten_column = 18, overwritten_end_column = 18} 39 | }, [[ 40 | return { 41 | {a = 1, a = 2}, 42 | key = {b = 1, b = 2} 43 | } 44 | ]]) 45 | end) 46 | end) 47 | -------------------------------------------------------------------------------- /src/luacheck/check.lua: -------------------------------------------------------------------------------- 1 | local check_state = require "luacheck.check_state" 2 | local core_utils = require "luacheck.core_utils" 3 | local parse_inline_options = require "luacheck.stages.parse_inline_options" 4 | local parser = require "luacheck.parser" 5 | local stages = require "luacheck.stages" 6 | local utils = require "luacheck.utils" 7 | 8 | local inline_option_fields = utils.array_to_set(parse_inline_options.inline_option_fields) 9 | 10 | local function validate_fields(tables, per_code_fields) 11 | for _, t in ipairs(tables) do 12 | local fields_set 13 | 14 | if per_code_fields then 15 | if not t.code then 16 | error("Warning has no code", 0) 17 | end 18 | 19 | local warning_info = stages.warnings[t.code] 20 | 21 | if not warning_info then 22 | error("Unknown issue code " .. t.code, 0) 23 | end 24 | 25 | fields_set = warning_info.fields_set 26 | else 27 | fields_set = inline_option_fields 28 | end 29 | 30 | for field in pairs(t) do 31 | if not fields_set[field] then 32 | error("Unknown field " .. field .. " in " .. 33 | (per_code_fields and "issue with code " .. t.code or "inline option table"), 0) 34 | end 35 | end 36 | end 37 | end 38 | 39 | --- Checks source. 40 | -- Returns a table with results, with the following fields: 41 | -- `events`: array of issues and inline option events (options, push, or pop). 42 | -- `per_line_options`: map from line numbers to arrays of inline option events. 43 | -- `line_lengths`: map from line numbers to line lengths. 44 | -- `line_endings`: map from line numbers to "comment", "string", or `nil` base on 45 | -- whether the line ending is within a token. 46 | -- If `events` array contains a syntax error, the other fields are empty tables. 47 | local function check(source) 48 | local chstate = check_state.new(source) 49 | local ok, error_wrapper = utils.try(stages.run, chstate) 50 | local warnings, inline_options, line_lengths, line_endings 51 | 52 | if ok then 53 | warnings = chstate.warnings 54 | core_utils.sort_by_location(warnings) 55 | inline_options = chstate.inline_options 56 | line_lengths = chstate.line_lengths 57 | line_endings = chstate.line_endings 58 | else 59 | local err = error_wrapper.err 60 | 61 | if not utils.is_instance(err, parser.SyntaxError) then 62 | error(error_wrapper, 0) 63 | end 64 | 65 | local syntax_error = { 66 | code = "011", 67 | line = err.line, 68 | column = chstate:offset_to_column(err.line, err.offset), 69 | end_column = chstate:offset_to_column(err.line, err.end_offset), 70 | msg = err.msg 71 | } 72 | 73 | if err.prev_line then 74 | syntax_error.prev_line = err.prev_line 75 | syntax_error.prev_column = chstate:offset_to_column(err.prev_line, err.prev_offset) 76 | syntax_error.prev_end_column = chstate:offset_to_column(err.prev_line, err.prev_end_offset) 77 | end 78 | 79 | warnings = {syntax_error} 80 | inline_options = {} 81 | line_lengths = {} 82 | line_endings = {} 83 | end 84 | 85 | validate_fields(warnings, true) 86 | validate_fields(inline_options) 87 | 88 | return { 89 | warnings = warnings, 90 | inline_options = inline_options, 91 | line_lengths = line_lengths, 92 | line_endings = line_endings 93 | } 94 | end 95 | 96 | return check 97 | -------------------------------------------------------------------------------- /src/luacheck/check_state.lua: -------------------------------------------------------------------------------- 1 | local utils = require "luacheck.utils" 2 | 3 | local check_state = {} 4 | 5 | local CheckState = utils.class() 6 | 7 | function CheckState:__init(source_bytes) 8 | self.source_bytes = source_bytes 9 | self.warnings = {} 10 | end 11 | 12 | -- Returns column of a character in a line given its offset. 13 | -- The column is never larger than the line length. 14 | -- This can be called if line length is not yet known. 15 | function CheckState:offset_to_column(line, offset) 16 | local line_length = self.line_lengths[line] 17 | local column = offset - self.line_offsets[line] + 1 18 | 19 | if not line_length then 20 | return column 21 | end 22 | 23 | return math.max(1, math.min(line_length, column)) 24 | end 25 | 26 | function CheckState:warn_column_range(code, range, warning) 27 | warning = warning or {} 28 | warning.code = code 29 | warning.line = range.line 30 | warning.column = range.column 31 | warning.end_column = range.end_column 32 | table.insert(self.warnings, warning) 33 | return warning 34 | end 35 | 36 | function CheckState:warn(code, line, offset, end_offset, warning) 37 | warning = warning or {} 38 | warning.code = code 39 | warning.line = line 40 | warning.column = self:offset_to_column(line, offset) 41 | warning.end_column = self:offset_to_column(line, end_offset) 42 | table.insert(self.warnings, warning) 43 | return warning 44 | end 45 | 46 | function CheckState:warn_range(code, range, warning) 47 | return self:warn(code, range.line, range.offset, range.end_offset, warning) 48 | end 49 | 50 | function CheckState:warn_var(code, var, warning) 51 | warning = self:warn_range(code, var.node, warning) 52 | warning.name = var.name 53 | return warning 54 | end 55 | 56 | function CheckState:warn_value(code, value, warning) 57 | warning = self:warn_range(code, value.var_node, warning) 58 | warning.name = value.var.name 59 | return warning 60 | end 61 | 62 | function check_state.new(source_bytes) 63 | return CheckState(source_bytes) 64 | end 65 | 66 | return check_state 67 | -------------------------------------------------------------------------------- /src/luacheck/core_utils.lua: -------------------------------------------------------------------------------- 1 | local decoder = require "luacheck.decoder" 2 | local utils = require "luacheck.utils" 3 | 4 | local core_utils = {} 5 | 6 | -- Attempts to evaluate a node as a Lua value, without resolving locals. 7 | -- Returns Lua value and its string representation on success, nothing on failure. 8 | function core_utils.eval_const_node(node) 9 | if node.tag == "True" then 10 | return true, "true" 11 | elseif node.tag == "False" then 12 | return false, "false" 13 | elseif node.tag == "String" then 14 | local chars = decoder.decode(node[1]) 15 | return node[1], chars:get_printable_substring(1, chars:get_length()) 16 | else 17 | local is_negative 18 | 19 | if node.tag == "Op" and node[1] == "unm" then 20 | is_negative = true 21 | node = node[2] 22 | end 23 | 24 | if node.tag ~= "Number" then 25 | return 26 | end 27 | 28 | local str = node[1] 29 | 30 | if str:find("[iIuUlL]") then 31 | -- Ignore LuaJIT cdata literals. 32 | return 33 | end 34 | 35 | -- On Lua 5.3+ convert to float to get same results as on Lua 5.1 and 5.2. 36 | if (_VERSION == "Lua 5.3" or _VERSION == "Lua 5.4") and not str:find("[%.eEpP]") then 37 | str = str .. ".0" 38 | end 39 | 40 | local number = tonumber(str) 41 | 42 | if not number then 43 | return 44 | end 45 | 46 | if is_negative then 47 | number = -number 48 | end 49 | 50 | if number == number and number < 1/0 and number > -1/0 then 51 | return number, (is_negative and "-" or "") .. node[1] 52 | end 53 | end 54 | end 55 | 56 | local statement_containing_tags = utils.array_to_set({"Do", "While", "Repeat", "Fornum", "Forin", "If"}) 57 | 58 | -- `items` is an array of nodes or nested item arrays. 59 | local function scan_for_statements(chstate, items, tags, callback, ...) 60 | for _, item in ipairs(items) do 61 | if tags[item.tag] then 62 | callback(chstate, item, ...) 63 | end 64 | 65 | if not item.tag or statement_containing_tags[item.tag] then 66 | scan_for_statements(chstate, item, tags, callback, ...) 67 | end 68 | end 69 | end 70 | 71 | -- Calls `callback(chstate, node, ...)` for each statement node within AST with tag in given array. 72 | function core_utils.each_statement(chstate, tags_array, callback, ...) 73 | local tags = utils.array_to_set(tags_array) 74 | 75 | for _, line in ipairs(chstate.lines) do 76 | scan_for_statements(chstate, line.node[2], tags, callback, ...) 77 | end 78 | end 79 | 80 | local function location_comparator(warning1, warning2) 81 | if warning1.line ~= warning2.line then 82 | return warning1.line < warning2.line 83 | elseif warning1.column ~= warning2.column then 84 | return warning1.column < warning2.column 85 | else 86 | return warning1.code < warning2.code 87 | end 88 | end 89 | 90 | -- Sorts an array of warnings by location information as provided in `line` and `column` fields. 91 | function core_utils.sort_by_location(warnings) 92 | table.sort(warnings, location_comparator) 93 | end 94 | 95 | return core_utils 96 | -------------------------------------------------------------------------------- /src/luacheck/expand_rockspec.lua: -------------------------------------------------------------------------------- 1 | local fs = require "luacheck.fs" 2 | local utils = require "luacheck.utils" 3 | 4 | local blacklist = utils.array_to_set({"spec", ".luarocks", "lua_modules", "test.lua", "tests.lua"}) 5 | 6 | -- This reimplements relevant parts of `luarocks.build.builtin.autodetect_modules`. 7 | -- Autodetection works relatively to the directory containing the rockspec. 8 | local function autodetect_modules(rockspec_path) 9 | rockspec_path = fs.normalize(rockspec_path) 10 | local base, rest = fs.split_base(rockspec_path) 11 | local project_dir = base .. (rest:match("^(.*)" .. utils.dir_sep .. ".*$") or "") 12 | 13 | if project_dir == "" then 14 | project_dir = "." 15 | end 16 | 17 | local module_dir = project_dir 18 | 19 | for _, module_subdir in ipairs({"src", "lua", "lib"}) do 20 | local full_module_dir = fs.join(project_dir, module_subdir) 21 | 22 | if fs.is_dir(full_module_dir) then 23 | module_dir = full_module_dir 24 | break 25 | end 26 | end 27 | 28 | local res = {} 29 | 30 | for _, file in ipairs((fs.extract_files(module_dir, "%.lua$"))) do 31 | -- Extract first part of the path from module_dir to the file, or file name itself. 32 | if not blacklist[file:match("^" .. module_dir:gsub("%p", "%%%0") .. "[\\/]*([^\\/]*)")] then 33 | table.insert(res, file) 34 | end 35 | end 36 | 37 | local bin_dir 38 | 39 | for _, bin_subdir in ipairs({"src/bin", "bin"}) do 40 | local full_bin_dir = fs.join(project_dir, bin_subdir) 41 | 42 | if fs.is_dir(full_bin_dir) then 43 | bin_dir = full_bin_dir 44 | end 45 | end 46 | 47 | if bin_dir then 48 | local iter, state, var = fs.dir_iter(bin_dir) 49 | 50 | if iter then 51 | for basename in iter, state, var do 52 | if basename:sub(-#".lua") == ".lua" then 53 | table.insert(res, fs.join(bin_dir, basename)) 54 | end 55 | end 56 | end 57 | end 58 | 59 | return res 60 | end 61 | 62 | local function extract_lua_files(rockspec_path, rockspec) 63 | local build = rockspec.build 64 | 65 | if type(build) ~= "table" then 66 | return autodetect_modules(rockspec_path) 67 | end 68 | 69 | if not build.type or build.type == "builtin" or build.type == "module" then 70 | if not build.modules then 71 | return autodetect_modules(rockspec_path) 72 | end 73 | end 74 | 75 | local res = {} 76 | 77 | local function scan(t) 78 | if type(t) == "table" then 79 | for _, file in pairs(t) do 80 | if type(file) == "string" and file:sub(-#".lua") == ".lua" then 81 | table.insert(res, file) 82 | end 83 | end 84 | end 85 | end 86 | 87 | scan(build.modules) 88 | 89 | if type(build.install) == "table" then 90 | scan(build.install.lua) 91 | scan(build.install.bin) 92 | end 93 | 94 | table.sort(res) 95 | return res 96 | end 97 | 98 | -- Receives a name of a rockspec, returns list of related .lua files. 99 | -- On error returns nil and "I/O", "syntax", or "runtime" and error message. 100 | local function expand_rockspec(rockspec_path) 101 | local rockspec, err_type, err_msg = utils.load_config(rockspec_path) 102 | 103 | if not rockspec then 104 | return nil, err_type, err_msg 105 | end 106 | 107 | return extract_lua_files(rockspec_path, rockspec) 108 | end 109 | 110 | return expand_rockspec 111 | -------------------------------------------------------------------------------- /src/luacheck/multithreading.lua: -------------------------------------------------------------------------------- 1 | local utils = require "luacheck.utils" 2 | 3 | local multithreading = {} 4 | 5 | local lanes_ok, lanes = pcall(require, "lanes") 6 | lanes_ok = lanes_ok and pcall(lanes.configure) 7 | multithreading.has_lanes = lanes_ok 8 | multithreading.lanes = lanes 9 | multithreading.default_jobs = 1 10 | 11 | if not lanes_ok then 12 | return multithreading 13 | end 14 | 15 | local cpu_number_detection_commands = {} 16 | 17 | if utils.is_windows then 18 | cpu_number_detection_commands[1] = "echo %NUMBER_OF_PROCESSORS%" 19 | else 20 | cpu_number_detection_commands[1] = "getconf _NPROCESSORS_ONLN 2>&1" 21 | cpu_number_detection_commands[2] = "sysctl -n hw.ncpu 2>&1" 22 | cpu_number_detection_commands[3] = "psrinfo -p 2>&1" 23 | end 24 | 25 | for _, command in ipairs(cpu_number_detection_commands) do 26 | local handler = io.popen(command) 27 | 28 | if handler then 29 | local output = handler:read("*a") 30 | handler:close() 31 | 32 | if output then 33 | local cpu_number = tonumber(utils.strip(output)) 34 | 35 | if cpu_number then 36 | multithreading.default_jobs = math.floor(math.max(cpu_number, 1)) 37 | break 38 | end 39 | end 40 | end 41 | end 42 | 43 | -- Reads pairs {key, arg} from given linda slot until it gets nil as arg. 44 | -- Returns table with pairs [key] = func(arg). 45 | local function worker_task(linda, input_slot, func) 46 | local results = {} 47 | 48 | while true do 49 | local _, pair = linda:receive(nil, input_slot) 50 | local key, arg = pair[1], pair[2] 51 | 52 | if arg == nil then 53 | return results 54 | end 55 | 56 | results[key] = func(arg) 57 | end 58 | end 59 | 60 | local function protected_worker_task(...) 61 | return true, utils.try(worker_task, ...) 62 | end 63 | 64 | local worker_gen = lanes.gen("*", protected_worker_task) 65 | 66 | -- Maps func over array, performing at most jobs calls in parallel. 67 | function multithreading.pmap(func, array, jobs) 68 | jobs = jobs or multithreading.default_jobs 69 | jobs = math.min(jobs, #array) 70 | 71 | if jobs < 2 then 72 | return utils.map(func, array) 73 | end 74 | 75 | local workers = {} 76 | local linda = lanes.linda() 77 | 78 | for i = 1, jobs do 79 | workers[i] = worker_gen(linda, 0, func) 80 | end 81 | 82 | for i, item in ipairs(array) do 83 | linda:send(nil, 0, {i, item}) 84 | end 85 | 86 | for _ = 1, jobs do 87 | linda:send(nil, 0, {}) 88 | end 89 | 90 | local results = {} 91 | 92 | for _, worker in ipairs(workers) do 93 | local _, ok, worker_results = assert(worker:join()) 94 | 95 | if ok then 96 | utils.update(results, worker_results) 97 | else 98 | error(worker_results, 0) 99 | end 100 | end 101 | 102 | return results 103 | end 104 | 105 | return multithreading 106 | -------------------------------------------------------------------------------- /src/luacheck/stages/detect_bad_whitespace.lua: -------------------------------------------------------------------------------- 1 | local stage = {} 2 | 3 | stage.warnings = { 4 | ["611"] = {message_format = "line contains only whitespace", fields = {}}, 5 | ["612"] = {message_format = "line contains trailing whitespace", fields = {}}, 6 | ["613"] = {message_format = "trailing whitespace in a string", fields = {}}, 7 | ["614"] = {message_format = "trailing whitespace in a comment", fields = {}}, 8 | ["621"] = {message_format = "inconsistent indentation (SPACE followed by TAB)", fields = {}} 9 | } 10 | 11 | function stage.run(chstate) 12 | local num_lines = #chstate.line_offsets 13 | 14 | for line_number = 1, num_lines do 15 | local line_offset = chstate.line_offsets[line_number] 16 | local line_length = chstate.line_lengths[line_number] 17 | 18 | if line_length > 0 then 19 | local trailing_ws_pattern 20 | 21 | if line_number == num_lines then 22 | trailing_ws_pattern = "^[^\r\n]-()[ \t\f\v]+()[\r\n]?$" 23 | else 24 | trailing_ws_pattern = "^[^\r\n]-()[ \t\f\v]+()[\r\n]" 25 | end 26 | 27 | local line_start_byte, _, trailing_ws_start_byte, line_end_byte = chstate.source:find( 28 | trailing_ws_pattern, line_offset) 29 | 30 | local trailing_ws_code 31 | 32 | if trailing_ws_start_byte then 33 | 34 | if trailing_ws_start_byte == line_start_byte then 35 | -- Line contains only whitespace (thus never considered "code"). 36 | trailing_ws_code = "611" 37 | elseif not chstate.line_endings[line_number] then 38 | -- Trailing whitespace on code line or after long comment. 39 | trailing_ws_code = "612" 40 | elseif chstate.line_endings[line_number] == "string" then 41 | -- Trailing whitespace embedded in a string literal. 42 | trailing_ws_code = "613" 43 | elseif chstate.line_endings[line_number] == "comment" then 44 | -- Trailing whitespace at the end of a line comment or inside long comment. 45 | trailing_ws_code = "614" 46 | end 47 | 48 | -- The difference between the start and the end of the warning range 49 | -- is the same in bytes and in characters because whitespace characters are ASCII. 50 | -- Can calculate one based on the three others. 51 | local trailing_ws_end_byte = line_end_byte - 1 52 | local trailing_ws_end_char = line_offset + line_length - 1 53 | local trailing_ws_start_char = trailing_ws_end_char - (trailing_ws_end_byte - trailing_ws_start_byte) 54 | 55 | chstate:warn(trailing_ws_code, line_number, trailing_ws_start_char, trailing_ws_end_char) 56 | end 57 | 58 | -- Don't look for inconsistent whitespace in pure whitespace lines. 59 | if trailing_ws_code ~= "611" then 60 | local leading_ws_start_byte, leading_ws_end_byte = chstate.source:find( 61 | "^[ \t\f\v]- \t[ \t\f\v]*", line_offset) 62 | 63 | if leading_ws_start_byte then 64 | -- Inconsistent leading whitespace (SPACE followed by TAB). 65 | 66 | -- Calculate warning end in characters using same logic as above. 67 | local leading_ws_start_char = line_offset 68 | local leading_ws_end_char = leading_ws_start_char + (leading_ws_end_byte - leading_ws_start_byte) 69 | chstate:warn("621", line_number, line_offset, leading_ws_end_char) 70 | end 71 | end 72 | end 73 | end 74 | end 75 | 76 | return stage 77 | -------------------------------------------------------------------------------- /src/luacheck/stages/detect_compound_operators.lua: -------------------------------------------------------------------------------- 1 | local core_utils = require "luacheck.core_utils" 2 | 3 | local stage = {} 4 | 5 | stage.warnings = { 6 | ["033"] = {message_format = "assignment uses compound operator {operator}", fields = {"operator"}}, 7 | } 8 | 9 | local reverse_compound_operators = { 10 | add = "+=", 11 | sub = "-=", 12 | mul = "*=", 13 | mod = "%=", 14 | pow = "^=", 15 | div = "/=", 16 | idiv = "//=", 17 | band = "&=", 18 | bor = "|=", 19 | bxor = "~=", 20 | shl = "<<=", 21 | shr = ">>=", 22 | concat = "..=" 23 | } 24 | 25 | local function check_node(chstate, node) 26 | local operator = reverse_compound_operators[node[3]] 27 | chstate:warn_range("033", node, {operator = operator}) 28 | end 29 | 30 | function stage.run(chstate) 31 | core_utils.each_statement(chstate, { "OpSet" }, check_node) 32 | end 33 | 34 | return stage 35 | -------------------------------------------------------------------------------- /src/luacheck/stages/detect_empty_blocks.lua: -------------------------------------------------------------------------------- 1 | local core_utils = require "luacheck.core_utils" 2 | 3 | local stage = {} 4 | 5 | stage.warnings = { 6 | ["541"] = {message_format = "empty do..end block", fields = {}}, 7 | ["542"] = {message_format = "empty if branch", fields = {}} 8 | } 9 | 10 | local function check_block(chstate, block, code) 11 | if #block == 0 then 12 | chstate:warn_range(code, block) 13 | end 14 | end 15 | 16 | 17 | local function check_node(chstate, node) 18 | if node.tag == "Do" then 19 | check_block(chstate, node, "541") 20 | return 21 | end 22 | 23 | for index = 2, #node, 2 do 24 | check_block(chstate, node[index], "542") 25 | end 26 | 27 | if #node % 2 == 1 then 28 | check_block(chstate, node[#node], "542") 29 | end 30 | end 31 | 32 | function stage.run(chstate) 33 | core_utils.each_statement(chstate, {"Do", "If"}, check_node) 34 | end 35 | 36 | return stage 37 | -------------------------------------------------------------------------------- /src/luacheck/stages/detect_empty_statements.lua: -------------------------------------------------------------------------------- 1 | local stage = {} 2 | 3 | stage.warnings = { 4 | ["551"] = {message_format = "empty statement", fields = {}} 5 | } 6 | 7 | function stage.run(chstate) 8 | for _, range in ipairs(chstate.useless_semicolons) do 9 | chstate:warn_range("551", range) 10 | end 11 | end 12 | 13 | return stage 14 | -------------------------------------------------------------------------------- /src/luacheck/stages/detect_reversed_fornum_loops.lua: -------------------------------------------------------------------------------- 1 | local core_utils = require "luacheck.core_utils" 2 | 3 | local stage = {} 4 | 5 | stage.warnings = { 6 | ["571"] = {message_format = "numeric for loop goes from #(expr) down to {limit} but loop step is not negative", 7 | fields = {"limit"}} 8 | } 9 | 10 | local function check_fornum(chstate, node) 11 | if node[2].tag ~= "Op" or node[2][1] ~= "len" then 12 | return 13 | end 14 | 15 | local limit, limit_repr = core_utils.eval_const_node(node[3]) 16 | 17 | if not limit or limit > 1 then 18 | return 19 | end 20 | 21 | local step = 1 22 | 23 | if node[5] then 24 | step = core_utils.eval_const_node(node[4]) 25 | end 26 | 27 | if step and step >= 0 then 28 | chstate:warn_range("571", node, { 29 | limit = limit_repr 30 | }) 31 | end 32 | end 33 | 34 | -- Warns about loops trying to go from `#(expr)` to `1` with positive step. 35 | function stage.run(chstate) 36 | core_utils.each_statement(chstate, {"Fornum"}, check_fornum) 37 | end 38 | 39 | return stage 40 | -------------------------------------------------------------------------------- /src/luacheck/stages/detect_unbalanced_assignments.lua: -------------------------------------------------------------------------------- 1 | local core_utils = require "luacheck.core_utils" 2 | 3 | local stage = {} 4 | 5 | stage.warnings = { 6 | ["531"] = {message_format = "right side of assignment has more values than left side expects", fields = {}}, 7 | ["532"] = {message_format = "right side of assignment has less values than left side expects", fields = {}} 8 | } 9 | 10 | local function is_unpacking(node) 11 | return node.tag == "Dots" or node.tag == "Call" or node.tag == "Invoke" 12 | end 13 | 14 | local function check_assignment(chstate, node) 15 | local rhs = node[2] 16 | 17 | if not rhs then 18 | return 19 | end 20 | 21 | local lhs = node[1] 22 | 23 | if #rhs > #lhs then 24 | chstate:warn_range("531", node) 25 | elseif #rhs < #lhs and node.tag == "Set" and not is_unpacking(rhs[#rhs]) then 26 | chstate:warn_range("532", node) 27 | end 28 | end 29 | 30 | function stage.run(chstate) 31 | core_utils.each_statement(chstate, {"Set", "Local"}, check_assignment) 32 | end 33 | 34 | return stage 35 | -------------------------------------------------------------------------------- /src/luacheck/stages/detect_uninit_accesses.lua: -------------------------------------------------------------------------------- 1 | local stage = {} 2 | 3 | stage.warnings = { 4 | ["321"] = {message_format = "accessing uninitialized variable {name!}", fields = {"name"}}, 5 | ["341"] = {message_format = "mutating uninitialized variable {name!}", fields = {"name"}} 6 | } 7 | 8 | local function detect_uninit_access_in_line(chstate, line) 9 | for _, item in ipairs(line.items) do 10 | for _, action_key in ipairs({"accesses", "mutations"}) do 11 | local code = action_key == "accesses" and "321" or "341" 12 | local item_var_map = item[action_key] 13 | 14 | if item_var_map then 15 | for var, accessing_nodes in pairs(item_var_map) do 16 | -- If there are no values at all reaching this access, not even the empty one, 17 | -- this item (or a closure containing it) is not reachable from variable definition. 18 | -- It will be reported as unreachable code, no need to report uninitialized accesses in it. 19 | if item.used_values[var] then 20 | -- If this variable is has only one, empty value then it's already reported as never set, 21 | -- no need to report each access. 22 | if not (#var.values == 1 and var.values[1].empty) then 23 | local all_possible_values_empty = true 24 | 25 | for _, possible_value in ipairs(item.used_values[var]) do 26 | if not possible_value.empty then 27 | all_possible_values_empty = false 28 | break 29 | end 30 | end 31 | 32 | if all_possible_values_empty then 33 | for _, accessing_node in ipairs(accessing_nodes) do 34 | chstate:warn_range(code, accessing_node, { 35 | name = accessing_node[1] 36 | }) 37 | end 38 | end 39 | end 40 | end 41 | end 42 | end 43 | end 44 | end 45 | end 46 | 47 | -- Warns about accesses and mutations that don't resolve to any values except initial empty one. 48 | function stage.run(chstate) 49 | for _, line in ipairs(chstate.lines) do 50 | detect_uninit_access_in_line(chstate, line) 51 | end 52 | end 53 | 54 | return stage 55 | -------------------------------------------------------------------------------- /src/luacheck/stages/detect_unreachable_code.lua: -------------------------------------------------------------------------------- 1 | local stage = {} 2 | 3 | stage.warnings = { 4 | ["511"] = {message_format = "unreachable code", fields = {}}, 5 | ["512"] = {message_format = "loop is executed at most once", fields = {}} 6 | } 7 | 8 | local function noop_callback() end 9 | 10 | local function detect_unreachable_code(chstate, line) 11 | local reachable_indexes = {} 12 | 13 | -- Mark all items reachable from the function start. 14 | line:walk(reachable_indexes, 1, noop_callback) 15 | 16 | -- All remaining items are unreachable. 17 | -- However, there is no point in reporting all of them. 18 | -- Only report those that are not reachable from any already reported ones. 19 | for item_index, item in ipairs(line.items) do 20 | if not reachable_indexes[item_index] then 21 | if item.node then 22 | chstate:warn_range(item.loop_end and "512" or "511", item.node) 23 | -- Mark all items reachable from the item just reported. 24 | line:walk(reachable_indexes, item_index, noop_callback) 25 | end 26 | end 27 | end 28 | end 29 | 30 | function stage.run(chstate) 31 | for _, line in ipairs(chstate.lines) do 32 | detect_unreachable_code(chstate, line) 33 | end 34 | end 35 | 36 | return stage 37 | -------------------------------------------------------------------------------- /src/luacheck/stages/detect_unused_fields.lua: -------------------------------------------------------------------------------- 1 | local core_utils = require "luacheck.core_utils" 2 | 3 | local stage = {} 4 | 5 | local function unused_field_value_message_format(warning) 6 | local target = warning.index and "index" or "field" 7 | return "value assigned to " .. target .. " {field!} is overwritten on line {overwritten_line} before use" 8 | end 9 | 10 | stage.warnings = { 11 | ["314"] = {message_format = unused_field_value_message_format, 12 | fields = {"field", "index", "overwritten_line","overwritten_column", "overwritten_end_column"}} 13 | } 14 | 15 | local function warn_unused_field_value(chstate, node, field_repr, is_index, overwriting_node) 16 | chstate:warn_range("314", node, { 17 | field = field_repr, 18 | index = is_index, 19 | overwritten_line = overwriting_node.line, 20 | overwritten_column = chstate:offset_to_column(overwriting_node.line, overwriting_node.offset), 21 | overwritten_end_column = chstate:offset_to_column(overwriting_node.line, overwriting_node.end_offset) 22 | }) 23 | end 24 | 25 | local function check_table(chstate, node) 26 | local array_index = 1.0 27 | local key_value_to_node = {} 28 | local key_node_to_repr = {} 29 | local index_key_nodes = {} 30 | 31 | for _, pair in ipairs(node) do 32 | local key_value 33 | local key_repr 34 | local key_node 35 | 36 | if pair.tag == "Pair" then 37 | key_node = pair[1] 38 | key_value, key_repr = core_utils.eval_const_node(key_node) 39 | else 40 | key_node = pair 41 | key_value = array_index 42 | key_repr = tostring(math.floor(key_value)) 43 | array_index = array_index + 1.0 44 | end 45 | 46 | if key_value then 47 | local prev_key_node = key_value_to_node[key_value] 48 | local prev_key_repr = key_node_to_repr[prev_key_node] 49 | local prev_key_is_index = index_key_nodes[prev_key_node] 50 | 51 | if prev_key_node then 52 | warn_unused_field_value(chstate, prev_key_node, prev_key_repr, prev_key_is_index, key_node) 53 | end 54 | 55 | key_value_to_node[key_value] = key_node 56 | key_node_to_repr[key_node] = key_repr 57 | 58 | if pair.tag ~= "Pair" then 59 | index_key_nodes[key_node] = true 60 | end 61 | end 62 | end 63 | end 64 | 65 | local function check_nodes(chstate, nodes) 66 | for _, node in ipairs(nodes) do 67 | if type(node) == "table" then 68 | if node.tag == "Table" then 69 | check_table(chstate, node) 70 | end 71 | 72 | check_nodes(chstate, node) 73 | end 74 | end 75 | end 76 | 77 | function stage.run(chstate) 78 | check_nodes(chstate, chstate.ast) 79 | end 80 | 81 | return stage 82 | -------------------------------------------------------------------------------- /src/luacheck/stages/init.lua: -------------------------------------------------------------------------------- 1 | local utils = require "luacheck.utils" 2 | 3 | local stages = {} 4 | 5 | -- Checking is organized into stages run one after another. 6 | -- Each stage is in its own module and provides `run` function operating on a check state, 7 | -- and optionally `warnings` table mapping issue codes to tables with fields `message_format` 8 | -- containing format string for the issue or a function returning it given the issue, 9 | -- and `fields` containing array of extra fields this warning can have. 10 | 11 | stages.names = { 12 | "parse", 13 | "unwrap_parens", 14 | "linearize", 15 | "parse_inline_options", 16 | "name_functions", 17 | "resolve_locals", 18 | "detect_bad_whitespace", 19 | "detect_compound_operators", 20 | "detect_cyclomatic_complexity", 21 | "detect_empty_blocks", 22 | "detect_empty_statements", 23 | "detect_globals", 24 | "detect_reversed_fornum_loops", 25 | "detect_unbalanced_assignments", 26 | "detect_uninit_accesses", 27 | "detect_unreachable_code", 28 | "detect_unused_fields", 29 | "detect_unused_locals" 30 | } 31 | 32 | stages.modules = {} 33 | 34 | for _, name in ipairs(stages.names) do 35 | table.insert(stages.modules, (require("luacheck.stages." .. name))) 36 | end 37 | 38 | stages.warnings = {} 39 | 40 | local base_fields = {"code", "line", "column", "end_column"} 41 | 42 | local function register_warnings(warnings) 43 | for code, warning in pairs(warnings) do 44 | assert(not stages.warnings[code]) 45 | assert(warning.message_format) 46 | assert(warning.fields) 47 | 48 | local full_fields = utils.concat_arrays({base_fields, warning.fields}) 49 | 50 | stages.warnings[code] = { 51 | message_format = warning.message_format, 52 | fields = full_fields, 53 | fields_set = utils.array_to_set(full_fields) 54 | } 55 | end 56 | end 57 | 58 | -- Issues that do not originate from normal check stages (excluding global related ones). 59 | register_warnings({ 60 | ["011"] = {message_format = "{msg}", fields = {"msg", "prev_line", "prev_column", "prev_end_column"}}, 61 | ["631"] = {message_format = "line is too long ({end_column} > {max_length})", fields = {}} 62 | }) 63 | 64 | for _, stage_module in ipairs(stages.modules) do 65 | if stage_module.warnings then 66 | register_warnings(stage_module.warnings) 67 | end 68 | end 69 | 70 | function stages.run(chstate) 71 | for _, stage_module in ipairs(stages.modules) do 72 | stage_module.run(chstate) 73 | end 74 | end 75 | 76 | return stages 77 | -------------------------------------------------------------------------------- /src/luacheck/stages/name_functions.lua: -------------------------------------------------------------------------------- 1 | local stage = {} 2 | 3 | local function get_index_name(base_name, key_node) 4 | if key_node.tag == "String" then 5 | return base_name .. "." .. key_node[1] 6 | end 7 | end 8 | 9 | local function get_full_field_name(node) 10 | if node.tag == "Id" then 11 | return node[1] 12 | elseif node.tag == "Index" then 13 | local base_name = get_full_field_name(node[1]) 14 | return base_name and get_index_name(base_name, node[2]) 15 | end 16 | end 17 | 18 | local handle_node 19 | 20 | local function handle_nodes(nodes) 21 | for _, node in ipairs(nodes) do 22 | if type(node) == "table" then 23 | handle_node(node) 24 | end 25 | end 26 | end 27 | 28 | function handle_node(node, name) 29 | if node.tag == "Function" then 30 | node.name = name 31 | handle_nodes(node[2]) 32 | elseif node.tag == "Set" or node.tag == "Local" or node.tag == "Localrec" then 33 | local lhs = node[1] 34 | local rhs = node[2] 35 | 36 | -- No need to handle LHS if there is no RHS, it's always just a list of locals in that case. 37 | if rhs then 38 | handle_nodes(lhs) 39 | 40 | for index, rhs_node in ipairs(rhs) do 41 | local lhs_node = lhs[index] 42 | local field_name = lhs_node and get_full_field_name(lhs_node) 43 | handle_node(rhs_node, field_name) 44 | end 45 | end 46 | elseif node.tag == "Table" and name then 47 | for _, pair_node in ipairs(node) do 48 | if pair_node.tag == "Pair" then 49 | local key_node = pair_node[1] 50 | local value_node = pair_node[2] 51 | handle_node(key_node) 52 | handle_node(value_node, get_index_name(name, key_node)) 53 | else 54 | handle_node(pair_node) 55 | end 56 | end 57 | else 58 | handle_nodes(node) 59 | end 60 | end 61 | 62 | -- Adds `name` field to `Function` ast nodes when possible: 63 | -- * Function assigned to a variable (doesn't matter if local or global): "foo". 64 | -- * Function assigned to a field: "foo.bar.baz". 65 | -- Function can be in a table assigned to a variable or a field, e.g. `foo.bar = {baz = function() ... end}`. 66 | -- * Otherwise: `nil`. 67 | function stage.run(chstate) 68 | handle_nodes(chstate.ast) 69 | end 70 | 71 | return stage 72 | -------------------------------------------------------------------------------- /src/luacheck/stages/parse.lua: -------------------------------------------------------------------------------- 1 | local decoder = require "luacheck.decoder" 2 | local parser = require "luacheck.parser" 3 | 4 | local stage = {} 5 | 6 | function stage.run(chstate) 7 | chstate.source = decoder.decode(chstate.source_bytes) 8 | chstate.line_offsets = {} 9 | chstate.line_lengths = {} 10 | local ast, comments, code_lines, line_endings, useless_semicolons = parser.parse( 11 | chstate.source, chstate.line_offsets, chstate.line_lengths) 12 | chstate.ast = ast 13 | chstate.comments = comments 14 | chstate.code_lines = code_lines 15 | chstate.line_endings = line_endings 16 | chstate.useless_semicolons = useless_semicolons 17 | end 18 | 19 | return stage 20 | -------------------------------------------------------------------------------- /src/luacheck/stages/unwrap_parens.lua: -------------------------------------------------------------------------------- 1 | local stage = {} 2 | 3 | stage.warnings = { 4 | ["581"] = { 5 | message_format = "'not (x {operator} y)' can be replaced by 'x {replacement_operator} y'" 6 | .. " (if neither side is a table or NaN)", 7 | fields = {"operator", "replacement_operator"} 8 | }, 9 | ["582"] = {message_format = "Error prone negation: negation is executed before relational operator.", fields = {}} 10 | } 11 | 12 | local relational_operators = { 13 | ne = "~=", 14 | eq = "==", 15 | gt = ">", 16 | ge = ">=", 17 | lt = "<", 18 | le = "<=", 19 | } 20 | local replacements = { 21 | ne = "==", 22 | eq = "~=", 23 | gt = "<=", 24 | ge = "<", 25 | lt = ">=", 26 | le = ">", 27 | } 28 | 29 | -- Mutates an array of nodes and non-tables, unwrapping Paren nodes. 30 | -- If list_start is given, tail Paren is not unwrapped if it's unpacking and past list_start index. 31 | local function handle_nodes(chstate, nodes, list_start) 32 | local num_nodes = #nodes 33 | 34 | for index = 1, num_nodes do 35 | local node = nodes[index] 36 | 37 | if type(node) == "table" then 38 | local tag = node.tag 39 | 40 | if tag == "Table" or tag == "Return" then 41 | handle_nodes(chstate, node, 1) 42 | elseif tag == "Call" then 43 | handle_nodes(chstate, node, 2) 44 | elseif tag == "Invoke" then 45 | handle_nodes(chstate, node, 3) 46 | elseif tag == "Forin" then 47 | handle_nodes(chstate, node[2], 1) 48 | handle_nodes(chstate, node[3]) 49 | elseif tag == "Local" then 50 | if node[2] then 51 | handle_nodes(chstate, node[2]) 52 | end 53 | elseif tag == "Set" or tag == "OpSet" then 54 | handle_nodes(chstate, node[1]) 55 | handle_nodes(chstate, node[2], 1) 56 | else 57 | -- warn that not x y means (not x) y 58 | if tag == "Op" 59 | and relational_operators[node[1]] 60 | and node[2].tag == "Op" 61 | and node[2][1] == "not" 62 | then 63 | chstate:warn_range("582", node) 64 | end 65 | 66 | handle_nodes(chstate, node) 67 | 68 | -- warn that not (x == y) can become x ~= y 69 | if tag == "Op" and node[1] == "not" and node[2].tag == "Op" and relational_operators[node[2][1]] then 70 | chstate:warn_range("581", node, { 71 | operator = relational_operators[node[2][1]], 72 | replacement_operator = replacements[node[2][1]] 73 | }) 74 | end 75 | 76 | if tag == "Paren" and (not list_start or index < list_start or index ~= num_nodes) then 77 | local inner_node = node[1] 78 | 79 | if inner_node.tag ~= "Call" and inner_node.tag ~= "Invoke" and inner_node.tag ~= "Dots" then 80 | nodes[index] = inner_node 81 | end 82 | end 83 | end 84 | end 85 | end 86 | end 87 | 88 | -- Mutates AST, unwrapping Paren nodes. 89 | -- Paren nodes are preserved only when they matter: 90 | -- at the ends of expression lists with potentially multi-value inner expressions. 91 | function stage.run(chstate) 92 | handle_nodes(chstate, chstate.ast) 93 | end 94 | 95 | return stage 96 | -------------------------------------------------------------------------------- /src/luacheck/unicode.lua: -------------------------------------------------------------------------------- 1 | local unicode_printability_boundaries = require "luacheck.unicode_printability_boundaries" 2 | 3 | local unicode = {} 4 | 5 | -- unicode_printability_boundaries is an array of first codepoints of 6 | -- each continuous block of codepoints that are all printable or all not printable. 7 | 8 | function unicode.is_printable(codepoint) 9 | -- Binary search for index of the first boundary less than or equal to given codepoint. 10 | local floor_boundary_index 11 | 12 | -- Target index is always in [begin_index..end_index). 13 | local begin_index = 1 14 | local end_index = #unicode_printability_boundaries + 1 15 | 16 | while end_index - begin_index > 1 do 17 | local mid_index = math.floor((begin_index + end_index) / 2) 18 | local mid_codepoint = unicode_printability_boundaries[mid_index] 19 | 20 | if codepoint < mid_codepoint then 21 | end_index = mid_index 22 | elseif codepoint > mid_codepoint then 23 | begin_index = mid_index 24 | else 25 | floor_boundary_index = mid_index 26 | break 27 | end 28 | end 29 | 30 | floor_boundary_index = floor_boundary_index or begin_index 31 | -- floor_boundary_index is the number of the block containing codepoint. 32 | -- Printable and not printable blocks alternate and the first one is not printable (zero is not printable). 33 | return floor_boundary_index % 2 == 0 34 | end 35 | 36 | return unicode 37 | -------------------------------------------------------------------------------- /src/luacheck/vendor/sha1/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Enrique García Cota, Eike Decker, Jeffrey Friedl 2 | Copyright (c) 2018 Peter Melnichenko 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a 5 | copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included 13 | in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 19 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 20 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/luacheck/vendor/sha1/bit32_ops.lua: -------------------------------------------------------------------------------- 1 | local bit32 = require "bit32" 2 | 3 | local ops = {} 4 | 5 | local band = bit32.band 6 | local bor = bit32.bor 7 | local bxor = bit32.bxor 8 | 9 | ops.uint32_lrot = bit32.lrotate 10 | ops.byte_xor = bxor 11 | ops.uint32_xor_3 = bxor 12 | ops.uint32_xor_4 = bxor 13 | 14 | function ops.uint32_ternary(a, b, c) 15 | -- c ~ (a & (b ~ c)) has less bitwise operations than (a & b) | (~a & c). 16 | return bxor(c, band(a, bxor(b, c))) 17 | end 18 | 19 | function ops.uint32_majority(a, b, c) 20 | -- (a & (b | c)) | (b & c) has less bitwise operations than (a & b) | (a & c) | (b & c). 21 | return bor(band(a, bor(b, c)), band(b, c)) 22 | end 23 | 24 | return ops 25 | -------------------------------------------------------------------------------- /src/luacheck/vendor/sha1/bit_ops.lua: -------------------------------------------------------------------------------- 1 | local bit = require "bit" 2 | 3 | local ops = {} 4 | 5 | local band = bit.band 6 | local bor = bit.bor 7 | local bxor = bit.bxor 8 | 9 | ops.uint32_lrot = bit.rol 10 | ops.byte_xor = bxor 11 | ops.uint32_xor_3 = bxor 12 | ops.uint32_xor_4 = bxor 13 | 14 | function ops.uint32_ternary(a, b, c) 15 | -- c ~ (a & (b ~ c)) has less bitwise operations than (a & b) | (~a & c). 16 | return bxor(c, band(a, bxor(b, c))) 17 | end 18 | 19 | function ops.uint32_majority(a, b, c) 20 | -- (a & (b | c)) | (b & c) has less bitwise operations than (a & b) | (a & c) | (b & c). 21 | return bor(band(a, bor(b, c)), band(b, c)) 22 | end 23 | 24 | return ops 25 | -------------------------------------------------------------------------------- /src/luacheck/vendor/sha1/common.lua: -------------------------------------------------------------------------------- 1 | local common = {} 2 | 3 | -- Merges four bytes into a uint32 number. 4 | function common.bytes_to_uint32(a, b, c, d) 5 | return a * 0x1000000 + b * 0x10000 + c * 0x100 + d 6 | end 7 | 8 | -- Splits a uint32 number into four bytes. 9 | function common.uint32_to_bytes(a) 10 | local a4 = a % 256 11 | a = (a - a4) / 256 12 | local a3 = a % 256 13 | a = (a - a3) / 256 14 | local a2 = a % 256 15 | local a1 = (a - a2) / 256 16 | return a1, a2, a3, a4 17 | end 18 | 19 | 20 | return common 21 | -------------------------------------------------------------------------------- /src/luacheck/vendor/sha1/lua53_ops.lua: -------------------------------------------------------------------------------- 1 | local ops = {} 2 | 3 | function ops.uint32_lrot(a, bits) 4 | return ((a << bits) & 0xFFFFFFFF) | (a >> (32 - bits)) 5 | end 6 | 7 | function ops.byte_xor(a, b) 8 | return a ~ b 9 | end 10 | 11 | function ops.uint32_xor_3(a, b, c) 12 | return a ~ b ~ c 13 | end 14 | 15 | function ops.uint32_xor_4(a, b, c, d) 16 | return a ~ b ~ c ~ d 17 | end 18 | 19 | function ops.uint32_ternary(a, b, c) 20 | -- c ~ (a & (b ~ c)) has less bitwise operations than (a & b) | (~a & c). 21 | return c ~ (a & (b ~ c)) 22 | end 23 | 24 | function ops.uint32_majority(a, b, c) 25 | -- (a & (b | c)) | (b & c) has less bitwise operations than (a & b) | (a & c) | (b & c). 26 | return (a & (b | c)) | (b & c) 27 | end 28 | 29 | return ops 30 | -------------------------------------------------------------------------------- /src/luacheck/version.lua: -------------------------------------------------------------------------------- 1 | local argparse = require "argparse" 2 | local lfs = require "lfs" 3 | local luacheck = require "luacheck" 4 | local multithreading = require "luacheck.multithreading" 5 | local utils = require "luacheck.utils" 6 | 7 | local version = {} 8 | 9 | version.luacheck = luacheck._VERSION 10 | 11 | if rawget(_G, "jit") then 12 | version.lua = rawget(_G, "jit").version 13 | elseif _VERSION:find("^Lua ") then 14 | version.lua = "PUC-Rio " .. _VERSION 15 | else 16 | version.lua = _VERSION 17 | end 18 | 19 | version.argparse = argparse.version 20 | 21 | version.lfs = utils.unprefix(lfs._VERSION, "LuaFileSystem ") 22 | 23 | if multithreading.has_lanes then 24 | version.lanes = multithreading.lanes.ABOUT.version 25 | else 26 | version.lanes = "Not found" 27 | end 28 | 29 | version.string = ([[ 30 | Luacheck: %s 31 | Lua: %s 32 | Argparse: %s 33 | LuaFileSystem: %s 34 | LuaLanes: %s]]):format(version.luacheck, version.lua, version.argparse, version.lfs, version.lanes) 35 | 36 | return version 37 | --------------------------------------------------------------------------------