[Tarantool-patches] [PATCH v2] luacheck: change global vars to local in sql-tap

Sergey Bronnikov sergeyb at tarantool.org
Tue Nov 24 21:57:41 MSK 2020


Hi, Artem!

thanks for the patch! See 2 comment below.

On 20.11.2020 19:34, Artem Starshov wrote:
> Fixed luacheck warning 111 (setting non-standard global variable)
> in test/sql-tap directory.
> Enabled this directory for checking W111 in
> config file(.luacheckrc).
>
> Changed almost all variables in test/sql-tap from globals
> to locals. In any cases, where variables need to be global,
> added inline comments for luacheck.
>
> Fixes #5173
> Part-of #5464
> ---

Please don't forget to place a branch name, issue number.

I believe both are the same as in previous mail:

 >> Branch: 
https://github.com/tarantool/tarantool/tree/artemreyt/gh-5173-fix-luacheck-warnings-sql-tap 
 >> Issue: https://github.com/tarantool/tarantool/issues/5173

<snipped>

> diff --git a/.luacheckrc b/.luacheckrc
> index 2a652cd06..174bfdf25 100644
> --- a/.luacheckrc
> +++ b/.luacheckrc
> @@ -31,12 +31,67 @@ exclude_files = {
>       -- Third-party source code.
>       "src/box/lua/serpent.lua",
>       "test-run/**/*.lua",
> -    "test/**/*.lua",
> +    "test/app/**/*.lua",
> +    "test/app-tap/**/*.lua",
> +    "test/box/**/*.lua",
> +    "test/box-py/**/*.lua",
> +    "test/box-tap/**/*.lua",
> +    "test/engine/**/*.lua",
> +    "test/engine_long/**/*.lua",
> +    "test/long_run-py/**/*.lua",
> +    "test/luajit-tap/**/*.lua",
> +    "test/replication/**/*.lua",
> +    "test/replication-py/**/*.lua",
> +    "test/sql/**/*.lua",
> +    "test/swim/**/*.lua",
> +    "test/var/**/*.lua",
> +    "test/vinyl/**/*.lua",
> +    "test/wal_off/**/*.lua",
> +    "test/xlog/**/*.lua",
> +    "test/xlog-py/**/*.lua",
>       "third_party/**/*.lua",
>       ".rocks/**/*.lua",
>       ".git/**/*.lua",
>   }
>   
> +--
> +-- gh-5464: Fix luacheck warnings in test/sql-tap
> +--
1. Number of ticket that will be closed after merging this patch is 
useless here.
> +files["test/sql-tap/**/*.lua"] = {
> +    ignore = {
> +        -- Accessing an undefined global variable.
> +        "113",
> +        -- Unused local variable.
> +        "211",
> +        -- Unused argument.
> +        "212",
> +        -- Unused loop variable.
> +        "213",
> +        -- Local variable is set but never accessed.
> +        "231",
> +        -- "Value assigned to a local variable is unused."
> +        "311",
> +        -- Unreachable code.
> +        "511",
> +        -- Loop can be executed at most once.
> +        "512",
> +        -- An empty if branch.
> +        "542",
> +        -- A line consists of nothing but whitespace.
> +        "611",
> +        -- A line contains trailing whitespace.
> +        "612",
> +        -- Trailing whitespace in a string.
> +        "613",
> +        -- Trailing whitespace in a comment.
> +        "614",
> +        -- Inconsistent indentation (SPACE followed by TAB).
> +        "621",
> +        -- Line is too long.
> +        "631"
> +    }
> +}
> +
>   files["src/lua/help.lua"] = {
>       -- Globals defined for interactive mode.
>       globals = {"help", "tutorial"},
> diff --git a/test/sql-tap/aggnested.test.lua b/test/sql-tap/aggnested.test.lua
> index 67a9ba891..8a79e0df2 100755
> --- a/test/sql-tap/aggnested.test.lua
> +++ b/test/sql-tap/aggnested.test.lua
> @@ -1,5 +1,5 @@
>   #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>   test:plan(7)
>   
>   --!./tcltestrunner.lua
> diff --git a/test/sql-tap/alias.test.lua b/test/sql-tap/alias.test.lua
> index 75391b305..8181b5ed5 100755
> --- a/test/sql-tap/alias.test.lua
> +++ b/test/sql-tap/alias.test.lua
> @@ -1,5 +1,5 @@
>   #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>   test:plan(9)
>   
>   --!./tcltestrunner.lua
> @@ -24,6 +24,7 @@ test:plan(9)
>   -- A procedure to return a sequence of increasing integers.
>   --
>   
> +-- luacheck: globals counter
>   counter = 0
>   

2. In [1] I asked to place supressions on the same line with code

1. 
https://lists.tarantool.org/pipermail/tarantool-patches/2020-November/020606.html

<snipped>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20201124/d1714722/attachment.html>


More information about the Tarantool-patches mailing list