Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH v7 0/3] Fix luacheck warnings in test/box-tap, test/box and test/box-py
@ 2020-12-22 14:54 sergeyb
  2020-12-22 14:54 ` [Tarantool-patches] [PATCH 1/3] luacheck: fix warnings in test/box sergeyb
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: sergeyb @ 2020-12-22 14:54 UTC (permalink / raw)
  To: tarantool-patches, v.shpilevoy, lvasiliev; +Cc: Sergey Bronnikov

From: Sergey Bronnikov <estetus@gmail.com>

Changelog v7:
- rebased to master branch and fixed new warnings
- splitted a huge patch series for test/ to a separate issues and patches series
  (other patches will follow)

Changelog v6:

- splitted patch in test/ for patches per sub-directory
- adjusted supressions in .luacheckrc
- fixed formatting issues in .luacheckrc
- fixed warnings in test/vinyl/vinyl.lua and test/vinyl/large.lua
- added commit with bumping luajit version
- fixed warnings in test/app-tap/lua/serializer_test.lua

NOTE: most luacheck patches includes changes in .luacheckrc so branch with
patches from this patch series includes uncommitted (but with one LGTM) patches
for test/app and test/app-tap (ligurio/gh-5453-luacheck-warnings-test-app-tap).

1. https://lists.tarantool.org/pipermail/tarantool-patches/2020-December/021385.html 

Gitlab CI: https://gitlab.com/tarantool/tarantool/-/pipelines/233332402
GH branch: ligurio/gh-5455-luacheck-warnings-test-box
GH issues:
  - https://github.com/tarantool/tarantool/issues/5455
  - https://github.com/tarantool/tarantool/issues/5456 
  - https://github.com/tarantool/tarantool/issues/5457

Sergey Bronnikov (3):
  luacheck: fix warnings in test/box
  luacheck: fix warnings in test/box-py
  luacheck: fix warnings in test/box-tap

 .luacheckrc                                   | 80 ++++++++++++++++++-
 test/box-py/box.lua                           |  2 +-
 test/box-tap/auth.test.lua                    | 20 ++---
 test/box-tap/cfg.test.lua                     | 34 ++++----
 test/box-tap/cfgup.test.lua                   |  4 +-
 test/box-tap/extended_error.test.lua          | 11 +--
 test/box-tap/feedback_daemon.test.lua         |  8 +-
 test/box-tap/gc.test.lua                      |  4 +-
 test/box-tap/gh-4688-box-info-memory.test.lua |  2 +-
 test/box-tap/on_schema_init.test.lua          |  4 +-
 test/box-tap/schema_mt.test.lua               | 22 ++---
 test/box-tap/session.storage.test.lua         | 10 +--
 test/box-tap/session.test.lua                 | 56 ++++++-------
 test/box-tap/trigger_atexit.test.lua          | 10 +--
 test/box-tap/trigger_yield.test.lua           | 10 +--
 test/box/box.lua                              |  4 +-
 test/box/lua/bitset.lua                       |  7 +-
 test/box/lua/cfg_bad_vinyl_dir.lua            |  2 +-
 test/box/lua/cfg_rtree.lua                    |  2 +-
 test/box/lua/cfg_test1.lua                    |  2 +-
 test/box/lua/cfg_test2.lua                    |  2 +-
 test/box/lua/cfg_test3.lua                    |  2 +-
 test/box/lua/cfg_test4.lua                    |  2 +-
 test/box/lua/cfg_test5.lua                    |  2 +-
 test/box/lua/cfg_test6.lua                    |  2 +-
 test/box/lua/cfg_test8.lua                    |  2 +-
 test/box/lua/fifo.lua                         |  2 +-
 test/box/lua/identifier.lua                   |  9 +--
 test/box/lua/index_random_test.lua            |  2 +-
 test/box/lua/txn_proxy.lua                    |  6 +-
 test/box/lua/utils.lua                        | 10 +--
 test/box/on_schema_init.lua                   |  8 +-
 test/box/proxy.lua                            |  2 +-
 test/box/tiny.lua                             |  2 +-
 34 files changed, 202 insertions(+), 145 deletions(-)

-- 
2.25.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Tarantool-patches] [PATCH 1/3] luacheck: fix warnings in test/box
  2020-12-22 14:54 [Tarantool-patches] [PATCH v7 0/3] Fix luacheck warnings in test/box-tap, test/box and test/box-py sergeyb
@ 2020-12-22 14:54 ` sergeyb
  2021-01-11 17:52   ` Vladislav Shpilevoy via Tarantool-patches
  2020-12-22 14:54 ` [Tarantool-patches] [PATCH v7 2/3] luacheck: fix warnings in test/box-py sergeyb
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: sergeyb @ 2020-12-22 14:54 UTC (permalink / raw)
  To: tarantool-patches, v.shpilevoy, lvasiliev

From: Sergey Bronnikov <sergeyb@tarantool.org>

Closes #5455

Reviewed-by: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Reviewed-by: Igor Munkin <imun@tarantool.org>

Co-authored-by: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Co-authored-by: Igor Munkin <imun@tarantool.org>
---
 .luacheckrc                        | 58 +++++++++++++++++++++++++++++-
 test/box/box.lua                   |  4 +--
 test/box/lua/bitset.lua            |  7 ++--
 test/box/lua/cfg_bad_vinyl_dir.lua |  2 +-
 test/box/lua/cfg_rtree.lua         |  2 +-
 test/box/lua/cfg_test1.lua         |  2 +-
 test/box/lua/cfg_test2.lua         |  2 +-
 test/box/lua/cfg_test3.lua         |  2 +-
 test/box/lua/cfg_test4.lua         |  2 +-
 test/box/lua/cfg_test5.lua         |  2 +-
 test/box/lua/cfg_test6.lua         |  2 +-
 test/box/lua/cfg_test8.lua         |  2 +-
 test/box/lua/fifo.lua              |  2 +-
 test/box/lua/identifier.lua        |  9 +++--
 test/box/lua/index_random_test.lua |  2 +-
 test/box/lua/txn_proxy.lua         |  6 ++--
 test/box/lua/utils.lua             | 10 +++---
 test/box/on_schema_init.lua        |  8 ++---
 test/box/proxy.lua                 |  2 +-
 test/box/tiny.lua                  |  2 +-
 20 files changed, 89 insertions(+), 39 deletions(-)

diff --git a/.luacheckrc b/.luacheckrc
index 4b829f3dc..17cff8671 100644
--- a/.luacheckrc
+++ b/.luacheckrc
@@ -32,7 +32,13 @@ exclude_files = {
     "build/**/*.lua",
     "test-run/**/*.lua",
     "test/app/*.test.lua",
-    "test/box/**/*.lua",
+    "test/box/*.test.lua",
+    -- Unused source file, to be dropped (gh-5169).
+    "test/box/lua/require_init.lua",
+    -- Unused source file, to be dropped (gh-5169).
+    "test/box/lua/require_mod.lua",
+    -- Unused source file, to be dropped (gh-5169).
+    "test/box/lua/test_init.lua",
     "test/box-py/**/*.lua",
     "test/box-tap/**/*.lua",
     "test/engine/**/*.lua",
@@ -102,3 +108,53 @@ files["src/box/lua/console.lua"] = {
         "212",
     }
 }
+files["test/box/box.lua"] = {
+    globals = {
+        "cfg_filter",
+        "sorted",
+        "iproto_request",
+    }
+}
+files["test/box/lua/push.lua"] = {
+    globals = {"push_collection"}
+}
+files["test/box/lua/index_random_test.lua"] = {
+    globals = {"index_random_test"}
+}
+files["test/box/lua/utils.lua"] = {
+    globals = {
+        "arithmetic",
+        "check_space",
+        "create_iterator",
+        "iterate",
+        "setmap",
+        "sort",
+        "space_field_types",
+        "space_bsize",
+        "table_generate",
+        "table_shuffle",
+        "tuple_to_string",
+    }
+}
+files["test/box/lua/bitset.lua"] = {
+    globals = {
+        "clear",
+        "create_space",
+        "delete",
+        "drop_space",
+        "dump",
+        "fill",
+        "test_insert_delete",
+    }
+}
+files["test/box/lua/fifo.lua"] = {
+    globals = {
+        "fifomax",
+        "fifo_push",
+        "fifo_top",
+        "find_or_create_fifo",
+    }
+}
+files["test/box/lua/identifier.lua"] = {
+     globals = {"run_test"}
+}
diff --git a/test/box/box.lua b/test/box/box.lua
index 44d82ff0a..567583533 100644
--- a/test/box/box.lua
+++ b/test/box/box.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
 
 local msgpack = require('msgpack')
 
@@ -20,7 +20,7 @@ local _hide = {
 
 function cfg_filter(data)
     if type(data)~='table' then return data end
-    local keys,k,_ = {}
+    local keys = {}
     for k in pairs(data) do
         table.insert(keys, k)
     end
diff --git a/test/box/lua/bitset.lua b/test/box/lua/bitset.lua
index 41d2c3681..948bf3710 100644
--- a/test/box/lua/bitset.lua
+++ b/test/box/lua/bitset.lua
@@ -1,8 +1,5 @@
 local utils = require('utils')
 
-local SPACE_NO = 0 
-local INDEX_NO = 1
-
 function create_space()
     local space = box.schema.create_space('tweedledum')
     space:create_index('primary', { type = 'hash', parts = {1, 'unsigned'}, unique = true })
@@ -13,7 +10,7 @@ function fill(...)
     local space = box.space['tweedledum']
     local nums = utils.table_generate(utils.arithmetic(...))
     utils.table_shuffle(nums)
-    for _k, v in ipairs(nums) do
+    for _, v in ipairs(nums) do
         space:insert{v, v}
     end
 end
@@ -22,7 +19,7 @@ function delete(...)
     local space = box.space['tweedledum']
     local nums = utils.table_generate(utils.arithmetic(...))
     utils.table_shuffle(nums)
-    for _k, v in ipairs(nums) do
+    for _, v in ipairs(nums) do
         space:delete{v}
     end
 end
diff --git a/test/box/lua/cfg_bad_vinyl_dir.lua b/test/box/lua/cfg_bad_vinyl_dir.lua
index 8e1a98dc8..82746b99a 100644
--- a/test/box/lua/cfg_bad_vinyl_dir.lua
+++ b/test/box/lua/cfg_bad_vinyl_dir.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
 
 box.cfg{
     listen              = os.getenv("LISTEN"),
diff --git a/test/box/lua/cfg_rtree.lua b/test/box/lua/cfg_rtree.lua
index f2d32ef7d..860cb14a8 100644
--- a/test/box/lua/cfg_rtree.lua
+++ b/test/box/lua/cfg_rtree.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
 box.error.injection.set("ERRINJ_INDEX_RESERVE", true)
 box.cfg{
     listen              = os.getenv("LISTEN"),
diff --git a/test/box/lua/cfg_test1.lua b/test/box/lua/cfg_test1.lua
index 60b7aff9a..aa026ed42 100644
--- a/test/box/lua/cfg_test1.lua
+++ b/test/box/lua/cfg_test1.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
 
 box.cfg{
     listen              = os.getenv("LISTEN"),
diff --git a/test/box/lua/cfg_test2.lua b/test/box/lua/cfg_test2.lua
index 2397f9c19..536661698 100644
--- a/test/box/lua/cfg_test2.lua
+++ b/test/box/lua/cfg_test2.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
 
 box.cfg{
     listen              = os.getenv("LISTEN"),
diff --git a/test/box/lua/cfg_test3.lua b/test/box/lua/cfg_test3.lua
index 6a6e544b6..4978900fb 100644
--- a/test/box/lua/cfg_test3.lua
+++ b/test/box/lua/cfg_test3.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
 
 box.cfg{
     listen              = os.getenv("LISTEN"),
diff --git a/test/box/lua/cfg_test4.lua b/test/box/lua/cfg_test4.lua
index 82dab8757..21a38f95c 100644
--- a/test/box/lua/cfg_test4.lua
+++ b/test/box/lua/cfg_test4.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
 
 box.cfg{
     listen              = os.getenv("LISTEN"),
diff --git a/test/box/lua/cfg_test5.lua b/test/box/lua/cfg_test5.lua
index e3eb87392..d462c3bbc 100644
--- a/test/box/lua/cfg_test5.lua
+++ b/test/box/lua/cfg_test5.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
 
 box.cfg{
     listen              = os.getenv("LISTEN"),
diff --git a/test/box/lua/cfg_test6.lua b/test/box/lua/cfg_test6.lua
index efcfc6f3e..0a5859bc5 100644
--- a/test/box/lua/cfg_test6.lua
+++ b/test/box/lua/cfg_test6.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
 
 box.cfg{
     listen = os.getenv("LISTEN"),
diff --git a/test/box/lua/cfg_test8.lua b/test/box/lua/cfg_test8.lua
index c61b86ae3..edc666ea9 100644
--- a/test/box/lua/cfg_test8.lua
+++ b/test/box/lua/cfg_test8.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
 
 box.cfg{
     listen = os.getenv("LISTEN"),
diff --git a/test/box/lua/fifo.lua b/test/box/lua/fifo.lua
index bb3446179..c9216cfde 100644
--- a/test/box/lua/fifo.lua
+++ b/test/box/lua/fifo.lua
@@ -4,7 +4,7 @@ function find_or_create_fifo(space, name)
     local fifo = space:get{name}
     if fifo == nil then
         fifo = {}
-        for i = 1, fifomax do table.insert(fifo, 0) end
+        for _ = 1, fifomax do table.insert(fifo, 0) end
         fifo = space:insert{name, 4, 4, unpack(fifo)}
     end
     return fifo
diff --git a/test/box/lua/identifier.lua b/test/box/lua/identifier.lua
index 0cfb9e722..3103239ad 100644
--- a/test/box/lua/identifier.lua
+++ b/test/box/lua/identifier.lua
@@ -1,6 +1,6 @@
-max_len_string = string.rep('a', box.schema.NAME_MAX)
+local max_len_string = string.rep('a', box.schema.NAME_MAX)
 
-valid_testcases = {
+local valid_testcases = {
     --[[ Symbols from various unicode groups ,, --]]
     "1", "_", "sd", "я", "Ё",
     ".", "@", "#" , "⁋", "☢",
@@ -13,7 +13,7 @@ valid_testcases = {
     "⧭", "⭓", max_len_string
 }
 
-invalid_testcases = {
+local invalid_testcases = {
     --[[ Invalid and non printable unicode sequences --]]
     --[[ 1-3 ASCII control, C0 --]]
     "\x01", "\x09", "\x1f",
@@ -35,7 +35,6 @@ invalid_testcases = {
 }
 
 function run_test(create_func, cleanup_func)
-    local json = require("json")
     local bad_tests = {}
     for i, identifier in ipairs(valid_testcases) do
         local ok, res = pcall(create_func,identifier)
@@ -48,7 +47,7 @@ function run_test(create_func, cleanup_func)
         end
     end
     for i, identifier in ipairs(invalid_testcases) do
-        local ok, res = pcall(create_func,identifier)
+        local ok = pcall(create_func,identifier)
         if ok then
             table.insert(bad_tests, "invalid_testcases: "..i)
         end
diff --git a/test/box/lua/index_random_test.lua b/test/box/lua/index_random_test.lua
index 7b5256a7c..83e230216 100644
--- a/test/box/lua/index_random_test.lua
+++ b/test/box/lua/index_random_test.lua
@@ -7,7 +7,7 @@ function index_random_test(space, index_no)
 	-- insert values into the index
 	for k=1,COUNT,1 do space:insert{k}  end
 	-- delete some values from the index
-	for i=1,COUNT/2,1 do
+	for _=1,COUNT/2,1 do
 		local k = math.random(COUNT)
 		local tuple = space:delete{k}
 		if tuple ~= nil then COUNT = COUNT - 1 end
diff --git a/test/box/lua/txn_proxy.lua b/test/box/lua/txn_proxy.lua
index 7a4d0b865..15b0e4add 100644
--- a/test/box/lua/txn_proxy.lua
+++ b/test/box/lua/txn_proxy.lua
@@ -1,11 +1,11 @@
--- A fiber can't use multiple transactions simultaneously;  
+-- A fiber can't use multiple transactions simultaneously;
 -- i.e. [fiber] --? [transaction] in UML parlor.
 --
 -- This module provides a simple transaction proxy facility
--- to control multiple transactions at once. A proxy executes 
+-- to control multiple transactions at once. A proxy executes
 -- statements in a worker fiber in order to overcome
 -- "one transaction per fiber" limitation.
--- 
+--
 -- Ex:
 -- proxy = require('txn_proxy').new()
 -- proxy:begin()
diff --git a/test/box/lua/utils.lua b/test/box/lua/utils.lua
index 5f859fd19..a6185fbd0 100644
--- a/test/box/lua/utils.lua
+++ b/test/box/lua/utils.lua
@@ -22,8 +22,7 @@ function iterate(space_no, index_no, f1, f2, iterator, ...)
 			return f
 		end
 	end
-	local state, v
-	for state, v in box.space[space_no].index[index_no]:pairs({...}, { iterator = iterator }) do
+	for _, v in box.space[space_no].index[index_no]:pairs({...}, { iterator = iterator }) do
 		local pk = get_field(v, 1);
 		local tk = '$';
 		for f = f1 + 1, f2, 1 do tk = (tk..(get_field(v, f))..'$'); end;
@@ -90,7 +89,7 @@ end;
 
 -- return string tuple
 function tuple_to_string(tuple, yaml)
-    ans = '['
+    local ans = '['
     for i = 0, #tuple - 1 do
         if #i == 4 then
             ans = ans..i
@@ -208,14 +207,13 @@ function create_iterator(obj, key, opts)
     local iter, key, state = obj:pairs(key, opts)
     local res = {iter = iter, key = key, state = state}
     res.next = function()
-        local st, tp = iter.gen(key, state)
+        local _, tp = iter.gen(key, state)
         return tp
     end
     res.iterate_over = function()
-        local tp = nil
         local ret = {}
         local i = 0
-        tp = res.next()
+        local tp = res.next()
         while tp do
             ret[i] = tp
             i = i + 1
diff --git a/test/box/on_schema_init.lua b/test/box/on_schema_init.lua
index 17cf89166..a10687a09 100644
--- a/test/box/on_schema_init.lua
+++ b/test/box/on_schema_init.lua
@@ -1,12 +1,12 @@
 #!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
 
-function test_before_replace_trig(old, new)
+local function test_before_replace_trig(old, new) -- luacheck: no unused args
     -- return multiple values so that the stack fills earlier.
     return new:update{{'+', 2, 1}}, new:update{{'+', 2, 1}}, new:update{{'+', 2, 1}}, new:update{{'+', 2, 1}}
 end
 
-function space_on_replace_trig(old, new)
+local function space_on_replace_trig(old, new) -- luacheck: no unused args
     if new and new[3] == 'test_on_schema_init' then
         box.on_commit(function()
             box.space.test_on_schema_init:before_replace(test_before_replace_trig)
@@ -14,7 +14,7 @@ function space_on_replace_trig(old, new)
     end
 end
 
-function on_init_trig()
+local function on_init_trig()
     box.space._space:on_replace(space_on_replace_trig)
 end
 
diff --git a/test/box/proxy.lua b/test/box/proxy.lua
index 8bbd505f8..c763e9634 100644
--- a/test/box/proxy.lua
+++ b/test/box/proxy.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
 
 box.cfg{
     listen              = os.getenv("LISTEN"),
diff --git a/test/box/tiny.lua b/test/box/tiny.lua
index 04b523fb2..608d48366 100644
--- a/test/box/tiny.lua
+++ b/test/box/tiny.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
 
 box.cfg{
     listen              = os.getenv("LISTEN"),
-- 
2.25.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Tarantool-patches] [PATCH v7 2/3] luacheck: fix warnings in test/box-py
  2020-12-22 14:54 [Tarantool-patches] [PATCH v7 0/3] Fix luacheck warnings in test/box-tap, test/box and test/box-py sergeyb
  2020-12-22 14:54 ` [Tarantool-patches] [PATCH 1/3] luacheck: fix warnings in test/box sergeyb
@ 2020-12-22 14:54 ` sergeyb
  2020-12-22 14:54 ` [Tarantool-patches] [PATCH v7 3/3] luacheck: fix warnings in test/box-tap sergeyb
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 18+ messages in thread
From: sergeyb @ 2020-12-22 14:54 UTC (permalink / raw)
  To: tarantool-patches, v.shpilevoy, lvasiliev

From: Sergey Bronnikov <sergeyb@tarantool.org>

Closes #5456

Reviewed-by: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Reviewed-by: Igor Munkin <imun@tarantool.org>

Co-authored-by: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Co-authored-by: Igor Munkin <imun@tarantool.org>
---
 .luacheckrc         | 1 -
 test/box-py/box.lua | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/.luacheckrc b/.luacheckrc
index 17cff8671..52625bb35 100644
--- a/.luacheckrc
+++ b/.luacheckrc
@@ -39,7 +39,6 @@ exclude_files = {
     "test/box/lua/require_mod.lua",
     -- Unused source file, to be dropped (gh-5169).
     "test/box/lua/test_init.lua",
-    "test/box-py/**/*.lua",
     "test/box-tap/**/*.lua",
     "test/engine/**/*.lua",
     "test/engine_long/**/*.lua",
diff --git a/test/box-py/box.lua b/test/box-py/box.lua
index e9403774c..35a087de9 100644
--- a/test/box-py/box.lua
+++ b/test/box-py/box.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
 
 box.cfg{
     listen              = os.getenv("LISTEN"),
-- 
2.25.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Tarantool-patches] [PATCH v7 3/3] luacheck: fix warnings in test/box-tap
  2020-12-22 14:54 [Tarantool-patches] [PATCH v7 0/3] Fix luacheck warnings in test/box-tap, test/box and test/box-py sergeyb
  2020-12-22 14:54 ` [Tarantool-patches] [PATCH 1/3] luacheck: fix warnings in test/box sergeyb
  2020-12-22 14:54 ` [Tarantool-patches] [PATCH v7 2/3] luacheck: fix warnings in test/box-py sergeyb
@ 2020-12-22 14:54 ` sergeyb
  2021-01-11 17:52   ` Vladislav Shpilevoy via Tarantool-patches
  2020-12-25 10:37 ` [Tarantool-patches] [PATCH v7 0/3] Fix luacheck warnings in test/box-tap, test/box and test/box-py Kirill Yukhin
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: sergeyb @ 2020-12-22 14:54 UTC (permalink / raw)
  To: tarantool-patches, v.shpilevoy, lvasiliev

From: Sergey Bronnikov <sergeyb@tarantool.org>

Closes #5457

Reviewed-by: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Reviewed-by: Igor Munkin <imun@tarantool.org>

Co-authored-by: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Co-authored-by: Igor Munkin <imun@tarantool.org>
---
 .luacheckrc                                   | 21 ++++++-
 test/box-tap/auth.test.lua                    | 20 ++-----
 test/box-tap/cfg.test.lua                     | 34 +++++------
 test/box-tap/cfgup.test.lua                   |  4 +-
 test/box-tap/extended_error.test.lua          | 11 ++--
 test/box-tap/feedback_daemon.test.lua         |  8 +--
 test/box-tap/gc.test.lua                      |  4 +-
 test/box-tap/gh-4688-box-info-memory.test.lua |  2 +-
 test/box-tap/on_schema_init.test.lua          |  4 +-
 test/box-tap/schema_mt.test.lua               | 22 ++++----
 test/box-tap/session.storage.test.lua         | 10 ++--
 test/box-tap/session.test.lua                 | 56 +++++++++----------
 test/box-tap/trigger_atexit.test.lua          | 10 ++--
 test/box-tap/trigger_yield.test.lua           | 10 ++--
 14 files changed, 112 insertions(+), 104 deletions(-)

diff --git a/.luacheckrc b/.luacheckrc
index 52625bb35..b7f9abb45 100644
--- a/.luacheckrc
+++ b/.luacheckrc
@@ -39,7 +39,6 @@ exclude_files = {
     "test/box/lua/require_mod.lua",
     -- Unused source file, to be dropped (gh-5169).
     "test/box/lua/test_init.lua",
-    "test/box-tap/**/*.lua",
     "test/engine/**/*.lua",
     "test/engine_long/**/*.lua",
     "test/long_run-py/**/*.lua",
@@ -157,3 +156,23 @@ files["test/box/lua/fifo.lua"] = {
 files["test/box/lua/identifier.lua"] = {
      globals = {"run_test"}
 }
+files["test/box-tap/session.test.lua"] = {
+    globals = {
+        "active_connections",
+        "session",
+        "space",
+        "f1",
+        "f2",
+    },
+}
+files["test/box-tap/extended_error.test.lua"] = {
+    globals = {
+        "error_access_denied",
+        "error_new",
+        "error_new_stacked",
+        "error_throw",
+        "error_throw_stacked",
+        "error_throw_access_denied",
+        "forbidden_function",
+    },
+}
diff --git a/test/box-tap/auth.test.lua b/test/box-tap/auth.test.lua
index 4e9879408..c6de6ff82 100755
--- a/test/box-tap/auth.test.lua
+++ b/test/box-tap/auth.test.lua
@@ -18,22 +18,22 @@ local test = tap.test("auth")
 test:plan(42)
 
 local space = box.schema.space.create('tweedledum')
-local index = space:create_index('primary', { type = 'hash' })
+space:create_index('primary', { type = 'hash' })
 box.schema.user.create('test', {password='pass'})
 box.schema.user.create('test2', {password=''})
 
 -- check how authentication trigger work
 local msg, counter, succeeded
-function auth_trigger(user_name)
+local function auth_trigger(user_name) -- luacheck: no unused args
     counter = counter + 1
 end
 -- get user name as argument
-function auth_trigger2(user_name)
+local function auth_trigger2(user_name) -- luacheck: no unused args
     msg = 'user ' .. user_name .. ' is there'
 end
 -- get user name and result of authentication as arguments
-function auth_trigger3(user_name, success)
-        succeeded = success
+local function auth_trigger3(user_name, success) -- luacheck: no unused args
+    succeeded = success
 end
 -- set trigger
 local handle = session.on_auth(auth_trigger)
@@ -57,7 +57,6 @@ test:is(counter, 1, "on_auth has been fired once")
 test:is(msg, "user test is there", "on_auth username param")
 test:ok(succeeded, "on_auth success param")
 conn:close()
-conn = nil
 
 -- check failing authentication
 counter = 0
@@ -68,7 +67,6 @@ test:is(counter, 1, "on_auth has been fired once")
 test:is(msg, "user test is there", "on_auth username param")
 test:ok(not succeeded, "on_auth success param")
 conn:close()
-conn = nil
 
 counter = 0
 succeeded = false
@@ -78,7 +76,6 @@ test:is(counter, 1, "on_auth has been fired once")
 test:is(msg, "user test2 is there", "on_auth username param")
 test:ok(succeeded, "on_auth success param")
 conn:close()
-conn = nil
 
 counter = 0
 succeeded = false
@@ -88,7 +85,6 @@ test:is(counter, 1, "on_auth has been fired once")
 test:is(msg, "user test2 is there", "on_auth username param")
 test:ok(succeeded, "on_auth success param")
 conn:close()
-conn = nil
 
 counter = 0
 succeeded = false
@@ -98,7 +94,6 @@ test:is(counter, 1, "on_auth has been fired once")
 test:is(msg, "user test2 is there", "on_auth username param")
 test:ok(succeeded, "on_auth success param")
 conn:close()
-conn = nil
 
 counter = 0
 succeeded = false
@@ -108,7 +103,6 @@ test:is(counter, 1, "on_auth has been fired once")
 test:is(msg, "user guest is there", "on_auth username param")
 test:ok(succeeded, "on_auth success param")
 conn:close()
-conn = nil
 
 counter = 0
 succeeded = false
@@ -118,7 +112,6 @@ test:is(counter, 1, "on_auth has been fired once")
 test:is(msg, "user guest is there", "on_auth username param")
 test:ok(succeeded, "on_auth success param")
 conn:close()
-conn = nil
 
 counter = 0
 succeeded = false
@@ -128,7 +121,6 @@ test:is(counter, 1, "on_auth has been fired once")
 test:is(msg, "user guest is there", "on_auth username param")
 test:ok(succeeded, "on_auth success param")
 conn:close()
-conn = nil
 
 counter = 0
 succeeded = false
@@ -138,7 +130,6 @@ test:is(counter, 1, "on_auth has been fired once")
 test:is(msg, "user guest is there", "on_auth username param")
 test:ok(succeeded, "on_auth success param")
 conn:close()
-conn = nil
 
 -- check guest connection without authentication(no increment)
 counter = 0
@@ -148,7 +139,6 @@ conn:ping()
 test:is(counter, 0, "on_auth hasn't been fired")
 test:ok(not succeeded, "on_auth not successed param")
 conn:close()
-conn = nil
 
 test:isnil(session.on_auth(nil, auth_trigger), "removal returns nil")
 test:isnil(session.on_auth(nil, auth_trigger2), "removal returns nil")
diff --git a/test/box-tap/cfg.test.lua b/test/box-tap/cfg.test.lua
index 569b5f463..a577f023d 100755
--- a/test/box-tap/cfg.test.lua
+++ b/test/box-tap/cfg.test.lua
@@ -76,14 +76,14 @@ test:ok(not status and result:match('Please call box.cfg{}'),
     'exception on unconfigured box')
 
 status, result = pcall(box.error, box.error.ILLEGAL_PARAMS, 'xx')
-test:ok(result.code == box.error.ILLEGAL_PARAMS, "box.error without box.cfg")
+test:ok(not status and result.code == box.error.ILLEGAL_PARAMS, "box.error without box.cfg")
 status, result = pcall(function() return box.runtime.info() end)
 test:ok(status and type(result) == 'table', "box.runtime without box.cfg")
 status, result = pcall(function() return box.index.EQ end)
 test:ok(status and type(result) == 'number', "box.index without box.cfg")
 status, result = pcall(function() return box.NULL end)
 test:ok(status and result == msgpack.NULL, "box.NULL without box.cfg")
-status, result = pcall(box.session.id)
+status = pcall(box.session.id)
 test:ok(status, "box.session without box.cfg")
 status, result = pcall(box.tuple.new, {1, 2, 3})
 test:ok(status and result[1] == 1, "box.tuple without box.cfg")
@@ -145,13 +145,13 @@ test:is(box.cfg.too_long_threshold , 0.1, "too_long_threshold new value")
 test:is(box.cfg.read_only, false, "read_only default value")
 box.cfg{read_only = true}
 test:is(box.cfg.read_only, true, "read_only new value")
-local status, reason = pcall(function()
+local status = pcall(function()
     box.space._schema:insert({'read_only', 'test'})
 end)
 test:ok(not status and box.error.last().code == box.error.READONLY,
     "read_only = true")
 box.cfg{read_only = false}
-local status, reason = pcall(function()
+local status = pcall(function()
     box.space._schema:insert({'read_only', 'test'})
 end)
 test:ok(status, "read_only = false")
@@ -163,7 +163,7 @@ test:is(box.cfg.worker_pool_threads, 1, 'worker_pool_threads')
 
 local tarantool_bin = arg[-1]
 local PANIC = 256
-function run_script(code)
+local function run_script(code)
     local dir = fio.tempdir()
     local script_path = fio.pathjoin(dir, 'script.lua')
     local script = fio.open(script_path, {'O_CREAT', 'O_WRONLY', 'O_APPEND'},
@@ -178,7 +178,7 @@ function run_script(code)
 end
 
 -- gh-3468: should allow box.cfg with vinyl_memory=0
-code =[[
+local code =[[
 box.cfg{vinyl_memory=0}
 os.exit(box.cfg.vinyl_memory == 0 and 0 or 1)
 ]]
@@ -198,7 +198,6 @@ code = [[ box.cfg{ wal_mode = 'write' }; box.cfg { wal_mode = 'fsync'} ]]
 test:is(run_script(code), PANIC, 'wal_mode write -> fsync is not supported')
 
 -- gh-684: Inconsistency with box.cfg and directories
-local code;
 code = [[ box.cfg{ work_dir='invalid' } ]]
 test:is(run_script(code), PANIC, 'work_dir is invalid')
 
@@ -238,7 +237,7 @@ os.remove(path)
 
 path = './tarantool.sock'
 local path2 = './tarantool2.sock'
-local s = socket.tcp_server('unix/', path, function () end)
+s = socket.tcp_server('unix/', path, function () end)
 os.execute('ln ' .. path .. ' ' .. path2)
 s:close()
 box.cfg{ listen = 'unix/:'.. path2}
@@ -270,6 +269,7 @@ test:is(run_script(code), 0, "wal_mode none and ER_LOADING")
 --
 -- gh-1962: incorrect replication source
 --
+local reason
 status, reason = pcall(box.cfg, {replication="3303,3304"})
 test:ok(not status and reason:match("Incorrect"), "invalid replication")
 
@@ -298,7 +298,7 @@ test:is(run_script(code), 0, "page size equal with range")
 code = [[
 box.cfg{slab_alloc_arena = 0.2, slab_alloc_minimal = 16,
     slab_alloc_maximal = 64 * 1024}
-os.exit(box.cfg.memtx_memory == 214748364 
+os.exit(box.cfg.memtx_memory == 214748364
     and box.cfg.memtx_min_tuple_size == 16
     and box.cfg.memtx_max_tuple_size == 64 * 1024
 and 0 or 1)
@@ -384,7 +384,7 @@ test:is(run_script(code), 0, "wal_max_size xlog rotation")
 -- gh-2872 bootstrap is aborted if vinyl_dir contains vylog files
 -- left from previous runs
 --
-vinyl_dir = fio.tempdir()
+local vinyl_dir = fio.tempdir()
 run_script(string.format([[
 box.cfg{vinyl_dir = '%s'}
 s = box.schema.space.create('test', {engine = 'vinyl'})
@@ -401,8 +401,8 @@ fio.rmtree(vinyl_dir)
 --
 -- gh-2278 vinyl does not support DDL/DML if wal_mode = 'none'
 --
-dir = fio.tempdir()
-cfg = string.format("wal_dir = '%s', memtx_dir = '%s', vinyl_dir = '%s'", dir, dir, dir)
+local dir = fio.tempdir()
+local cfg = string.format("wal_dir = '%s', memtx_dir = '%s', vinyl_dir = '%s'", dir, dir, dir)
 run_script(string.format([[
 box.cfg{%s}
 s = box.schema.space.create('test', {engine = 'vinyl'})
@@ -453,9 +453,9 @@ test:is(run_script(code), 0, "check replicaset_uuid")
 -- Configuration fails on instance or replica set UUID mismatch.
 --
 dir = fio.tempdir()
-instance_uuid = uuid.new()
-replicaset_uuid = uuid.new()
-code_fmt = [[
+local instance_uuid = uuid.new()
+local replicaset_uuid = uuid.new()
+local code_fmt = [[
 box.cfg{memtx_dir = '%s', instance_uuid = '%s', replicaset_uuid = '%s'}
 os.exit(0)
 ]]
@@ -569,14 +569,14 @@ test:is(run_script(code), 0, "log_nonblock")
 -- Crash (instead of panic) when trying to recover a huge tuple.
 --
 dir = fio.tempdir()
-code1 = string.format([[
+local code1 = string.format([[
 box.cfg{wal_dir = '%s', memtx_dir = '%s', memtx_max_tuple_size = 10 * 1024 * 1024}
 box.schema.space.create('test')
 box.space.test:create_index('primary')
 box.space.test:insert{1, string.rep('x', 1024 * 1024)}
 os.exit(0)
 ]], dir, dir)
-code2 = string.format([[
+local code2 = string.format([[
 box.cfg{wal_dir = '%s', memtx_dir = '%s', memtx_max_tuple_size = 10 * 1024}
 os.exit(0)
 ]], dir, dir)
diff --git a/test/box-tap/cfgup.test.lua b/test/box-tap/cfgup.test.lua
index 45fc12316..e699e304f 100755
--- a/test/box-tap/cfgup.test.lua
+++ b/test/box-tap/cfgup.test.lua
@@ -6,8 +6,8 @@ local tap = require('tap')
 local test = tap.test('cfg')
 test:plan(3)
 
-config = {
-	pid_file = '1.pid',
+local config = {
+    pid_file = '1.pid',
     log="tarantool.log"
 }
 
diff --git a/test/box-tap/extended_error.test.lua b/test/box-tap/extended_error.test.lua
index 884387be8..7a6152d22 100755
--- a/test/box-tap/extended_error.test.lua
+++ b/test/box-tap/extended_error.test.lua
@@ -24,7 +24,8 @@ box.schema.func.create('forbidden_function')
 box.session.su('guest')
 local tmp = box.func.forbidden_function
 local access_denied_error
-tmp, access_denied_error = pcall(tmp.call, tmp)
+local _
+_, access_denied_error = pcall(tmp.call, tmp)
 box.session.su('admin')
 box.schema.func.drop('forbidden_function')
 box.session.su(user)
@@ -85,7 +86,7 @@ local checks = {
     type = 'ClientError',
 }
 test:ok(check_error(err, checks), "ClientError marshaling")
-tmp, err = pcall(c.call, c, 'error_throw', args)
+_, err = pcall(c.call, c, 'error_throw', args)
 test:ok(check_error(err, checks), "ClientError marshaling in iproto fields")
 
 args = {{code = 1001, reason = 'Reason2', type = 'MyError'}}
@@ -97,7 +98,7 @@ checks = {
     type = 'MyError',
 }
 test:ok(check_error(err, checks), "CustomError marshaling")
-tmp, err = pcall(c.call, c, 'error_throw', args)
+_, err = pcall(c.call, c, 'error_throw', args)
 test:ok(check_error(err, checks), "CustomError marshaling in iproto fields")
 
 err = c:call('error_access_denied')
@@ -111,7 +112,7 @@ checks = {
     access_type = 'Execute',
 }
 test:ok(check_error(err, checks), "AccessDeniedError marshaling")
-tmp, err = pcall(c.call, c, 'error_throw_access_denied')
+_, err = pcall(c.call, c, 'error_throw_access_denied')
 test:ok(check_error(err, checks), "AccessDeniedError marshaling in iproto fields")
 
 args = {
@@ -137,7 +138,7 @@ local checks2 = {
 }
 test:ok(check_error(err2, checks2), "Second error in the stack")
 
-tmp, err = pcall(c.call, c, 'error_throw_stacked', args)
+_, err = pcall(c.call, c, 'error_throw_stacked', args)
 err1 = err
 err2 = err.prev
 test:isnt(err2, nil, 'Stack is received via iproto fields')
diff --git a/test/box-tap/feedback_daemon.test.lua b/test/box-tap/feedback_daemon.test.lua
index 7ebc97587..3c929132d 100755
--- a/test/box-tap/feedback_daemon.test.lua
+++ b/test/box-tap/feedback_daemon.test.lua
@@ -36,7 +36,7 @@ local function http_handle(s)
         buf = s:read('\n')
     end
     buf = s:read(length)
-    local ok, data = pcall(json.decode, buf)
+    local ok = pcall(json.decode, buf)
     if ok then
         feedback = buf
         feedback_count = feedback_count + 1
@@ -126,7 +126,7 @@ fio.unlink("feedback.json")
 
 server:close()
 -- check it does not fail without server
-local daemon = box.internal.feedback_daemon
+daemon = box.internal.feedback_daemon
 daemon.start()
 daemon.send_test()
 daemon.stop()
@@ -225,8 +225,8 @@ test:is(actual.features.schema.hash_indices, 2,
 -- collect box.cfg options: election mode, synchronous replication and tx
 -- manager.
 --
-em = box.cfg.election_mode
-quorum = box.cfg.replication_synchro_quorum
+local em = box.cfg.election_mode
+local quorum = box.cfg.replication_synchro_quorum
 box.cfg{election_mode='candidate', replication_synchro_quorum=2}
 box.on_reload_configuration = function() end
 actual = daemon.generate_feedback()
diff --git a/test/box-tap/gc.test.lua b/test/box-tap/gc.test.lua
index f88752e71..f0155779c 100755
--- a/test/box-tap/gc.test.lua
+++ b/test/box-tap/gc.test.lua
@@ -4,7 +4,7 @@ local fiber = require('fiber')
 
 box.cfg{}
 
-local debug = type(box.error.injection) == "table" 
+local debug = type(box.error.injection) == "table"
 
 -- check box.info.gc() is false if snapshot is not in progress
 local test = tap.test('box.info.gc')
@@ -19,7 +19,7 @@ test:is(gc.checkpoint_is_in_progress, false, "checkpoint is not in progress")
 if debug then
     box.error.injection.set("ERRINJ_SNAP_COMMIT_DELAY", true)
     local snapshot_f  = function()
-       box.snapshot() 
+       box.snapshot()
     end
     fiber.create(snapshot_f)
     local gc = box.info.gc()
diff --git a/test/box-tap/gh-4688-box-info-memory.test.lua b/test/box-tap/gh-4688-box-info-memory.test.lua
index 0a27741d3..991ea4177 100755
--- a/test/box-tap/gh-4688-box-info-memory.test.lua
+++ b/test/box-tap/gh-4688-box-info-memory.test.lua
@@ -12,7 +12,7 @@ test:plan(1)
 
 local function get_keys(t)
     local keys = {}
-    for k, v in pairs(t) do
+    for k, _ in pairs(t) do
         table.insert(keys, k)
     end
     return keys
diff --git a/test/box-tap/on_schema_init.test.lua b/test/box-tap/on_schema_init.test.lua
index 51b28ea08..db9ae6f27 100755
--- a/test/box-tap/on_schema_init.test.lua
+++ b/test/box-tap/on_schema_init.test.lua
@@ -8,7 +8,7 @@ local test = tap.test('on_schema_init')
 local str = ''
 test:plan(7)
 
-function testing_trig()
+local function testing_trig()
     test:istable(box.space._space, 'system spaces are accessible')
     test:is(type(box.space._space.before_replace), 'function', 'before_replace triggers')
     test:is(type(box.space._space.on_replace), 'function', 'on_replace triggers')
@@ -17,7 +17,7 @@ function testing_trig()
     str = str..'on_schema_init'
 end
 
-trig = box.ctl.on_schema_init(testing_trig)
+local trig = box.ctl.on_schema_init(testing_trig)
 test:is(type(trig), 'function', 'on_schema_init trigger set')
 
 box.cfg{log = 'tarantool.log'}
diff --git a/test/box-tap/schema_mt.test.lua b/test/box-tap/schema_mt.test.lua
index 5a635262f..c0fe5f10b 100755
--- a/test/box-tap/schema_mt.test.lua
+++ b/test/box-tap/schema_mt.test.lua
@@ -20,7 +20,7 @@ local sp1 = box.schema.create_space('test1', {engine = 'memtx'})
 local sp2 = box.schema.create_space('test2', {engine = 'vinyl'})
 test:is(getmetatable(sp1).__index, getmetatable(sp2).__index, 'spaces share metatables __index')
 
-function box.schema.space_mt.myfunc(space, args)
+function box.schema.space_mt.myfunc(space, args) -- luacheck: no unused args
   return args
 end
 test:is(sp1:myfunc(123), 123, 'space_mt can be extended')
@@ -41,13 +41,13 @@ test:isnt(getmetatable(sp1_pk).__index, getmetatable(sp2_pk).__index, 'engines d
 -- Check that there are two ways to extend index metatable:
 -- extend base index metatable, or extend engine specific.
 --
-function box.schema.index_mt.common_func(index, args)
+function box.schema.index_mt.common_func(index, args) -- luacheck: no unused args
   return args
 end
-function box.schema.vinyl_index_mt.vinyl_func(index, args)
+function box.schema.vinyl_index_mt.vinyl_func(index, args) -- luacheck: no unused args
   return args
 end
-function box.schema.memtx_index_mt.memtx_func(index, args)
+function box.schema.memtx_index_mt.memtx_func(index, args) -- luacheck: no unused args
   return args
 end
 test:is(box.schema.index_mt.common_func, box.schema.vinyl_index_mt.common_func,
@@ -77,14 +77,14 @@ test:is(sp2_sk:common_func(400), 400, 'vinyl common methods work')
 -- A space local metatable can extended so it does not affect
 -- other spaces. Same about index.
 --
-sp3 = box.schema.create_space('test3', {engine = 'memtx'})
-sp3_pk = sp3:create_index('pk')
-sp3_sk = sp3:create_index('sk')
-mt1 = getmetatable(sp1)
-mt2 = getmetatable(sp2)
+local sp3 = box.schema.create_space('test3', {engine = 'memtx'})
+local sp3_pk = sp3:create_index('pk')
+local sp3_sk = sp3:create_index('sk')
+local mt1 = getmetatable(sp1)
+local mt2 = getmetatable(sp2)
 test:isnt(mt1, mt2, 'spaces do not share metatables')
-index_mt1 = getmetatable(sp3_pk)
-index_mt2 = getmetatable(sp3_sk)
+local index_mt1 = getmetatable(sp3_pk)
+local index_mt2 = getmetatable(sp3_sk)
 test:isnt(index_mt1, index_mt2, 'indexes do not share metatables')
 
 mt1.my_func = function(a) return a end
diff --git a/test/box-tap/session.storage.test.lua b/test/box-tap/session.storage.test.lua
index 40ca9c230..d17d3efce 100755
--- a/test/box-tap/session.storage.test.lua
+++ b/test/box-tap/session.storage.test.lua
@@ -19,7 +19,7 @@ test:is(
 )
 
 local uri = inspector:eval('session_storage', 'box.cfg.listen')[1]
-conn1 = net_box.connect(uri)
+local conn1 = net_box.connect(uri)
 
 conn1:eval("session = box.session")
 test:is(conn1:eval("return type(session.id())"), "number", "session.id()")
@@ -34,7 +34,7 @@ conn1:eval("all = getmetatable(session).aggregate_storage")
 test:ok(conn1:eval("return all[session.id()].abc == 'cde'"), "check meta table")
 
 
-conn2 = net_box.connect(uri)
+local conn2 = net_box.connect(uri)
 
 test:is(conn2:eval("return type(session.storage)"), "table", "storage")
 test:isnil(conn2:eval("return type(session.storage.abc)"), "empty storage")
@@ -45,12 +45,12 @@ test:ok(conn1:eval("return session.storage.abc == 'cde'"), "first conn storage")
 test:ok(conn1:eval("return all[session.id()].abc == 'cde'"), "check first conn metatable")
 test:ok(conn2:eval("return all[session.id()].abc == 'def'"), "check second conn metatable")
 
-tres1 = conn1:eval("t1 = {} for k, v in pairs(all) do table.insert(t1, v.abc) end return t1")
+local tres1 = conn1:eval("t1 = {} for k, v in pairs(all) do table.insert(t1, v.abc) end return t1")
 
 conn1:close()
 conn2:close()
-conn3 = net_box.connect(uri)
-tres2 = conn3:eval("t2 = {} for k, v in pairs(all) do table.insert(t2, v.abc) end return t2")
+local conn3 = net_box.connect(uri)
+local tres2 = conn3:eval("t2 = {} for k, v in pairs(all) do table.insert(t2, v.abc) end return t2")
 table.sort(tres1)
 table.sort(tres2)
 test:is(tres1[1], "cde", "check after closing")
diff --git a/test/box-tap/session.test.lua b/test/box-tap/session.test.lua
index 5d4965533..160f047bc 100755
--- a/test/box-tap/session.test.lua
+++ b/test/box-tap/session.test.lua
@@ -13,7 +13,7 @@ local uri = require('uri').parse(box.cfg.listen)
 local HOST, PORT = uri.host or 'localhost', uri.service
 session = box.session
 space = box.schema.space.create('tweedledum')
-index = space:create_index('primary', { type = 'hash' })
+space:create_index('primary', { type = 'hash' })
 
 test:plan(56)
 
@@ -23,25 +23,25 @@ test:plan(56)
 test:ok(session.exists(session.id()), "session is created")
 test:isnil(session.peer(session.id()), "session.peer")
 test:ok(session.exists(), "session.exists")
-ok, err = pcall(session.exists, 1, 2, 3)
+local _, err = pcall(session.exists, 1, 2, 3)
 test:is(err, "session.exists(sid): bad arguments", "exists bad args #2")
 test:ok(not session.exists(1234567890), "session doesn't exist")
 
 -- check session.id()
 test:ok(session.id() > 0, "id > 0")
-failed = false
+local failed = false
 local f = fiber.create(function() failed = session.id() == 0 end)
 while f:status() ~= 'dead' do fiber.sleep(0) end
 test:ok(not failed, "session not broken")
 test:is(session.peer(), session.peer(session.id()), "peer() == peer(id())")
 
 -- check on_connect/on_disconnect triggers
-function noop() end
+local function noop() end
 test:is(type(session.on_connect(noop)), "function", "type of trigger noop on_connect")
 test:is(type(session.on_disconnect(noop)), "function", "type of trigger noop on_disconnect")
 
 -- check it's possible to reset these triggers
-function fail() error('hear') end
+local function fail() error('hear') end
 test:is(type(session.on_connect(fail, noop)), "function", "type of trigger fail, noop on_connect")
 test:is(type(session.on_disconnect(fail, noop)), "function", "type of trigger fail, noop on_disconnect")
 
@@ -49,19 +49,19 @@ test:is(type(session.on_disconnect(fail, noop)), "function", "type of trigger fa
 test:is(type(session.on_connect()), "table", "type of trigger on_connect, no args")
 test:is(type(session.on_disconnect()), "table", "type of trigger on_disconnect, no args")
 
-ok, err = pcall(session.on_connect, function() end, function() end)
+_, err = pcall(session.on_connect, function() end, function() end)
 test:is(err,"trigger reset: Trigger is not found", "on_connect trigger not found")
-ok, err = pcall(session.on_disconnect, function() end, function() end)
+_, err = pcall(session.on_disconnect, function() end, function() end)
 test:is(err,"trigger reset: Trigger is not found", "on_disconnect trigger not found")
 
-ok, err = pcall(session.on_connect, 1, 2)
+_, err = pcall(session.on_connect, 1, 2)
 test:is(err, "trigger reset: incorrect arguments", "on_connect bad args #1")
-ok, err = pcall(session.on_disconnect, 1, 2)
+_, err = pcall(session.on_disconnect, 1, 2)
 test:is(err, "trigger reset: incorrect arguments", "on_disconnect bad args #1")
 
-ok, err = pcall(session.on_connect, 1)
+_, err = pcall(session.on_connect, 1)
 test:is(err, "trigger reset: incorrect arguments", "on_connect bad args #2")
-ok, err = pcall(session.on_disconnect, 1)
+_, err = pcall(session.on_disconnect, 1)
 test:is(err, "trigger reset: incorrect arguments", "on_disconnect bad args #2")
 
 -- use of nil to clear the trigger
@@ -70,18 +70,18 @@ session.on_disconnect(nil, fail)
 
 -- check how connect/disconnect triggers work
 local peer_name = "peer_name"
-function inc() active_connections = active_connections + 1 end
-function dec() active_connections = active_connections - 1 end
-function peer() peer_name = box.session.peer() end
-net = { box = require('net.box') }
+local function inc() active_connections = active_connections + 1 end
+local function dec() active_connections = active_connections - 1 end
+local function peer() peer_name = box.session.peer() end
+local net = { box = require('net.box') }
 test:is(type(session.on_connect(inc)), "function", "type of trigger inc on_connect")
 test:is(type(session.on_disconnect(dec)), "function", "type of trigger dec on_disconnect")
 test:is(type(session.on_disconnect(peer)), "function", "type of trigger peer on_disconnect")
 active_connections = 0
-c = net.box.connect(HOST, PORT)
+local c = net.box.connect(HOST, PORT)
 while active_connections < 1 do fiber.sleep(0.001) end
 test:is(active_connections, 1, "active_connections after 1 connection")
-c1 = net.box.connect(HOST, PORT)
+local c1 = net.box.connect(HOST, PORT)
 while active_connections < 2 do fiber.sleep(0.001) end
 test:is(active_connections, 2, "active_connections after 2 connection")
 c:close()
@@ -95,14 +95,14 @@ session.on_disconnect(nil, dec)
 session.on_disconnect(nil, peer)
 
 -- write audit trail of connect/disconnect into a space
-function audit_connect() box.space['tweedledum']:insert{session.id()} end
-function audit_disconnect() box.space['tweedledum']:delete{session.id()} end
+local function audit_connect() box.space['tweedledum']:insert{session.id()} end
+local function audit_disconnect() box.space['tweedledum']:delete{session.id()} end
 test:is(type(session.on_connect(audit_connect)), "function", "type of trigger audit_connect on_connect")
 test:is(type(session.on_disconnect(audit_disconnect)), "function", "type of trigger audit_connect on_disconnect")
 
 box.schema.user.grant('guest', 'read,write', 'space', 'tweedledum')
 box.schema.user.grant('guest', 'execute', 'universe')
-a = net.box.connect(HOST, PORT)
+local a = net.box.connect(HOST, PORT)
 test:ok(a:eval('return space:get{box.session.id()}[1] == session.id()'), "eval get_id")
 test:ok(a:eval('return session.sync() ~= 0'), "eval sync")
 a:close()
@@ -122,15 +122,15 @@ box.schema.user.revoke('guest', 'execute', 'universe')
 -- audit permission in on_connect/on_disconnect triggers
 box.schema.user.create('tester', { password = 'tester' })
 
-on_connect_user = nil
-on_disconnect_user = nil
-function on_connect() on_connect_user = box.session.effective_user() end
-function on_disconnect() on_disconnect_user = box.session.effective_user() end
+local on_connect_user = nil
+local on_disconnect_user = nil
+local function on_connect() on_connect_user = box.session.effective_user() end
+local function on_disconnect() on_disconnect_user = box.session.effective_user() end
 _ = box.session.on_connect(on_connect)
 _ = box.session.on_disconnect(on_disconnect)
 local conn = require('net.box').connect("tester:tester@" ..HOST..':'..PORT)
 -- Triggers must not lead to privilege escalation
-ok, err = pcall(function () conn:eval('box.space._user:select()') end)
+local ok = pcall(function () conn:eval('box.space._user:select()') end)
 test:ok(not ok, "check access")
 conn:close()
 conn = nil
@@ -143,13 +143,13 @@ box.session.on_connect(nil, on_connect)
 box.session.on_disconnect(nil, on_disconnect)
 
 -- check Session privilege
-ok, err = pcall(function() net.box.connect("tester:tester@" ..HOST..':'..PORT) end)
+ok = pcall(function() net.box.connect("tester:tester@" ..HOST..':'..PORT) end)
 test:ok(ok, "session privilege")
 box.schema.user.revoke('tester', 'session', 'universe')
 conn = net.box.connect("tester:tester@" ..HOST..':'..PORT)
 test:is(conn.state, "error", "session privilege state")
 test:ok(conn.error:match("Session"), "sesssion privilege errmsg")
-ok, err = pcall(box.session.su, "user1")
+ok = pcall(box.session.su, "user1")
 test:ok(not ok, "session.su on revoked")
 box.schema.user.drop('tester')
 
@@ -187,7 +187,7 @@ conn:close()
 --
 -- gh-3450: box.session.sync() becomes request local.
 --
-cond = fiber.cond()
+local cond = fiber.cond()
 local sync1, sync2
 local started = 0
 function f1()
diff --git a/test/box-tap/trigger_atexit.test.lua b/test/box-tap/trigger_atexit.test.lua
index 59b47aa6a..8baa868c4 100755
--- a/test/box-tap/trigger_atexit.test.lua
+++ b/test/box-tap/trigger_atexit.test.lua
@@ -3,11 +3,9 @@
 
 -- see https://github.com/tarantool/tarantool/issues/583
 
-tap = require 'tap'
-fio = require 'fio'
-log = require 'log'
+local fio = require 'fio'
 
-tempdir = fio.tempdir()
+local tempdir = fio.tempdir()
 
 box.cfg {
     wal_dir = tempdir,
@@ -17,7 +15,7 @@ box.cfg {
     memtx_memory = 104857600 -- for small systems
 }
 
-local function test_replace(old_tuple, new_tuple)
+local function test_replace()
 
 end
 
@@ -27,7 +25,7 @@ box.space.abc:create_index('pk', { type = 'tree' })
 box.space.abc:on_replace(test_replace)
 
 
-cleanup_list = fio.glob(fio.pathjoin(tempdir, '*'))
+local cleanup_list = fio.glob(fio.pathjoin(tempdir, '*'))
 for _, file in pairs(cleanup_list) do
     fio.unlink(file)
 end
diff --git a/test/box-tap/trigger_yield.test.lua b/test/box-tap/trigger_yield.test.lua
index 5d02fea3a..10fca632c 100755
--- a/test/box-tap/trigger_yield.test.lua
+++ b/test/box-tap/trigger_yield.test.lua
@@ -5,21 +5,21 @@ box.cfg{
     log = "tarantool.log"
 }
 
-fiber = require('fiber')
+local fiber = require('fiber')
 
 box.schema.space.create('test')
 box.space.test:create_index('pk')
 
 box.space.test:truncate()
 
-function fail() fiber.sleep(0.0001) error("fail") end
+local function fail() fiber.sleep(0.0001) error("fail") end
 
 box.space.test:on_replace(fail)
 
-function insert() box.space.test:auto_increment{fiber.id()} end
+local function insert() box.space.test:auto_increment{fiber.id()} end
 
-fibers = {}
-for i = 1, 100 do
+local fibers = {}
+for _ = 1, 100 do
     table.insert(fibers, fiber.create(insert))
 end
 
-- 
2.25.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Tarantool-patches] [PATCH v7 0/3] Fix luacheck warnings in test/box-tap, test/box and test/box-py
  2020-12-22 14:54 [Tarantool-patches] [PATCH v7 0/3] Fix luacheck warnings in test/box-tap, test/box and test/box-py sergeyb
                   ` (2 preceding siblings ...)
  2020-12-22 14:54 ` [Tarantool-patches] [PATCH v7 3/3] luacheck: fix warnings in test/box-tap sergeyb
@ 2020-12-25 10:37 ` Kirill Yukhin
  2020-12-30 10:17   ` Kirill Yukhin
  2020-12-30 12:27 ` Leonid Vasiliev
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Kirill Yukhin @ 2020-12-25 10:37 UTC (permalink / raw)
  To: sergeyb; +Cc: Sergey Bronnikov, tarantool-patches, v.shpilevoy

Hello,

On 22 Dec 17:54, Sergey Bronnikov via Tarantool-patches wrote:
> From: Sergey Bronnikov <estetus@gmail.com>
> 
> Changelog v7:
> - rebased to master branch and fixed new warnings
> - splitted a huge patch series for test/ to a separate issues and patches series
>   (other patches will follow)
> 
> Changelog v6:
> 
> - splitted patch in test/ for patches per sub-directory
> - adjusted supressions in .luacheckrc
> - fixed formatting issues in .luacheckrc
> - fixed warnings in test/vinyl/vinyl.lua and test/vinyl/large.lua
> - added commit with bumping luajit version
> - fixed warnings in test/app-tap/lua/serializer_test.lua
> 
> NOTE: most luacheck patches includes changes in .luacheckrc so branch with
> patches from this patch series includes uncommitted (but with one LGTM) patches
> for test/app and test/app-tap (ligurio/gh-5453-luacheck-warnings-test-app-tap).
> 
> 1. https://lists.tarantool.org/pipermail/tarantool-patches/2020-December/021385.html 
> 
> Gitlab CI: https://gitlab.com/tarantool/tarantool/-/pipelines/233332402
> GH branch: ligurio/gh-5455-luacheck-warnings-test-box
> GH issues:
>   - https://github.com/tarantool/tarantool/issues/5455
>   - https://github.com/tarantool/tarantool/issues/5456 
>   - https://github.com/tarantool/tarantool/issues/5457

I've checked your patchset into 2.5, 2.6 and master.

--
Regards, Kirill Yukhin

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Tarantool-patches] [PATCH v7 0/3] Fix luacheck warnings in test/box-tap, test/box and test/box-py
  2020-12-25 10:37 ` [Tarantool-patches] [PATCH v7 0/3] Fix luacheck warnings in test/box-tap, test/box and test/box-py Kirill Yukhin
@ 2020-12-30 10:17   ` Kirill Yukhin
  0 siblings, 0 replies; 18+ messages in thread
From: Kirill Yukhin @ 2020-12-30 10:17 UTC (permalink / raw)
  To: sergeyb, Sergey Bronnikov, tarantool-patches, v.shpilevoy

Hello,

On 25 Dec 10:37, Kirill Yukhin via Tarantool-patches wrote:
> Hello,
> 
> On 22 Dec 17:54, Sergey Bronnikov via Tarantool-patches wrote:
> > From: Sergey Bronnikov <estetus@gmail.com>
> > 
> > Changelog v7:
> > - rebased to master branch and fixed new warnings
> > - splitted a huge patch series for test/ to a separate issues and patches series
> >   (other patches will follow)
> > 
> > Changelog v6:
> > 
> > - splitted patch in test/ for patches per sub-directory
> > - adjusted supressions in .luacheckrc
> > - fixed formatting issues in .luacheckrc
> > - fixed warnings in test/vinyl/vinyl.lua and test/vinyl/large.lua
> > - added commit with bumping luajit version
> > - fixed warnings in test/app-tap/lua/serializer_test.lua
> > 
> > NOTE: most luacheck patches includes changes in .luacheckrc so branch with
> > patches from this patch series includes uncommitted (but with one LGTM) patches
> > for test/app and test/app-tap (ligurio/gh-5453-luacheck-warnings-test-app-tap).
> > 
> > 1. https://lists.tarantool.org/pipermail/tarantool-patches/2020-December/021385.html 
> > 
> > Gitlab CI: https://gitlab.com/tarantool/tarantool/-/pipelines/233332402
> > GH branch: ligurio/gh-5455-luacheck-warnings-test-box
> > GH issues:
> >   - https://github.com/tarantool/tarantool/issues/5455
> >   - https://github.com/tarantool/tarantool/issues/5456 
> >   - https://github.com/tarantool/tarantool/issues/5457
> 
> I've checked your patchset into 2.5, 2.6 and master.

Disregard, pls.

--
Regards, Kirill Yukhin

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Tarantool-patches] [PATCH v7 0/3] Fix luacheck warnings in test/box-tap, test/box and test/box-py
  2020-12-22 14:54 [Tarantool-patches] [PATCH v7 0/3] Fix luacheck warnings in test/box-tap, test/box and test/box-py sergeyb
                   ` (3 preceding siblings ...)
  2020-12-25 10:37 ` [Tarantool-patches] [PATCH v7 0/3] Fix luacheck warnings in test/box-tap, test/box and test/box-py Kirill Yukhin
@ 2020-12-30 12:27 ` Leonid Vasiliev
  2021-01-14 21:34 ` Vladislav Shpilevoy via Tarantool-patches
  2021-01-15  9:48 ` Kirill Yukhin via Tarantool-patches
  6 siblings, 0 replies; 18+ messages in thread
From: Leonid Vasiliev @ 2020-12-30 12:27 UTC (permalink / raw)
  To: sergeyb, tarantool-patches, v.shpilevoy; +Cc: Sergey Bronnikov

Hi! Thank you for the patchset!
LGTM.

On 22.12.2020 17:54, sergeyb@tarantool.org wrote:
> From: Sergey Bronnikov <estetus@gmail.com>
> 
> Changelog v7:
> - rebased to master branch and fixed new warnings
> - splitted a huge patch series for test/ to a separate issues and patches series
>    (other patches will follow)
> 
> Changelog v6:
> 
> - splitted patch in test/ for patches per sub-directory
> - adjusted supressions in .luacheckrc
> - fixed formatting issues in .luacheckrc
> - fixed warnings in test/vinyl/vinyl.lua and test/vinyl/large.lua
> - added commit with bumping luajit version
> - fixed warnings in test/app-tap/lua/serializer_test.lua
> 
> NOTE: most luacheck patches includes changes in .luacheckrc so branch with
> patches from this patch series includes uncommitted (but with one LGTM) patches
> for test/app and test/app-tap (ligurio/gh-5453-luacheck-warnings-test-app-tap).
> 
> 1. https://lists.tarantool.org/pipermail/tarantool-patches/2020-December/021385.html
> 
> Gitlab CI: https://gitlab.com/tarantool/tarantool/-/pipelines/233332402
> GH branch: ligurio/gh-5455-luacheck-warnings-test-box
> GH issues:
>    - https://github.com/tarantool/tarantool/issues/5455
>    - https://github.com/tarantool/tarantool/issues/5456
>    - https://github.com/tarantool/tarantool/issues/5457
> 
> Sergey Bronnikov (3):
>    luacheck: fix warnings in test/box
>    luacheck: fix warnings in test/box-py
>    luacheck: fix warnings in test/box-tap
> 
>   .luacheckrc                                   | 80 ++++++++++++++++++-
>   test/box-py/box.lua                           |  2 +-
>   test/box-tap/auth.test.lua                    | 20 ++---
>   test/box-tap/cfg.test.lua                     | 34 ++++----
>   test/box-tap/cfgup.test.lua                   |  4 +-
>   test/box-tap/extended_error.test.lua          | 11 +--
>   test/box-tap/feedback_daemon.test.lua         |  8 +-
>   test/box-tap/gc.test.lua                      |  4 +-
>   test/box-tap/gh-4688-box-info-memory.test.lua |  2 +-
>   test/box-tap/on_schema_init.test.lua          |  4 +-
>   test/box-tap/schema_mt.test.lua               | 22 ++---
>   test/box-tap/session.storage.test.lua         | 10 +--
>   test/box-tap/session.test.lua                 | 56 ++++++-------
>   test/box-tap/trigger_atexit.test.lua          | 10 +--
>   test/box-tap/trigger_yield.test.lua           | 10 +--
>   test/box/box.lua                              |  4 +-
>   test/box/lua/bitset.lua                       |  7 +-
>   test/box/lua/cfg_bad_vinyl_dir.lua            |  2 +-
>   test/box/lua/cfg_rtree.lua                    |  2 +-
>   test/box/lua/cfg_test1.lua                    |  2 +-
>   test/box/lua/cfg_test2.lua                    |  2 +-
>   test/box/lua/cfg_test3.lua                    |  2 +-
>   test/box/lua/cfg_test4.lua                    |  2 +-
>   test/box/lua/cfg_test5.lua                    |  2 +-
>   test/box/lua/cfg_test6.lua                    |  2 +-
>   test/box/lua/cfg_test8.lua                    |  2 +-
>   test/box/lua/fifo.lua                         |  2 +-
>   test/box/lua/identifier.lua                   |  9 +--
>   test/box/lua/index_random_test.lua            |  2 +-
>   test/box/lua/txn_proxy.lua                    |  6 +-
>   test/box/lua/utils.lua                        | 10 +--
>   test/box/on_schema_init.lua                   |  8 +-
>   test/box/proxy.lua                            |  2 +-
>   test/box/tiny.lua                             |  2 +-
>   34 files changed, 202 insertions(+), 145 deletions(-)
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Tarantool-patches] [PATCH 1/3] luacheck: fix warnings in test/box
  2020-12-22 14:54 ` [Tarantool-patches] [PATCH 1/3] luacheck: fix warnings in test/box sergeyb
@ 2021-01-11 17:52   ` Vladislav Shpilevoy via Tarantool-patches
  2021-01-12 15:26     ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 1 reply; 18+ messages in thread
From: Vladislav Shpilevoy via Tarantool-patches @ 2021-01-11 17:52 UTC (permalink / raw)
  To: sergeyb, tarantool-patches, lvasiliev

Hi! Thanks for the patch!

See 2 comments below.

> diff --git a/.luacheckrc b/.luacheckrc
> index 4b829f3dc..17cff8671 100644
> --- a/.luacheckrc
> +++ b/.luacheckrc
> @@ -102,3 +108,53 @@ files["src/box/lua/console.lua"] = {
>          "212",
>      }
>  }
> +files["test/box/box.lua"] = {
> +    globals = {
> +        "cfg_filter",
> +        "sorted",
> +        "iproto_request",
> +    }
> +}
> +files["test/box/lua/push.lua"] = {
> +    globals = {"push_collection"}
> +}
> +files["test/box/lua/index_random_test.lua"] = {
> +    globals = {"index_random_test"}
> +}
> +files["test/box/lua/utils.lua"] = {
> +    globals = {
> +        "arithmetic",
> +        "check_space",
> +        "create_iterator",
> +        "iterate",
> +        "setmap",
> +        "sort",
> +        "space_field_types",
> +        "space_bsize",
> +        "table_generate",
> +        "table_shuffle",
> +        "tuple_to_string",

1. All these functions are returned by the module. It means,
they are supposed to be used like this:

	utils = require('utils.lua')
	utils.setmap()
	utils.space_bsize()
	-- etc

This in turn means you need to make them all 'local' in utils.lua.
I did it, and the tests pass. Also some of these functions are
probably unused, but I didn't check.

The same for identifier.lua below.

> +    }
> +}
> +files["test/box/lua/bitset.lua"] = {
> +    globals = {
> +        "clear",
> +        "create_space",
> +        "delete",
> +        "drop_space",
> +        "dump",
> +        "fill",
> +        "test_insert_delete",

2. Almost the same here. With a difference that the functions
are not returned now. But they are used in a single file, so their
'return' like in utils.lua does should be easy to do.

The same for fifo.lua below.

> +    }
> +}
> +files["test/box/lua/fifo.lua"] = {
> +    globals = {
> +        "fifomax",
> +        "fifo_push",
> +        "fifo_top",
> +        "find_or_create_fifo",
> +    }
> +}
> +files["test/box/lua/identifier.lua"] = {
> +     globals = {"run_test"}
> +}

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Tarantool-patches] [PATCH v7 3/3] luacheck: fix warnings in test/box-tap
  2020-12-22 14:54 ` [Tarantool-patches] [PATCH v7 3/3] luacheck: fix warnings in test/box-tap sergeyb
@ 2021-01-11 17:52   ` Vladislav Shpilevoy via Tarantool-patches
  2021-01-12 13:59     ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 1 reply; 18+ messages in thread
From: Vladislav Shpilevoy via Tarantool-patches @ 2021-01-11 17:52 UTC (permalink / raw)
  To: sergeyb, tarantool-patches, lvasiliev

Thanks for the patch!

> diff --git a/.luacheckrc b/.luacheckrc
> index 52625bb35..b7f9abb45 100644
> --- a/.luacheckrc
> +++ b/.luacheckrc
> @@ -157,3 +156,23 @@ files["test/box/lua/fifo.lua"] = {
>  files["test/box/lua/identifier.lua"] = {
>       globals = {"run_test"}
>  }
> +files["test/box-tap/session.test.lua"] = {
> +    globals = {
> +        "active_connections",

This can be declared 'local'.

====================
@@ -70,6 +70,7 @@ session.on_disconnect(nil, fail)
 
 -- check how connect/disconnect triggers work
 local peer_name = "peer_name"
+local active_connections = 0
 local function inc() active_connections = active_connections + 1 end
 local function dec() active_connections = active_connections - 1 end
 local function peer() peer_name = box.session.peer() end
@@ -77,7 +78,6 @@ local net = { box = require('net.box') }
 test:is(type(session.on_connect(inc)), "function", "type of trigger inc on_connect")
 test:is(type(session.on_disconnect(dec)), "function", "type of trigger dec on_disconnect")
 test:is(type(session.on_disconnect(peer)), "function", "type of trigger peer on_disconnect")
-active_connections = 0
 local c = net.box.connect(HOST, PORT)
====================

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Tarantool-patches] [PATCH v7 3/3] luacheck: fix warnings in test/box-tap
  2021-01-11 17:52   ` Vladislav Shpilevoy via Tarantool-patches
@ 2021-01-12 13:59     ` Sergey Bronnikov via Tarantool-patches
  2021-01-12 14:52       ` Vladislav Shpilevoy via Tarantool-patches
  0 siblings, 1 reply; 18+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2021-01-12 13:59 UTC (permalink / raw)
  To: Vladislav Shpilevoy, tarantool-patches, lvasiliev

Thanks for review!

On 11.01.2021 20:52, Vladislav Shpilevoy wrote:
> Thanks for the patch!
>
>> diff --git a/.luacheckrc b/.luacheckrc
>> index 52625bb35..b7f9abb45 100644
>> --- a/.luacheckrc
>> +++ b/.luacheckrc
>> @@ -157,3 +156,23 @@ files["test/box/lua/fifo.lua"] = {
>>   files["test/box/lua/identifier.lua"] = {
>>        globals = {"run_test"}
>>   }
>> +files["test/box-tap/session.test.lua"] = {
>> +    globals = {
>> +        "active_connections",
> This can be declared 'local'.

and with removed a single suppression in .luacheckrc we have got another 
warnings,

that should be suppressed too (inline or in luacheckrc):

Checking test/box-tap/session.test.lua            4 warnings

     test/box-tap/session.test.lua:73:22: setting non-standard global 
variable active_connections
     test/box-tap/session.test.lua:73:43: accessing undefined variable 
active_connections
     test/box-tap/session.test.lua:74:22: setting non-standard global 
variable active_connections
     test/box-tap/session.test.lua:74:43: accessing undefined variable 
active_connections

I think it is better to keep it as is.

>
> ====================
> @@ -70,6 +70,7 @@ session.on_disconnect(nil, fail)
>   
>   -- check how connect/disconnect triggers work
>   local peer_name = "peer_name"
> +local active_connections = 0
>   local function inc() active_connections = active_connections + 1 end
>   local function dec() active_connections = active_connections - 1 end
>   local function peer() peer_name = box.session.peer() end
> @@ -77,7 +78,6 @@ local net = { box = require('net.box') }
>   test:is(type(session.on_connect(inc)), "function", "type of trigger inc on_connect")
>   test:is(type(session.on_disconnect(dec)), "function", "type of trigger dec on_disconnect")
>   test:is(type(session.on_disconnect(peer)), "function", "type of trigger peer on_disconnect")
> -active_connections = 0
>   local c = net.box.connect(HOST, PORT)
> ====================

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Tarantool-patches] [PATCH v7 3/3] luacheck: fix warnings in test/box-tap
  2021-01-12 13:59     ` Sergey Bronnikov via Tarantool-patches
@ 2021-01-12 14:52       ` Vladislav Shpilevoy via Tarantool-patches
  2021-01-12 15:21         ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 1 reply; 18+ messages in thread
From: Vladislav Shpilevoy via Tarantool-patches @ 2021-01-12 14:52 UTC (permalink / raw)
  To: Sergey Bronnikov, tarantool-patches, lvasiliev

On 12.01.2021 14:59, Sergey Bronnikov wrote:
> Thanks for review!
> 
> On 11.01.2021 20:52, Vladislav Shpilevoy wrote:
>> Thanks for the patch!
>>
>>> diff --git a/.luacheckrc b/.luacheckrc
>>> index 52625bb35..b7f9abb45 100644
>>> --- a/.luacheckrc
>>> +++ b/.luacheckrc
>>> @@ -157,3 +156,23 @@ files["test/box/lua/fifo.lua"] = {
>>>   files["test/box/lua/identifier.lua"] = {
>>>        globals = {"run_test"}
>>>   }
>>> +files["test/box-tap/session.test.lua"] = {
>>> +    globals = {
>>> +        "active_connections",
>> This can be declared 'local'.
> 
> and with removed a single suppression in .luacheckrc we have got another warnings,
> 
> that should be suppressed too (inline or in luacheckrc):
> 
> Checking test/box-tap/session.test.lua            4 warnings
> 
>     test/box-tap/session.test.lua:73:22: setting non-standard global variable active_connections
>     test/box-tap/session.test.lua:73:43: accessing undefined variable active_connections
>     test/box-tap/session.test.lua:74:22: setting non-standard global variable active_connections
>     test/box-tap/session.test.lua:74:43: accessing undefined variable active_connections
> 
> I think it is better to keep it as is.

It seems you didn't bother with applying my diff from the previous
email, did you? I kept it below:

>> ====================
>> @@ -70,6 +70,7 @@ session.on_disconnect(nil, fail)
>>     -- check how connect/disconnect triggers work
>>   local peer_name = "peer_name"
>> +local active_connections = 0
>>   local function inc() active_connections = active_connections + 1 end
>>   local function dec() active_connections = active_connections - 1 end
>>   local function peer() peer_name = box.session.peer() end
>> @@ -77,7 +78,6 @@ local net = { box = require('net.box') }
>>   test:is(type(session.on_connect(inc)), "function", "type of trigger inc on_connect")
>>   test:is(type(session.on_disconnect(dec)), "function", "type of trigger dec on_disconnect")
>>   test:is(type(session.on_disconnect(peer)), "function", "type of trigger peer on_disconnect")
>> -active_connections = 0
>>   local c = net.box.connect(HOST, PORT)
>> ====================

I will paste here the full diff now, with the line removed from
.luacheck:

====================
diff --git a/.luacheckrc b/.luacheckrc
index b7f9abb45..6043722f4 100644
--- a/.luacheckrc
+++ b/.luacheckrc
@@ -158,7 +158,6 @@ files["test/box/lua/identifier.lua"] = {
 }
 files["test/box-tap/session.test.lua"] = {
     globals = {
-        "active_connections",
         "session",
         "space",
         "f1",
diff --git a/test/box-tap/session.test.lua b/test/box-tap/session.test.lua
index 160f047bc..3dd159ebb 100755
--- a/test/box-tap/session.test.lua
+++ b/test/box-tap/session.test.lua
@@ -70,6 +70,7 @@ session.on_disconnect(nil, fail)
 
 -- check how connect/disconnect triggers work
 local peer_name = "peer_name"
+local active_connections = 0
 local function inc() active_connections = active_connections + 1 end
 local function dec() active_connections = active_connections - 1 end
 local function peer() peer_name = box.session.peer() end
@@ -77,7 +78,6 @@ local net = { box = require('net.box') }
 test:is(type(session.on_connect(inc)), "function", "type of trigger inc on_connect")
 test:is(type(session.on_disconnect(dec)), "function", "type of trigger dec on_disconnect")
 test:is(type(session.on_disconnect(peer)), "function", "type of trigger peer on_disconnect")
-active_connections = 0
 local c = net.box.connect(HOST, PORT)
====================

You can copy-paste it into a file and use `git apply` to repeat
it exactly. From the errors you have shown above it looks like
you didn't move the declaration above its usages (I tried it and
got the same errors, of course). You just added 'local', and didn't
try to move it.

With this diff I run luacheck command and get 0 errors/warnings.

====================
$ ./.rocks/bin/luacheck --codes --config .luacheckrc test/box-tap/session.test.lua
Checking test/box-tap/session.test.lua            OK

Total: 0 warnings / 0 errors in 1 file
====================

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Tarantool-patches] [PATCH v7 3/3] luacheck: fix warnings in test/box-tap
  2021-01-12 14:52       ` Vladislav Shpilevoy via Tarantool-patches
@ 2021-01-12 15:21         ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 18+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2021-01-12 15:21 UTC (permalink / raw)
  To: Vladislav Shpilevoy, tarantool-patches, lvasiliev


On 12.01.2021 17:52, Vladislav Shpilevoy wrote:
> On 12.01.2021 14:59, Sergey Bronnikov wrote:
>> Thanks for review!
>>
>> On 11.01.2021 20:52, Vladislav Shpilevoy wrote:
>>> Thanks for the patch!
>>>
>>>> diff --git a/.luacheckrc b/.luacheckrc
>>>> index 52625bb35..b7f9abb45 100644
>>>> --- a/.luacheckrc
>>>> +++ b/.luacheckrc
>>>> @@ -157,3 +156,23 @@ files["test/box/lua/fifo.lua"] = {
>>>>    files["test/box/lua/identifier.lua"] = {
>>>>         globals = {"run_test"}
>>>>    }
>>>> +files["test/box-tap/session.test.lua"] = {
>>>> +    globals = {
>>>> +        "active_connections",
>>> This can be declared 'local'.
>> and with removed a single suppression in .luacheckrc we have got another warnings,
>>
>> that should be suppressed too (inline or in luacheckrc):
>>
>> Checking test/box-tap/session.test.lua            4 warnings
>>
>>      test/box-tap/session.test.lua:73:22: setting non-standard global variable active_connections
>>      test/box-tap/session.test.lua:73:43: accessing undefined variable active_connections
>>      test/box-tap/session.test.lua:74:22: setting non-standard global variable active_connections
>>      test/box-tap/session.test.lua:74:43: accessing undefined variable active_connections
>>
>> I think it is better to keep it as is.
> It seems you didn't bother with applying my diff from the previous
> email, did you? I kept it below:


You are right, missed that active_connections must be moved above.

Now luacheck is green.

>
>>> ====================
>>> @@ -70,6 +70,7 @@ session.on_disconnect(nil, fail)
>>>      -- check how connect/disconnect triggers work
>>>    local peer_name = "peer_name"
>>> +local active_connections = 0
>>>    local function inc() active_connections = active_connections + 1 end
>>>    local function dec() active_connections = active_connections - 1 end
>>>    local function peer() peer_name = box.session.peer() end
>>> @@ -77,7 +78,6 @@ local net = { box = require('net.box') }
>>>    test:is(type(session.on_connect(inc)), "function", "type of trigger inc on_connect")
>>>    test:is(type(session.on_disconnect(dec)), "function", "type of trigger dec on_disconnect")
>>>    test:is(type(session.on_disconnect(peer)), "function", "type of trigger peer on_disconnect")
>>> -active_connections = 0
>>>    local c = net.box.connect(HOST, PORT)
>>> ====================
> I will paste here the full diff now, with the line removed from
> .luacheck:
>
> ====================
> diff --git a/.luacheckrc b/.luacheckrc
> index b7f9abb45..6043722f4 100644
> --- a/.luacheckrc
> +++ b/.luacheckrc
> @@ -158,7 +158,6 @@ files["test/box/lua/identifier.lua"] = {
>   }
>   files["test/box-tap/session.test.lua"] = {
>       globals = {
> -        "active_connections",
>           "session",
>           "space",
>           "f1",
> diff --git a/test/box-tap/session.test.lua b/test/box-tap/session.test.lua
> index 160f047bc..3dd159ebb 100755
> --- a/test/box-tap/session.test.lua
> +++ b/test/box-tap/session.test.lua
> @@ -70,6 +70,7 @@ session.on_disconnect(nil, fail)
>   
>   -- check how connect/disconnect triggers work
>   local peer_name = "peer_name"
> +local active_connections = 0
>   local function inc() active_connections = active_connections + 1 end
>   local function dec() active_connections = active_connections - 1 end
>   local function peer() peer_name = box.session.peer() end
> @@ -77,7 +78,6 @@ local net = { box = require('net.box') }
>   test:is(type(session.on_connect(inc)), "function", "type of trigger inc on_connect")
>   test:is(type(session.on_disconnect(dec)), "function", "type of trigger dec on_disconnect")
>   test:is(type(session.on_disconnect(peer)), "function", "type of trigger peer on_disconnect")
> -active_connections = 0
>   local c = net.box.connect(HOST, PORT)
> ====================
>
> You can copy-paste it into a file and use `git apply` to repeat
> it exactly. From the errors you have shown above it looks like
> you didn't move the declaration above its usages (I tried it and
> got the same errors, of course). You just added 'local', and didn't
> try to move it.
>
> With this diff I run luacheck command and get 0 errors/warnings.
>
> ====================
> $ ./.rocks/bin/luacheck --codes --config .luacheckrc test/box-tap/session.test.lua
> Checking test/box-tap/session.test.lua            OK
>
> Total: 0 warnings / 0 errors in 1 file
> ====================

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Tarantool-patches] [PATCH 1/3] luacheck: fix warnings in test/box
  2021-01-11 17:52   ` Vladislav Shpilevoy via Tarantool-patches
@ 2021-01-12 15:26     ` Sergey Bronnikov via Tarantool-patches
  2021-01-13  7:58       ` Sergey Bronnikov via Tarantool-patches
  2021-01-13 16:38       ` Vladislav Shpilevoy via Tarantool-patches
  0 siblings, 2 replies; 18+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2021-01-12 15:26 UTC (permalink / raw)
  To: Vladislav Shpilevoy, tarantool-patches, lvasiliev

Thanks for review!

On 11.01.2021 20:52, Vladislav Shpilevoy wrote:
> Hi! Thanks for the patch!
>
> See 2 comments below.
>
>> diff --git a/.luacheckrc b/.luacheckrc
>> index 4b829f3dc..17cff8671 100644
>> --- a/.luacheckrc
>> +++ b/.luacheckrc
>> @@ -102,3 +108,53 @@ files["src/box/lua/console.lua"] = {
>>           "212",
>>       }
>>   }
>> +files["test/box/box.lua"] = {
>> +    globals = {
>> +        "cfg_filter",
>> +        "sorted",
>> +        "iproto_request",
>> +    }
>> +}
>> +files["test/box/lua/push.lua"] = {
>> +    globals = {"push_collection"}
>> +}
>> +files["test/box/lua/index_random_test.lua"] = {
>> +    globals = {"index_random_test"}
>> +}
>> +files["test/box/lua/utils.lua"] = {
>> +    globals = {
>> +        "arithmetic",
>> +        "check_space",
>> +        "create_iterator",
>> +        "iterate",
>> +        "setmap",
>> +        "sort",
>> +        "space_field_types",
>> +        "space_bsize",
>> +        "table_generate",
>> +        "table_shuffle",
>> +        "tuple_to_string",
> 1. All these functions are returned by the module. It means,
> they are supposed to be used like this:
>
> 	utils = require('utils.lua')
> 	utils.setmap()
> 	utils.space_bsize()
> 	-- etc
>
> This in turn means you need to make them all 'local' in utils.lua.
> I did it, and the tests pass. Also some of these functions are
> probably unused, but I didn't check.
>
> The same for identifier.lua below.

- removed some functions from interfaces and their implementations

- most lua libs converted to modules and removed suppressions removed 
from luacheckrc except

"dump" function. It is used in module itself and mark it as local is not 
enough to make luacheck happy.

I didn't post patch here because it is too huge. Let me know if you need 
new patch series, I'll resend it.

>> +    }
>> +}
>> +files["test/box/lua/bitset.lua"] = {
>> +    globals = {
>> +        "clear",
>> +        "create_space",
>> +        "delete",
>> +        "drop_space",
>> +        "dump",
>> +        "fill",
>> +        "test_insert_delete",
> 2. Almost the same here. With a difference that the functions
> are not returned now. But they are used in a single file, so their
> 'return' like in utils.lua does should be easy to do.
>
> The same for fifo.lua below.
converted to modules
>
>> +    }
>> +}
>> +files["test/box/lua/fifo.lua"] = {
>> +    globals = {
>> +        "fifomax",
>> +        "fifo_push",
>> +        "fifo_top",
>> +        "find_or_create_fifo",
>> +    }
>> +}
>> +files["test/box/lua/identifier.lua"] = {
>> +     globals = {"run_test"}
>> +}

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Tarantool-patches] [PATCH 1/3] luacheck: fix warnings in test/box
  2021-01-12 15:26     ` Sergey Bronnikov via Tarantool-patches
@ 2021-01-13  7:58       ` Sergey Bronnikov via Tarantool-patches
  2021-01-13 16:38       ` Vladislav Shpilevoy via Tarantool-patches
  1 sibling, 0 replies; 18+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2021-01-13  7:58 UTC (permalink / raw)
  To: Vladislav Shpilevoy, tarantool-patches, lvasiliev


On 12.01.2021 18:26, Sergey Bronnikov via Tarantool-patches wrote:
> Thanks for review!
>
> On 11.01.2021 20:52, Vladislav Shpilevoy wrote:
>> Hi! Thanks for the patch!
>>
>> See 2 comments below.
>>
>>> diff --git a/.luacheckrc b/.luacheckrc
>>> index 4b829f3dc..17cff8671 100644
>>> --- a/.luacheckrc
>>> +++ b/.luacheckrc
>>> @@ -102,3 +108,53 @@ files["src/box/lua/console.lua"] = {
>>>           "212",
>>>       }
>>>   }
>>> +files["test/box/box.lua"] = {
>>> +    globals = {
>>> +        "cfg_filter",
>>> +        "sorted",
>>> +        "iproto_request",
>>> +    }
>>> +}
>>> +files["test/box/lua/push.lua"] = {
>>> +    globals = {"push_collection"}
>>> +}
>>> +files["test/box/lua/index_random_test.lua"] = {
>>> +    globals = {"index_random_test"}
>>> +}
>>> +files["test/box/lua/utils.lua"] = {
>>> +    globals = {
>>> +        "arithmetic",
>>> +        "check_space",
>>> +        "create_iterator",
>>> +        "iterate",
>>> +        "setmap",
>>> +        "sort",
>>> +        "space_field_types",
>>> +        "space_bsize",
>>> +        "table_generate",
>>> +        "table_shuffle",
>>> +        "tuple_to_string",
>> 1. All these functions are returned by the module. It means,
>> they are supposed to be used like this:
>>
>>     utils = require('utils.lua')
>>     utils.setmap()
>>     utils.space_bsize()
>>     -- etc
>>
>> This in turn means you need to make them all 'local' in utils.lua.
>> I did it, and the tests pass. Also some of these functions are
>> probably unused, but I didn't check.
>>
>> The same for identifier.lua below.
>
> - removed some functions from interfaces and their implementations

reverted change because removed functions are used by other suites (for 
example vinyl)

<snipped>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Tarantool-patches] [PATCH 1/3] luacheck: fix warnings in test/box
  2021-01-12 15:26     ` Sergey Bronnikov via Tarantool-patches
  2021-01-13  7:58       ` Sergey Bronnikov via Tarantool-patches
@ 2021-01-13 16:38       ` Vladislav Shpilevoy via Tarantool-patches
  2021-01-14  7:49         ` Sergey Bronnikov via Tarantool-patches
  1 sibling, 1 reply; 18+ messages in thread
From: Vladislav Shpilevoy via Tarantool-patches @ 2021-01-13 16:38 UTC (permalink / raw)
  To: Sergey Bronnikov, tarantool-patches, lvasiliev

Hi! Thanks for the fixes!

Consider my fixes on top of this commit on the branch, and below with
explanations.

==================================================
diff --git a/.luacheckrc b/.luacheckrc
index 749574378..0ff90450e 100644
--- a/.luacheckrc
+++ b/.luacheckrc
@@ -115,8 +115,3 @@ files["test/box/box.lua"] = {
         "iproto_request",
     }
 }
-files["test/box/lua/bitset.lua"] = {
-    globals = {
-        "dump",
-    }
-}
====================

You don't need to ignore it, because it works fine when declared
'local'. It does not prevent its usage inside of the module, because
local or not, it is still 'global' inside the file.

The only problem was in the test, where it was also saved to a local
variable. Which won't work in non-tap tests, because each line here
is executed as a script. It means, 'local' variables are not visible
out of the line where they are declared. I removed 'local' from the
test file, and it allowed not to ignore anything in bitset.lua.

====================
diff --git a/test/box/bitset.result b/test/box/bitset.result
index 3296f66d8..af3384d3f 100644
--- a/test/box/bitset.result
+++ b/test/box/bitset.result
@@ -1,7 +1,7 @@
 bset = require('bitset')
 ---
 ...
-local dump = bset.dump
+dump = bset.dump
 ---
 ...
 bset.create_space()
diff --git a/test/box/bitset.test.lua b/test/box/bitset.test.lua
index c56a7e1a4..cb7c408f5 100644
--- a/test/box/bitset.test.lua
+++ b/test/box/bitset.test.lua
@@ -1,6 +1,6 @@
 bset = require('bitset')
 
-local dump = bset.dump
+dump = bset.dump
 bset.create_space()
 
 ------------------------------------------------------------------------------
diff --git a/test/box/lua.result b/test/box/lua.result
index 409ab7e8f..4c14f200d 100644
--- a/test/box/lua.result
+++ b/test/box/lua.result
@@ -625,46 +625,46 @@ space = box.schema.space.create('tweedledum')
 tmp = space:create_index('primary', { type = 'tree', parts = {1, 'unsigned'}, unique = true })
 ---
 ...
-push = require('push')
+push_collection = require('push')
====================

This allowed to revert some big diff from your changes. Everything
below turns into no-diff when squashed into your commit.

====================
 ---
 ...
-push.push_collection(space, 0, 1038784, 'hello')
+push_collection(space, 0, 1038784, 'hello')
 ---
 - [1038784, 'hello']
 ...
-push.push_collection(space, 0, 1038784, 'hello')
+push_collection(space, 0, 1038784, 'hello')
 ---
 - [1038784]
 ...
-push.push_collection(space, 0, 1038784, 'hello')
+push_collection(space, 0, 1038784, 'hello')
 ---
 - [1038784]
 ...
-push.push_collection(space, 1, 1038784, 'hi')
+push_collection(space, 1, 1038784, 'hi')
 ---
 - [1038784, 'hi']
 ...
-push.push_collection(space, 2, 1038784, 'hi')
+push_collection(space, 2, 1038784, 'hi')
 ---
 - [1038784, 'hi', 'hi']
 ...
-push.push_collection(space, 2, 1038784, 'hi')
+push_collection(space, 2, 1038784, 'hi')
 ---
 - [1038784, 'hi', 'hi']
 ...
-push.push_collection(space, 5, 1038784, 'hey')
+push_collection(space, 5, 1038784, 'hey')
 ---
 - [1038784, 'hi', 'hi', 'hey']
 ...
-push.push_collection(space, 5, 1038784, 'hey')
+push_collection(space, 5, 1038784, 'hey')
 ---
 - [1038784, 'hi', 'hi', 'hey', 'hey']
 ...
-push.push_collection(space, 5, 1038784, 'hey')
+push_collection(space, 5, 1038784, 'hey')
 ---
 - [1038784, 'hi', 'hi', 'hey', 'hey', 'hey']
 ...
-push.push_collection(space, 5, 1038784, 'hey')
+push_collection(space, 5, 1038784, 'hey')
 ---
 - [1038784, 'hi', 'hey', 'hey', 'hey', 'hey']
 ...
@@ -752,7 +752,7 @@ space:drop()
 --
 -- index:random test
 -- 
-test = require('index_random_test')
+index_random_test = require('index_random_test')
 ---
 ...
 space = box.schema.space.create('tweedledum')
@@ -767,14 +767,14 @@ tmp = space:create_index('secondary', { type = 'hash', parts = {1, 'unsigned'},
 -------------------------------------------------------------------------------
 -- TreeIndex::random()
 -------------------------------------------------------------------------------
-test.index_random_test(space, 'primary')
+index_random_test(space, 'primary')
 ---
 - true
 ...
 -------------------------------------------------------------------------------
 -- HashIndex::random()
 -------------------------------------------------------------------------------
-test.index_random_test(space, 'secondary')
+index_random_test(space, 'secondary')
 ---
 - true
 ...
diff --git a/test/box/lua.test.lua b/test/box/lua.test.lua
index 8d429a7e3..9762e07eb 100644
--- a/test/box/lua.test.lua
+++ b/test/box/lua.test.lua
@@ -225,20 +225,20 @@ space:drop()
 
 space = box.schema.space.create('tweedledum')
 tmp = space:create_index('primary', { type = 'tree', parts = {1, 'unsigned'}, unique = true })
-push = require('push')
+push_collection = require('push')
 
-push.push_collection(space, 0, 1038784, 'hello')
-push.push_collection(space, 0, 1038784, 'hello')
-push.push_collection(space, 0, 1038784, 'hello')
+push_collection(space, 0, 1038784, 'hello')
+push_collection(space, 0, 1038784, 'hello')
+push_collection(space, 0, 1038784, 'hello')
 
-push.push_collection(space, 1, 1038784, 'hi')
-push.push_collection(space, 2, 1038784, 'hi')
-push.push_collection(space, 2, 1038784, 'hi')
+push_collection(space, 1, 1038784, 'hi')
+push_collection(space, 2, 1038784, 'hi')
+push_collection(space, 2, 1038784, 'hi')
 
-push.push_collection(space, 5, 1038784, 'hey')
-push.push_collection(space, 5, 1038784, 'hey')
-push.push_collection(space, 5, 1038784, 'hey')
-push.push_collection(space, 5, 1038784, 'hey')
+push_collection(space, 5, 1038784, 'hey')
+push_collection(space, 5, 1038784, 'hey')
+push_collection(space, 5, 1038784, 'hey')
+push_collection(space, 5, 1038784, 'hey')
 
 -- # lua box.auto_increment() testing
 -- # http://bugs.launchpad.net/tarantool/+bug/1006354
@@ -277,7 +277,7 @@ space:drop()
 --
 -- index:random test
 -- 
-test = require('index_random_test')
+index_random_test = require('index_random_test')
 space = box.schema.space.create('tweedledum')
 tmp = space:create_index('primary', { type = 'tree', parts = {1, 'unsigned'}, unique = true })
 tmp = space:create_index('secondary', { type = 'hash', parts = {1, 'unsigned'}, unique = true })
@@ -285,13 +285,13 @@ tmp = space:create_index('secondary', { type = 'hash', parts = {1, 'unsigned'},
 -- TreeIndex::random()
 -------------------------------------------------------------------------------
 
-test.index_random_test(space, 'primary')
+index_random_test(space, 'primary')
 
 -------------------------------------------------------------------------------
 -- HashIndex::random()
 -------------------------------------------------------------------------------
 
-test.index_random_test(space, 'secondary')
+index_random_test(space, 'secondary')
 
 space:drop()
 space = nil
diff --git a/test/box/lua/bitset.lua b/test/box/lua/bitset.lua
index 3420727cf..245e9f097 100644
--- a/test/box/lua/bitset.lua
+++ b/test/box/lua/bitset.lua
@@ -32,7 +32,7 @@ local function drop_space()
     box.space['tweedledum']:drop()
 end
 
-function dump(...)
+local function dump(...)
 	return utils.iterate('tweedledum', 'bitset', 1, 2, ...)
 end
 
@@ -50,11 +50,11 @@ local function test_insert_delete(n)
 end
 
 return {
-    clear = clear;
-    create_space = create_space;
-    delete = delete;
-    drop_space = drop_space;
-    dump = dump;
-    fill = fill;
-    test_insert_delete = test_insert_delete;
+    clear = clear,
+    create_space = create_space,
+    delete = delete,
+    drop_space = drop_space,
+    dump = dump,
+    fill = fill,
+    test_insert_delete = test_insert_delete,
====================

We don't use ';' anywhere. It may still be used in some old code,
but not in the new code. I have no idea though if it is stated
anywhere formally.

====================
 }
diff --git a/test/box/lua/fifo.lua b/test/box/lua/fifo.lua
index 9003904e2..3288c8be8 100644
--- a/test/box/lua/fifo.lua
+++ b/test/box/lua/fifo.lua
@@ -32,8 +32,8 @@ local function fifo_top(space, name)
 end
 
 return {
-    find_or_create_fifo = find_or_create_fifo;
-    fifo_push = fifo_push;
-    fifo_top = fifo_top;
-    fifomax = fifomax;
+    find_or_create_fifo = find_or_create_fifo,
+    fifo_push = fifo_push,
+    fifo_top = fifo_top,
+    fifomax = fifomax,
 };
diff --git a/test/box/lua/index_random_test.lua b/test/box/lua/index_random_test.lua
index b6248c07c..d8622a4db 100644
--- a/test/box/lua/index_random_test.lua
+++ b/test/box/lua/index_random_test.lua
@@ -40,6 +40,4 @@ local function index_random_test(space, index_no)
 	return true
 end
 
-return {
-	index_random_test = index_random_test;
-}
+return index_random_test
diff --git a/test/box/lua/push.lua b/test/box/lua/push.lua
index 7c9b36275..5ce0c12bc 100644
--- a/test/box/lua/push.lua
+++ b/test/box/lua/push.lua
@@ -1,4 +1,3 @@
-
 local function push_collection(space, size, cid, ...)
 	local append = { ... }
 	local tuple = space:get{cid}
@@ -15,6 +14,4 @@ local function push_collection(space, size, cid, ...)
 	return space:replace{tuple:unpack()}
 end
 
-return {
-	push_collection = push_collection;
-}
+return push_collection
diff --git a/test/box/lua/utils.lua b/test/box/lua/utils.lua
index 0eb427eb9..e6b3a6b57 100644
--- a/test/box/lua/utils.lua
+++ b/test/box/lua/utils.lua
@@ -209,11 +209,11 @@ end
 return {
     iterate = iterate;
     arithmetic = arithmetic;
-    create_iterator = create_iterator;
-    check_space = check_space;
     table_generate = table_generate;
     table_shuffle = table_shuffle;
     sort = sort;
+    check_space = check_space;
     space_bsize = space_bsize;
+    create_iterator = create_iterator;
====================

In your patch you somewhy moved these 2 functions. I moved
them back to reduce diff.

====================
     setmap = setmap;
 };

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Tarantool-patches] [PATCH 1/3] luacheck: fix warnings in test/box
  2021-01-13 16:38       ` Vladislav Shpilevoy via Tarantool-patches
@ 2021-01-14  7:49         ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 18+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2021-01-14  7:49 UTC (permalink / raw)
  To: Vladislav Shpilevoy, tarantool-patches, lvasiliev


On 13.01.2021 19:38, Vladislav Shpilevoy wrote:
> Hi! Thanks for the fixes!
>
> Consider my fixes on top of this commit on the branch, and below with
> explanations.
Thanks for your fixes! I have squashed your commit.

<snipped>

> @@ -50,11 +50,11 @@ local function test_insert_delete(n)
>   end
>   
>   return {
> -    clear = clear;
> -    create_space = create_space;
> -    delete = delete;
> -    drop_space = drop_space;
> -    dump = dump;
> -    fill = fill;
> -    test_insert_delete = test_insert_delete;
> +    clear = clear,
> +    create_space = create_space,
> +    delete = delete,
> +    drop_space = drop_space,
> +    dump = dump,
> +    fill = fill,
> +    test_insert_delete = test_insert_delete,
> ====================
>
> We don't use ';' anywhere. It may still be used in some old code,
> but not in the new code. I have no idea though if it is stated
> anywhere formally.

actually there is a rule in Lua guideline [1]: "do not use semicolon as 
table separator (only comma)"

<snipped>

1. 
https://www.tarantool.io/en/doc/latest/dev_guide/lua_style_guide/#idioms-and-patterns



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Tarantool-patches] [PATCH v7 0/3] Fix luacheck warnings in test/box-tap, test/box and test/box-py
  2020-12-22 14:54 [Tarantool-patches] [PATCH v7 0/3] Fix luacheck warnings in test/box-tap, test/box and test/box-py sergeyb
                   ` (4 preceding siblings ...)
  2020-12-30 12:27 ` Leonid Vasiliev
@ 2021-01-14 21:34 ` Vladislav Shpilevoy via Tarantool-patches
  2021-01-15  9:48 ` Kirill Yukhin via Tarantool-patches
  6 siblings, 0 replies; 18+ messages in thread
From: Vladislav Shpilevoy via Tarantool-patches @ 2021-01-14 21:34 UTC (permalink / raw)
  To: sergeyb, tarantool-patches, lvasiliev; +Cc: Sergey Bronnikov

Hi! Thanks for the patchset!

LGTM.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Tarantool-patches] [PATCH v7 0/3] Fix luacheck warnings in test/box-tap, test/box and test/box-py
  2020-12-22 14:54 [Tarantool-patches] [PATCH v7 0/3] Fix luacheck warnings in test/box-tap, test/box and test/box-py sergeyb
                   ` (5 preceding siblings ...)
  2021-01-14 21:34 ` Vladislav Shpilevoy via Tarantool-patches
@ 2021-01-15  9:48 ` Kirill Yukhin via Tarantool-patches
  6 siblings, 0 replies; 18+ messages in thread
From: Kirill Yukhin via Tarantool-patches @ 2021-01-15  9:48 UTC (permalink / raw)
  To: sergeyb; +Cc: Sergey Bronnikov, tarantool-patches, v.shpilevoy

Hello,

On 22 дек 17:54, Sergey Bronnikov via Tarantool-patches wrote:
> From: Sergey Bronnikov <estetus@gmail.com>
> 
> Changelog v7:
> - rebased to master branch and fixed new warnings
> - splitted a huge patch series for test/ to a separate issues and patches series
>   (other patches will follow)
> 
> Changelog v6:
> 
> - splitted patch in test/ for patches per sub-directory
> - adjusted supressions in .luacheckrc
> - fixed formatting issues in .luacheckrc
> - fixed warnings in test/vinyl/vinyl.lua and test/vinyl/large.lua
> - added commit with bumping luajit version
> - fixed warnings in test/app-tap/lua/serializer_test.lua

I've checked your patchset into 2.6, 2.7 and master.

--
Regards, Kirill Yukhin

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2021-01-15  9:48 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-22 14:54 [Tarantool-patches] [PATCH v7 0/3] Fix luacheck warnings in test/box-tap, test/box and test/box-py sergeyb
2020-12-22 14:54 ` [Tarantool-patches] [PATCH 1/3] luacheck: fix warnings in test/box sergeyb
2021-01-11 17:52   ` Vladislav Shpilevoy via Tarantool-patches
2021-01-12 15:26     ` Sergey Bronnikov via Tarantool-patches
2021-01-13  7:58       ` Sergey Bronnikov via Tarantool-patches
2021-01-13 16:38       ` Vladislav Shpilevoy via Tarantool-patches
2021-01-14  7:49         ` Sergey Bronnikov via Tarantool-patches
2020-12-22 14:54 ` [Tarantool-patches] [PATCH v7 2/3] luacheck: fix warnings in test/box-py sergeyb
2020-12-22 14:54 ` [Tarantool-patches] [PATCH v7 3/3] luacheck: fix warnings in test/box-tap sergeyb
2021-01-11 17:52   ` Vladislav Shpilevoy via Tarantool-patches
2021-01-12 13:59     ` Sergey Bronnikov via Tarantool-patches
2021-01-12 14:52       ` Vladislav Shpilevoy via Tarantool-patches
2021-01-12 15:21         ` Sergey Bronnikov via Tarantool-patches
2020-12-25 10:37 ` [Tarantool-patches] [PATCH v7 0/3] Fix luacheck warnings in test/box-tap, test/box and test/box-py Kirill Yukhin
2020-12-30 10:17   ` Kirill Yukhin
2020-12-30 12:27 ` Leonid Vasiliev
2021-01-14 21:34 ` Vladislav Shpilevoy via Tarantool-patches
2021-01-15  9:48 ` Kirill Yukhin via Tarantool-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox