Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package lua-luacheck for openSUSE:Factory checked in at 2023-05-03 15:42:26 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/lua-luacheck (Old) and /work/SRC/openSUSE:Factory/.lua-luacheck.new.1533 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "lua-luacheck" Wed May 3 15:42:26 2023 rev:2 rq:1084322 version:1.1.0 Changes: -------- --- /work/SRC/openSUSE:Factory/lua-luacheck/lua-luacheck.changes 2022-11-24 12:22:55.501181553 +0100 +++ /work/SRC/openSUSE:Factory/.lua-luacheck.new.1533/lua-luacheck.changes 2023-05-03 15:42:27.774785202 +0200 @@ -1,0 +2,8 @@ +Wed May 3 11:07:50 UTC 2023 - Michal Suchanek <[email protected]> + +- Update to 1.1.0 + - Add support for compound operators + - Add builtin rule set for SILE globals + - Fix circular reference detection + +------------------------------------------------------------------- Old: ---- luacheck-1.0.0.tar.gz New: ---- luacheck-1.1.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ lua-luacheck.spec ++++++ --- /var/tmp/diff_new_pack.cQ5zhY/_old 2023-05-03 15:42:28.306788354 +0200 +++ /var/tmp/diff_new_pack.cQ5zhY/_new 2023-05-03 15:42:28.310788378 +0200 @@ -20,7 +20,7 @@ %define flavor @BUILD_FLAVOR@%{nil} %define mod_name luacheck %define lua_value %(echo "%{flavor}" |sed -e 's:lua::') -Version: 1.0.0 +Version: 1.1.0 Release: 0 Summary: Command-line tool for linting and static analysis of Lua code License: MIT ++++++ luacheck-1.0.0.tar.gz -> luacheck-1.1.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/.gitignore new/luacheck-1.1.0/.gitignore --- old/luacheck-1.0.0/.gitignore 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/.gitignore 2022-12-19 18:51:56.000000000 +0100 @@ -2,6 +2,7 @@ luacov.stats.out luacov.report.out doc +*.rock !build/ build/* !build/Makefile diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/CHANGELOG.md new/luacheck-1.1.0/CHANGELOG.md --- old/luacheck-1.0.0/CHANGELOG.md 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/CHANGELOG.md 2022-12-19 18:51:56.000000000 +0100 @@ -2,6 +2,18 @@ All notable changes to this project will be documented in this file. +## [1.1.0] - 2022-12-19 + +### Features + +- Add builtin rule set for SILE globals (#79) â @alerque +- Implement support for compound operators (#66) â @a2 & @arichard4 + +### Bug Fixes + +- Correct circular reference detection visavis OpSet â @arichard4 +- Remove unnecessary symbol from Playdate std (#84) â @DidierMalenfant + ## v1.0.0 (2022-08-24) ### Documentation @@ -10,11 +22,11 @@ ### Features -- Overhaul docker container to run on Lua 5.4 -- Store cached luacheck values per-version in case of changes -- Set_default_std for ldoc -- Add builtin std option for Ldoc globals -- Add builtin std option for the Playdate SDK +- Overhaul docker container to run on Lua 5.4 â @alerque +- Store cached luacheck values per-version in case of changes â @arichard4 +- Set_default_std for ldoc â @Aire-One +- Add builtin std option for Ldoc globals â @Aire-One +- Add builtin std option for the Playdate SDK â @DidierMalenfant ## v0.26.1 (2022-04-23) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/README.md new/luacheck-1.1.0/README.md --- old/luacheck-1.0.0/README.md 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/README.md 2022-12-19 18:51:56.000000000 +0100 @@ -2,8 +2,8 @@ [](https://gitter.im/luacheck/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[](https://github.com/lunarmodules/luacheck/actions?workflow=Luacheck) -[](https://github.com/lunarmodules/luacheck/actions?workflow=Busted) +[](https://github.com/lunarmodules/luacheck/actions?workflow=Luacheck) +[](https://github.com/lunarmodules/luacheck/actions?workflow=Busted) [](https://coveralls.io/github/lunarmodules/luacheck?branch=master) [](https://github.com/lunarmodules/luacheck/releases) [](https://luarocks.org/modules/lunarmodules/luacheck) @@ -40,7 +40,7 @@ ### Windows binary download For Windows there is single-file 64-bit binary distribution, bundling Lua 5.4.4, Luacheck, LuaFileSystem, and LuaLanes using [LuaStatic](https://github.com/ers35/luastatic): -[download](https://github.com/lunarmodules/luacheck/releases/download/v1.0.0/luacheck.exe). +[download](https://github.com/lunarmodules/luacheck/releases/download/v1.1.0/luacheck.exe). ## Basic usage @@ -109,13 +109,13 @@ ## Development -Luacheck is currently in development. The latest released version is v1.0.0. The interface of the `luacheck` module may change between minor releases. The command line interface is fairly stable. +Luacheck is currently in development. The latest released version is v1.1.0. The interface of the `luacheck` module may change between minor releases. The command line interface is fairly stable. Use the Luacheck issue tracker on GitHub to submit bugs, suggestions and questions. Any pull requests are welcome, too. ## Building and testing -After the Luacheck repo is cloned and changes are made, run `luarocks make` (using `sudo` if necessary) from its root directory to install dev version of Luacheck. To run Luacheck using sources in current directory without installing it, run `lua -e 'package.path="./src/?.lua;./src/?/init.lua;"..package.path' bin/luacheck.lua ...`. To test Luacheck, ensure that you have [busted](http://olivinelabs.com/busted/) and [luautf8](https://github.com/starwing/luautf8) installed and run `busted`. +After the Luacheck repo is cloned and changes are made, run `luarocks make` (using `sudo` if necessary) from its root directory to install dev version of Luacheck. To run Luacheck using sources in current directory without installing it, run `lua -e 'package.path="./src/?.lua;./src/?/init.lua;"..package.path' bin/luacheck.lua ...`. To test Luacheck, ensure that you have [busted](http://olivinelabs.com/busted/), [luautf8](https://github.com/starwing/luautf8), and [luasocket](https://github.com/lunarmodules/luasocket) installed and run `busted`. ## Docker diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/action.yml new/luacheck-1.1.0/action.yml --- old/luacheck-1.0.0/action.yml 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/action.yml 2022-12-19 18:51:56.000000000 +0100 @@ -7,7 +7,7 @@ default: "." runs: using: docker - image: docker://ghcr.io/lunarmodules/luacheck:v1.0.0 + image: docker://ghcr.io/lunarmodules/luacheck:v1.1.0 entrypoint: sh args: - -c diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/docsrc/cli.rst new/luacheck-1.1.0/docsrc/cli.rst --- old/luacheck-1.0.0/docsrc/cli.rst 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/docsrc/cli.rst 2022-12-19 18:51:56.000000000 +0100 @@ -87,6 +87,7 @@ * ``rockspec`` - globals allowed in rockspecs, by default added for files ending with ``.rockspec``; * ``luacheckrc`` - globals allowed in Luacheck configs, by default added for files ending with ``.luacheckrc``; * ``ldoc`` - globals allowed in LDoc config, by default added for files named ``config.ld``; + * ``sile`` - globals allowed in The SILE Typesetter and its package ecosystem; * ``none`` - no standard globals. See :ref:`stds` @@ -118,6 +119,7 @@ ``--ignore | -i <patt> [<patt>] ...`` Filter out warnings matching patterns. ``--enable | -e <patt> [<patt>] ...`` Do not filter out warnings matching patterns. ``--only | -o <patt> [<patt>] ...`` Filter out warnings not matching patterns. +``--operators <patt> [<patt>] ...`` Allow compound operators matching patterns. (Multiple assignment not supported, as this is specifically for the Playdate SDK.) ``--config <config>`` Path to custom configuration file (default: ``.luacheckrc``). ``--no-config`` Do not look up custom configuration file. ``--default-config <config>`` Default path to custom configuration file, to be used if ``--[no-]config`` is not used and ``.luacheckrc`` is not found. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/docsrc/conf.py new/luacheck-1.1.0/docsrc/conf.py --- old/luacheck-1.0.0/docsrc/conf.py 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/docsrc/conf.py 2022-12-19 18:51:56.000000000 +0100 @@ -48,9 +48,9 @@ # built documents. # # The short X.Y version. -version = '1.0.0' +version = '1.1.0' # The full version, including alpha/beta/rc tags. -release = '1.0.0' +release = '1.1.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/docsrc/config.rst new/luacheck-1.1.0/docsrc/config.rst --- old/luacheck-1.0.0/docsrc/config.rst 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/docsrc/config.rst 2022-12-19 18:51:56.000000000 +0100 @@ -42,6 +42,7 @@ ``read_globals`` Array of strings or field definition map ``{}`` ``new_read_globals`` Array of strings or field definition map (Do not overwrite) ``not_globals`` Array of strings ``{}`` +``operators`` Array of strings ``{}`` ``compat`` Boolean ``false`` ``allow_defined`` Boolean ``false`` ``allow_defined_top`` Boolean ``false`` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/docsrc/index.rst new/luacheck-1.1.0/docsrc/index.rst --- old/luacheck-1.0.0/docsrc/index.rst 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/docsrc/index.rst 2022-12-19 18:51:56.000000000 +0100 @@ -11,4 +11,4 @@ inline module -This is documentation for 0.26.0 version of `Luacheck <https://github.com/lunarmodules/luacheck/>`_, a linter for `Lua <https://www.lua.org/>`_. +This is documentation for version |version| of `Luacheck <https://github.com/lunarmodules/luacheck/>`_, a linter for `Lua <https://www.lua.org/>`_. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/docsrc/warnings.rst new/luacheck-1.1.0/docsrc/warnings.rst --- old/luacheck-1.0.0/docsrc/warnings.rst 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/docsrc/warnings.rst 2022-12-19 18:51:56.000000000 +0100 @@ -10,6 +10,7 @@ 021 An invalid inline option. 022 An unpaired inline push directive. 023 An unpaired inline pop directive. +033 Invalid use of a compound operator. (Lua doesn't support compound operator by default; if using an extension that does, please set the operators option.) 111 Setting an undefined global variable. 112 Mutating an undefined global variable. 113 Accessing an undefined global variable. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/luacheck-dev-1.rockspec new/luacheck-1.1.0/luacheck-dev-1.rockspec --- old/luacheck-1.0.0/luacheck-dev-1.rockspec 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/luacheck-dev-1.rockspec 2022-12-19 18:51:56.000000000 +0100 @@ -68,6 +68,7 @@ ["luacheck.serializer"] = "src/luacheck/serializer.lua", ["luacheck.stages"] = "src/luacheck/stages/init.lua", ["luacheck.stages.detect_bad_whitespace"] = "src/luacheck/stages/detect_bad_whitespace.lua", + ["luacheck.stages.detect_compound_operators"] = "src/luacheck/stages/detect_compound_operators.lua", ["luacheck.stages.detect_cyclomatic_complexity"] = "src/luacheck/stages/detect_cyclomatic_complexity.lua", ["luacheck.stages.detect_empty_blocks"] = "src/luacheck/stages/detect_empty_blocks.lua", ["luacheck.stages.detect_empty_statements"] = "src/luacheck/stages/detect_empty_statements.lua", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/rockspecs/luacheck-1.1.0-1.rockspec new/luacheck-1.1.0/rockspecs/luacheck-1.1.0-1.rockspec --- old/luacheck-1.0.0/rockspecs/luacheck-1.1.0-1.rockspec 1970-01-01 01:00:00.000000000 +0100 +++ new/luacheck-1.1.0/rockspecs/luacheck-1.1.0-1.rockspec 2022-12-19 18:51:56.000000000 +0100 @@ -0,0 +1,95 @@ +local package_name = "luacheck" +local package_version = "1.1.0" +local rockspec_revision = "1" +local github_account_name = "lunarmodules" +local github_repo_name = package_name + +package = package_name +version = package_version .. "-" .. rockspec_revision + +source = { + url = "git+https://github.com/" .. github_account_name .. "/" .. github_repo_name .. ".git" +} + +if package_version == "dev" then source.branch = "master" else source.tag = "v" .. package_version end + +description = { + summary = "A static analyzer and a linter for Lua", + detailed = [[ + 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. + ]], + homepage = "https://github.com/lunarmodules/luacheck", + license = "MIT" +} + +dependencies = { + "lua >= 5.1", + "argparse >= 0.6.0", + "luafilesystem >= 1.6.3" +} +build = { + type = "builtin", + modules = { + luacheck = "src/luacheck/init.lua", + ["luacheck.builtin_standards"] = "src/luacheck/builtin_standards/init.lua", + ["luacheck.builtin_standards.love"] = "src/luacheck/builtin_standards/love.lua", + ["luacheck.builtin_standards.playdate"] = "src/luacheck/builtin_standards/playdate.lua", + ["luacheck.builtin_standards.ngx"] = "src/luacheck/builtin_standards/ngx.lua", + ["luacheck.cache"] = "src/luacheck/cache.lua", + ["luacheck.check"] = "src/luacheck/check.lua", + ["luacheck.check_state"] = "src/luacheck/check_state.lua", + ["luacheck.config"] = "src/luacheck/config.lua", + ["luacheck.core_utils"] = "src/luacheck/core_utils.lua", + ["luacheck.decoder"] = "src/luacheck/decoder.lua", + ["luacheck.expand_rockspec"] = "src/luacheck/expand_rockspec.lua", + ["luacheck.filter"] = "src/luacheck/filter.lua", + ["luacheck.format"] = "src/luacheck/format.lua", + ["luacheck.fs"] = "src/luacheck/fs.lua", + ["luacheck.globbing"] = "src/luacheck/globbing.lua", + ["luacheck.lexer"] = "src/luacheck/lexer.lua", + ["luacheck.main"] = "src/luacheck/main.lua", + ["luacheck.multithreading"] = "src/luacheck/multithreading.lua", + ["luacheck.options"] = "src/luacheck/options.lua", + ["luacheck.parser"] = "src/luacheck/parser.lua", + ["luacheck.profiler"] = "src/luacheck/profiler.lua", + ["luacheck.runner"] = "src/luacheck/runner.lua", + ["luacheck.serializer"] = "src/luacheck/serializer.lua", + ["luacheck.stages"] = "src/luacheck/stages/init.lua", + ["luacheck.stages.detect_bad_whitespace"] = "src/luacheck/stages/detect_bad_whitespace.lua", + ["luacheck.stages.detect_compound_operators"] = "src/luacheck/stages/detect_compound_operators.lua", + ["luacheck.stages.detect_cyclomatic_complexity"] = "src/luacheck/stages/detect_cyclomatic_complexity.lua", + ["luacheck.stages.detect_empty_blocks"] = "src/luacheck/stages/detect_empty_blocks.lua", + ["luacheck.stages.detect_empty_statements"] = "src/luacheck/stages/detect_empty_statements.lua", + ["luacheck.stages.detect_globals"] = "src/luacheck/stages/detect_globals.lua", + ["luacheck.stages.detect_reversed_fornum_loops"] = "src/luacheck/stages/detect_reversed_fornum_loops.lua", + ["luacheck.stages.detect_unbalanced_assignments"] = "src/luacheck/stages/detect_unbalanced_assignments.lua", + ["luacheck.stages.detect_uninit_accesses"] = "src/luacheck/stages/detect_uninit_accesses.lua", + ["luacheck.stages.detect_unreachable_code"] = "src/luacheck/stages/detect_unreachable_code.lua", + ["luacheck.stages.detect_unused_fields"] = "src/luacheck/stages/detect_unused_fields.lua", + ["luacheck.stages.detect_unused_locals"] = "src/luacheck/stages/detect_unused_locals.lua", + ["luacheck.stages.linearize"] = "src/luacheck/stages/linearize.lua", + ["luacheck.stages.name_functions"] = "src/luacheck/stages/name_functions.lua", + ["luacheck.stages.parse"] = "src/luacheck/stages/parse.lua", + ["luacheck.stages.parse_inline_options"] = "src/luacheck/stages/parse_inline_options.lua", + ["luacheck.stages.resolve_locals"] = "src/luacheck/stages/resolve_locals.lua", + ["luacheck.stages.unwrap_parens"] = "src/luacheck/stages/unwrap_parens.lua", + ["luacheck.standards"] = "src/luacheck/standards.lua", + ["luacheck.unicode"] = "src/luacheck/unicode.lua", + ["luacheck.unicode_printability_boundaries"] = "src/luacheck/unicode_printability_boundaries.lua", + ["luacheck.utils"] = "src/luacheck/utils.lua", + ["luacheck.vendor.sha1"] = "src/luacheck/vendor/sha1/init.lua", + ["luacheck.vendor.sha1.bit32_ops"] = "src/luacheck/vendor/sha1/bit32_ops.lua", + ["luacheck.vendor.sha1.bit_ops"] = "src/luacheck/vendor/sha1/bit_ops.lua", + ["luacheck.vendor.sha1.common"] = "src/luacheck/vendor/sha1/common.lua", + ["luacheck.vendor.sha1.lua53_ops"] = "src/luacheck/vendor/sha1/lua53_ops.lua", + ["luacheck.vendor.sha1.pure_lua_ops"] = "src/luacheck/vendor/sha1/pure_lua_ops.lua", + ["luacheck.version"] = "src/luacheck/version.lua" + }, + install = { + bin = { + luacheck = "bin/luacheck.lua" + } + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/spec/cli_spec.lua new/luacheck-1.1.0/spec/cli_spec.lua --- old/luacheck-1.0.0/spec/cli_spec.lua 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/spec/cli_spec.lua 2022-12-19 18:51:56.000000000 +0100 @@ -295,6 +295,36 @@ ]], get_output "--std lua51+lua52+lua53 spec/samples/bad_code.lua --no-config") end) + it("raises critical errors on config without additional operators", function() + assert.equal([[Checking spec/samples/compound_operators.lua 4 errors + + spec/samples/compound_operators.lua:2:1: assignment uses compound operator += + spec/samples/compound_operators.lua:3:1: assignment uses compound operator -= + spec/samples/compound_operators.lua:4:1: assignment uses compound operator *= + spec/samples/compound_operators.lua:5:1: assignment uses compound operator /= + +Total: 0 warnings / 4 errors in 1 file +]], get_output "spec/samples/compound_operators.lua --no-config") + end) + + it("raises critical errors for unfiltered additional operators", function() + assert.equal([[Checking spec/samples/compound_operators.lua 3 errors + + spec/samples/compound_operators.lua:3:1: assignment uses compound operator -= + spec/samples/compound_operators.lua:4:1: assignment uses compound operator *= + spec/samples/compound_operators.lua:5:1: assignment uses compound operator /= + +Total: 0 warnings / 3 errors in 1 file +]], get_output "spec/samples/compound_operators.lua --no-config --operators +=") + end) + + it("allows to define allowed compound operators", function() + assert.equal([[Checking spec/samples/compound_operators.lua OK + +Total: 0 warnings / 0 errors in 1 file +]], get_output "spec/samples/compound_operators.lua --config=spec/configs/compound_operators_config.luacheckrc") + end) + it("allows to ignore some variables", function() assert.equal([[ Checking spec/samples/bad_code.lua 3 warnings @@ -993,7 +1023,7 @@ end) it("expands folders", function() - assert.matches("^Total: %d+ warnings / %d+ errors in 26 files\n$", get_output "spec/samples -qqq --no-config --exclude-files spec/samples/global_fields.lua") + assert.matches("^Total: %d+ warnings / %d+ errors in 27 files\n$", get_output "spec/samples -qqq --no-config --exclude-files spec/samples/global_fields.lua") end) it("uses --include-files when expanding folders", function() @@ -1205,6 +1235,7 @@ assert.equal(([[ Checking spec/samples/argparse-0.2.0.lua 9 warnings Checking spec/samples/compat.lua 4 warnings +Checking spec/samples/compound_operators.lua 4 errors Checking spec/samples/custom_std_inline_options.lua 3 warnings / 1 error Checking spec/samples/global_inline_options.lua 3 warnings Checking spec/samples/globals.lua 2 warnings @@ -1221,7 +1252,7 @@ Checking spec/samples/utf8.lua 4 warnings Checking spec/samples/utf8_error.lua 1 error -Total: 73 warnings / 5 errors in 19 files +Total: 73 warnings / 9 errors in 20 files ]]):gsub("(spec/samples)/", "%1"..package.config:sub(1, 1)), get_output "spec/samples --config=spec/configs/exclude_files_config.luacheckrc -qq --exclude-files spec/samples/global_fields.lua") end) @@ -1230,6 +1261,7 @@ assert.equal([[ Checking argparse-0.2.0.lua 9 warnings Checking compat.lua 4 warnings +Checking compound_operators.lua 4 errors Checking custom_std_inline_options.lua 3 warnings / 1 error Checking global_inline_options.lua 3 warnings Checking globals.lua 2 warnings @@ -1246,7 +1278,7 @@ Checking utf8.lua 4 warnings Checking utf8_error.lua 1 error -Total: 73 warnings / 5 errors in 19 files +Total: 73 warnings / 9 errors in 20 files ]], get_output(". --config=spec/configs/exclude_files_config.luacheckrc -qq --exclude-files global_fields.lua", "spec/samples/")) end) @@ -1254,6 +1286,7 @@ assert.equal([[ Checking argparse-0.2.0.lua 9 warnings Checking compat.lua 4 warnings +Checking compound_operators.lua 4 errors Checking custom_std_inline_options.lua 3 warnings / 1 error Checking global_inline_options.lua 3 warnings Checking globals.lua 2 warnings @@ -1268,7 +1301,7 @@ Checking utf8.lua 4 warnings Checking utf8_error.lua 1 error -Total: 65 warnings / 5 errors in 17 files +Total: 65 warnings / 9 errors in 18 files ]], get_output(". --config=spec/configs/exclude_files_config.luacheckrc -qq --exclude-files global_fields.lua --exclude-files " .. quote("./read*"), "spec/samples/")) end) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/spec/configs/compound_operators_config.luacheckrc new/luacheck-1.1.0/spec/configs/compound_operators_config.luacheckrc --- old/luacheck-1.0.0/spec/configs/compound_operators_config.luacheckrc 1970-01-01 01:00:00.000000000 +0100 +++ new/luacheck-1.1.0/spec/configs/compound_operators_config.luacheckrc 2022-12-19 18:51:56.000000000 +0100 @@ -0,0 +1 @@ +operators = {"+=", "-=", "*=", "/="} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/spec/samples/compound_operators.lua new/luacheck-1.1.0/spec/samples/compound_operators.lua --- old/luacheck-1.0.0/spec/samples/compound_operators.lua 1970-01-01 01:00:00.000000000 +0100 +++ new/luacheck-1.1.0/spec/samples/compound_operators.lua 2022-12-19 18:51:56.000000000 +0100 @@ -0,0 +1,6 @@ +local i = 0 +i += 10 +i -= 5 +i *= 2 +i /= 5 +return i diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/src/luacheck/builtin_standards/init.lua new/luacheck-1.1.0/src/luacheck/builtin_standards/init.lua --- old/luacheck-1.0.0/src/luacheck/builtin_standards/init.lua 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/src/luacheck/builtin_standards/init.lua 2022-12-19 18:51:56.000000000 +0100 @@ -311,7 +311,7 @@ "allow_defined_top", "module", "globals", "read_globals", "new_globals", "new_read_globals", "not_globals", "ignore", "enable", "only", "std", "max_line_length", "max_code_line_length", "max_string_line_length", "max_comment_line_length", "max_cyclomatic_complexity", "quiet", "color", "codes", "ranges", "formatter", - "cache", "jobs", "files", "stds", "exclude_files", "include_files" + "cache", "jobs", "files", "stds", "exclude_files", "include_files", "operators" } } @@ -334,6 +334,12 @@ } } +builtin_standards.sile = { + globals = { + "SILE", "SU", "luautf8", "pl", "fluent", "CASILE" + } +} + builtin_standards.none = {} return builtin_standards diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/src/luacheck/builtin_standards/playdate.lua new/luacheck-1.1.0/src/luacheck/builtin_standards/playdate.lua --- old/luacheck-1.0.0/src/luacheck/builtin_standards/playdate.lua 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/src/luacheck/builtin_standards/playdate.lua 2022-12-19 18:51:56.000000000 +0100 @@ -135,7 +135,6 @@ argv = empty, setNewlinePrinted = empty, drawFPS = empty, - exit = empty, -- Profiling getStats = empty, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/src/luacheck/filter.lua new/luacheck-1.1.0/src/luacheck/filter.lua --- old/luacheck-1.0.0/src/luacheck/filter.lua 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/src/luacheck/filter.lua 2022-12-19 18:51:56.000000000 +0100 @@ -163,6 +163,15 @@ end warning.max_complexity = max_complexity + elseif warning.code == "033" then + local operators = normalized_options.operators or {} + for _, op in ipairs(operators) do + if warning.operator == op then + return false + end + end + + return true elseif warning.code:find("^[234]") and warning.name == "_" and not warning.useless then return false elseif warning.code:find("^1[14]") then diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/src/luacheck/init.lua new/luacheck-1.1.0/src/luacheck/init.lua --- old/luacheck-1.0.0/src/luacheck/init.lua 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/src/luacheck/init.lua 2022-12-19 18:51:56.000000000 +0100 @@ -5,7 +5,7 @@ local utils = require "luacheck.utils" local luacheck = { - _VERSION = "1.0.0" + _VERSION = "1.1.0" } local function raw_validate_options(fname, opts, stds, context) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/src/luacheck/main.lua new/luacheck-1.1.0/src/luacheck/main.lua --- old/luacheck-1.0.0/src/luacheck/main.lua 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/src/luacheck/main.lua 2022-12-19 18:51:56.000000000 +0100 @@ -69,6 +69,12 @@ :count "*" :argname "<patt>" :action "concat" + :init(nil), + parser:option("--operators", "Allow compound operators matching patterns") + :args "+" + :count "*" + :argname "<patt>" + :action "concat" :init(nil)) parser:group("Options for configuring allowed globals", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/src/luacheck/options.lua new/luacheck-1.1.0/src/luacheck/options.lua --- old/luacheck-1.0.0/src/luacheck/options.lua 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/src/luacheck/options.lua 2022-12-19 18:51:56.000000000 +0100 @@ -70,7 +70,7 @@ not_globals = array_of_strings, ignore = array_of_strings, enable = array_of_strings, - only = array_of_strings + only = array_of_strings, } options.all_options = { @@ -79,7 +79,8 @@ max_code_line_length = number_or_false, max_string_line_length = number_or_false, max_comment_line_length = number_or_false, - max_cyclomatic_complexity = number_or_false + max_cyclomatic_complexity = number_or_false, + operators = array_of_strings } utils.update(options.all_options, options.nullary_inline_options) @@ -385,6 +386,26 @@ return res end +local function get_operators(opts_stack) + local operators, operatorsMap = nil, nil + + for _, opts in ipairs(opts_stack) do + if opts.operators then + operators = operators or {} + operatorsMap = operatorsMap or {} + + for _, op in ipairs(opts.operators) do + if not operatorsMap[op] then + table.insert(operators, op) + operatorsMap[op] = true + end + end + end + end + + return operators +end + local scalar_options = { unused_secondaries = true, self = true, @@ -404,6 +425,7 @@ local res = {} stds = stds or builtin_standards res.std = get_final_std(opts_stack, stds) + res.operators = get_operators(opts_stack) for option, default in pairs(scalar_options) do res[option] = get_scalar_opt(opts_stack, option, default) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/src/luacheck/parser.lua new/luacheck-1.1.0/src/luacheck/parser.lua --- old/luacheck-1.0.0/src/luacheck/parser.lua 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/src/luacheck/parser.lua 2022-12-19 18:51:56.000000000 +0100 @@ -572,6 +572,16 @@ ["and"] = "and", ["or"] = "or" } +local compound_operators = { + ["+"] = "add", ["-"] = "sub", + ["*"] = "mul", ["%"] = "mod", + ["^"] = "pow", + ["/"] = "div", ["//"] = "idiv", + ["&"] = "band", ["|"] = "bor", ["~"] = "bxor", + ["<<"] = "shl", [">>"] = "shr", + [".."] = "concat" +} + local left_priorities = { add = 10, sub = 10, mul = 11, mod = 11, @@ -903,9 +913,31 @@ lhs[#lhs + 1] = primary_expression until not test_and_skip_token(state, ",") - check_and_skip_token(state, "=") - local rhs = parse_expression_list(state) - return new_inner_node(start_range, rhs[#rhs], "Set", {lhs, rhs}) + local compound_operator = compound_operators[state.token] + if compound_operator then + -- This is an assignment in the form `lhs op= rhs`. + + if #lhs ~= 1 then + -- Multiple lhs values are not valid + parse_error(state, "compound assignment not allowed on tuples near " .. compound_operator .. "=") + end + + -- Skip operator. + skip_token(state) + check_and_skip_token(state, "=") + + local rhs = parse_expression_list(state) + if #rhs ~= 1 then + parse_error(state, "compound assignment not allowed on tuples near " .. compound_operator .. "=") + end + + return new_inner_node(start_range, rhs[1], "OpSet", {compound_operator, lhs[1], rhs[1]}) + else + -- This is an assignment in the form `lhs = rhs`. + check_and_skip_token(state, "=") + local rhs = parse_expression_list(state) + return new_inner_node(start_range, rhs[#rhs], "Set", {lhs, rhs}) + end end local function parse_statement(state) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/src/luacheck/serializer.lua new/luacheck-1.1.0/src/luacheck/serializer.lua --- old/luacheck-1.0.0/src/luacheck/serializer.lua 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/src/luacheck/serializer.lua 2022-12-19 18:51:56.000000000 +0100 @@ -9,7 +9,7 @@ "unused_secondaries", "allow_defined", "allow_defined_top", "module", "read_globals", "new_globals", "new_read_globals", "enable", "only", "not_globals", "max_line_length", "max_code_line_length", "max_string_line_length", "max_comment_line_length", - "max_cyclomatic_complexity" + "max_cyclomatic_complexity", "operators" } local function compress_table(t, fields) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/src/luacheck/stages/detect_compound_operators.lua new/luacheck-1.1.0/src/luacheck/stages/detect_compound_operators.lua --- old/luacheck-1.0.0/src/luacheck/stages/detect_compound_operators.lua 1970-01-01 01:00:00.000000000 +0100 +++ new/luacheck-1.1.0/src/luacheck/stages/detect_compound_operators.lua 2022-12-19 18:51:56.000000000 +0100 @@ -0,0 +1,34 @@ +local core_utils = require "luacheck.core_utils" + +local stage = {} + +stage.warnings = { + ["033"] = {message_format = "assignment uses compound operator {operator}", fields = {"operator"}}, +} + +local reverse_compound_operators = { + add = "+=", + sub = "-=", + mul = "*=", + mod = "%=", + pow = "^=", + div = "/=", + idiv = "//=", + band = "&=", + bor = "|=", + bxor = "~=", + shl = "<<=", + shr = ">>=", + concat = "..=" +} + +local function check_node(chstate, node) + local operator = reverse_compound_operators[node[1]] + chstate:warn_range("033", node, {operator = operator}) +end + +function stage.run(chstate) + core_utils.each_statement(chstate, { "OpSet" }, check_node) +end + +return stage diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/src/luacheck/stages/init.lua new/luacheck-1.1.0/src/luacheck/stages/init.lua --- old/luacheck-1.0.0/src/luacheck/stages/init.lua 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/src/luacheck/stages/init.lua 2022-12-19 18:51:56.000000000 +0100 @@ -16,6 +16,7 @@ "name_functions", "resolve_locals", "detect_bad_whitespace", + "detect_compound_operators", "detect_cyclomatic_complexity", "detect_empty_blocks", "detect_empty_statements", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/src/luacheck/stages/linearize.lua new/luacheck-1.1.0/src/luacheck/stages/linearize.lua --- old/luacheck-1.0.0/src/luacheck/stages/linearize.lua 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/src/luacheck/stages/linearize.lua 2022-12-19 18:51:56.000000000 +0100 @@ -199,6 +199,19 @@ } end +local function new_opset_item(node) + return { + tag = "OpSet", + node = node, + lhs = node[2], + rhs = node[3], + accesses = {}, + mutations = {}, + used_values = {}, + lines = {} + } +end + local function is_unpacking(node) return node.tag == "Dots" or node.tag == "Call" or node.tag == "Invoke" end @@ -515,6 +528,24 @@ self:emit(item) end +function LinState:emit_stmt_OpSet(node) + local item = new_opset_item(node) + self:scan_expr(item, node[3]) + + local lhs = node[2] + if lhs.tag == "Id" then + local var = self:check_var(lhs) + + if var then + self:register_upvalue_action(item, var, "set_upvalues") + end + else + assert(lhs.tag == "Index") + self:scan_lhs_index(item, lhs) + end + + self:emit(item) +end function LinState:scan_expr(item, node) local scanner = self["scan_expr_" .. node.tag] @@ -611,6 +642,8 @@ end end +LinState.scan_expr_OpSet = LinState.scan_expr_Op + -- Puts tables {var = value} into field `set_variables` of items in line which set values. -- Registers set values in field `values` of variables. function LinState:register_set_variables() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/src/luacheck/stages/parse_inline_options.lua new/luacheck-1.1.0/src/luacheck/stages/parse_inline_options.lua --- old/luacheck-1.0.0/src/luacheck/stages/parse_inline_options.lua 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/src/luacheck/stages/parse_inline_options.lua 2022-12-19 18:51:56.000000000 +0100 @@ -193,7 +193,7 @@ -- Adds a table with `line`, `column`, and `options` fields to given array. -- For each function a table with `options` set to "push" for the function start --- and a talbe with `options` set to "pop" for the function end are added. +-- and a table with `options` set to "pop" for the function end are added. local function add_function_boundaries(inline_options_and_boundaries, chstate) for _, line in ipairs(chstate.top_line.lines) do local fn_node = line.node diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/luacheck-1.0.0/src/luacheck/stages/resolve_locals.lua new/luacheck-1.1.0/src/luacheck/stages/resolve_locals.lua --- old/luacheck-1.0.0/src/luacheck/stages/resolve_locals.lua 2022-08-24 11:50:43.000000000 +0200 +++ new/luacheck-1.1.0/src/luacheck/stages/resolve_locals.lua 2022-12-19 18:51:56.000000000 +0100 @@ -96,18 +96,18 @@ local function is_circular_reference(item, var) -- No support for matching multiple assignment to the specific assignment - if not item.lhs or #item.lhs ~= 1 or not item.rhs or #item.rhs ~= 1 then + if not (item.tag == "Set" or item.tag == "Local" or item.tag == "OpSet") then return false end -- Case t[t.function()] = t.func() -- Functions can have side-effects, so this isn't purely circular - local right_assignment = item.rhs[1] + local right_assignment = item.tag == "OpSet" and item.rhs or item.rhs[1] if contains_call(right_assignment) then return false end - local left_assignment = item.lhs[1] + local left_assignment = item.tag == "OpSet" and item.lhs or item.lhs[1] if contains_call(left_assignment) then return false end
