[Tarantool-patches] [PATCH 2/6] Fix luacheck warnings in test/

Sergey Bronnikov sergeyb at tarantool.org
Tue Apr 14 10:57:06 MSK 2020


Closes #4681

Reviewed-by: Vladislav Shpilevoy <v.shpilevoy at tarantool.org>
---

 test/app-tap/console.test.lua                 |  4 ---
 test/app-tap/csv.test.lua                     | 28 +++++++++----------
 test/app-tap/logger.test.lua                  |  2 +-
 test/box-py/box.lua                           |  2 +-
 test/box-tap/gc.test.lua                      |  4 +--
 test/box/box.lua                              |  2 +-
 test/box/hash_multipart.result                |  2 +-
 test/box/hash_multipart.test.lua              |  2 +-
 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                    |  4 +--
 test/box/lua/cfg_test6.lua                    |  2 +-
 test/box/lua/utils.lua                        |  3 +-
 test/box/on_schema_init.lua                   |  2 +-
 test/box/proxy.lua                            |  2 +-
 test/box/tiny.lua                             |  2 +-
 test/box/tree_pk.result                       |  4 +--
 test/box/tree_pk.test.lua                     |  4 +--
 test/engine/tree_min_max_count.result         |  2 +-
 test/engine/tree_min_max_count.test.lua       |  2 +-
 test/replication-py/master.lua                |  2 +-
 test/replication-py/panic.lua                 |  2 +-
 test/replication/master.lua                   |  2 +-
 test/replication/replicaset_ro_mostly.result  |  2 +-
 .../replication/replicaset_ro_mostly.test.lua |  2 +-
 test/sql-tap/analyze3.test.lua                |  6 ++--
 test/sql-tap/analyze9.test.lua                | 16 +++++------
 .../gh-4077-iproto-execute-no-bind.test.lua   |  7 +++--
 test/sql-tap/index1.test.lua                  |  1 -
 test/sql-tap/join3.test.lua                   |  2 +-
 test/sql-tap/select9.test.lua                 | 10 ++-----
 test/sql-tap/tkt-fa7bf5ec.test.lua            |  6 ++--
 test/sql-tap/where2.test.lua                  |  2 +-
 test/sql/lua/sql_tokenizer.lua                |  2 +-
 test/sql/savepoints.result                    |  6 ++--
 test/sql/savepoints.test.lua                  |  6 ++--
 test/sql/triggers.result                      |  2 +-
 test/sql/triggers.test.lua                    |  2 +-
 test/vinyl/large.lua                          |  3 +-
 test/vinyl/txn_proxy.lua                      |  6 ++--
 test/vinyl/vinyl.lua                          |  2 +-
 test/wal_off/rtree_benchmark.result           |  2 +-
 test/wal_off/rtree_benchmark.test.lua         |  2 +-
 test/xlog-py/box.lua                          |  2 +-
 test/xlog/panic.lua                           |  2 +-
 test/xlog/reader.result                       |  2 +-
 test/xlog/reader.test.lua                     |  2 +-
 test/xlog/snap_io_rate.test.lua               |  2 +-
 test/xlog/transaction.result                  |  2 +-
 test/xlog/transaction.test.lua                |  2 +-
 test/xlog/xlog.lua                            |  2 +-
 55 files changed, 92 insertions(+), 102 deletions(-)

diff --git a/test/app-tap/console.test.lua b/test/app-tap/console.test.lua
index 4feadfa5e..1f61ba837 100755
--- a/test/app-tap/console.test.lua
+++ b/test/app-tap/console.test.lua
@@ -5,7 +5,6 @@ local console = require('console')
 local socket = require('socket')
 local yaml = require('yaml')
 local fiber = require('fiber')
-local ffi = require('ffi')
 local log = require('log')
 local fio = require('fio')
 
@@ -95,12 +94,9 @@ test:is(#client:read(EOL) > 0, true, "_G")
 client:write("require('fiber').id()\n")
 local fid1 = yaml.decode(client:read(EOL))[1]
 local state = fiber.find(fid1).storage.console
-local server_info = state.client:peer()
 local client_info = state.client:name()
 test:is(client_info.host, client_info.host, "state.socker:peer().host")
 test:is(client_info.port, client_info.port, "state.socker:peer().port")
-server_info = nil
-client_info = nil
 
 -- Check console.delimiter()
 client:write("require('console').delimiter(';')\n")
diff --git a/test/app-tap/csv.test.lua b/test/app-tap/csv.test.lua
index a7f17b1ea..689db7997 100755
--- a/test/app-tap/csv.test.lua
+++ b/test/app-tap/csv.test.lua
@@ -2,9 +2,9 @@
 
 local function table2str(t)
     local res = ""
-    for k, line in pairs(t) do
+    for _, line in pairs(t) do
         local s = ""
-        for k2, field in pairs(line) do
+        for _, field in pairs(line) do
             s = s .. '|' .. field .. '|\t'
         end
         res = res .. s .. '\n'
@@ -12,9 +12,9 @@ local function table2str(t)
     return res
 end
 
-local function myread(self, bytes) 
+local function myread(self, bytes)
     self.i = self.i + bytes
-    return self.v:sub(self.i - bytes + 1, self.i) 
+    return self.v:sub(self.i - bytes + 1, self.i)
 end
 local csv = require('csv')
 local fio = require('fio')
@@ -27,10 +27,10 @@ local test4_ans = '|123|\t|5|\t|92|\t|0|\t|0|\t\n|1|\t|12  34|\t|56|\t' ..
 local test5_ans = "|1|\t\n|23|\t|456|\t|abcac|\t|'multiword field 4'|\t\n" ..
                   "|none|\t|none|\t|0|\t\n||\t||\t||\t\n|aba|\t|adda|\t|f" ..
                   "3|\t|0|\t\n|local res = internal.pwrite(self.fh|\t|dat" ..
-                  "a|\t|len|\t|offset)|\t\n|iflag = bit.bor(iflag|\t|fio." .. 
+                  "a|\t|len|\t|offset)|\t\n|iflag = bit.bor(iflag|\t|fio." ..
                   "c.flag[ flag ])|\t\n||\t||\t||\t\n"
 local test6_ans = "|23|\t|456|\t|abcac|\t|'multiword field 4'|\t\n|none|" ..
-                  "\t|none|\t|0|\t\n||\t||\t||\t\n|aba|\t|adda|\t|f3|\t|" .. 
+                  "\t|none|\t|0|\t\n||\t||\t||\t\n|aba|\t|adda|\t|f3|\t|" ..
                   "0|\t\n|local res = internal.pwrite(self.fh|\t|data|\t" ..
                   "|len|\t|offset)|\t\n|iflag = bit.bor(iflag|\t|fio.c.f" ..
                   "lag[ flag ])|\t\n||\t||\t||\t\n"
@@ -62,7 +62,7 @@ local f = fio.open(file1, { 'O_WRONLY', 'O_TRUNC', 'O_CREAT' }, tonumber('0777',
 f:write("123 , 5  ,       92    , 0, 0\n" ..
         "1, 12  34, 56, \"quote , \", 66\nok")
 f:close()
-f = fio.open(file1, {'O_RDONLY'}) 
+f = fio.open(file1, {'O_RDONLY'})
 test:is(table2str(csv.load(f, {chunk_size = 10})), test4_ans, "fio test1")
 f:close()
 
@@ -77,20 +77,20 @@ f:write("1\n23,456,abcac,\'multiword field 4\'\n" ..
         ",,"
 )
 f:close()
-f = fio.open(file2, {'O_RDONLY'}) 
+f = fio.open(file2, {'O_RDONLY'})
 --symbol by symbol reading
-test:is(table2str(csv.load(f, {chunk_size = 1})), test5_ans, "fio test2") 
+test:is(table2str(csv.load(f, {chunk_size = 1})), test5_ans, "fio test2")
 f:close()
 
-f = fio.open(file2, {'O_RDONLY'}) 
+f = fio.open(file2, {'O_RDONLY'})
 opts = {chunk_size = 7, skip_head_lines = 1}
 --7 symbols per chunk
-test:is(table2str(csv.load(f, opts)), test6_ans, "fio test3") 
+test:is(table2str(csv.load(f, opts)), test6_ans, "fio test3")
 f:close()
 
 t = {
-    {'quote" d', ',and, comma', 'both " of " t,h,e,m'}, 
-    {'"""', ',","'}, 
+    {'quote" d', ',and, comma', 'both " of " t,h,e,m'},
+    {'"""', ',","'},
     {'mul\nti\nli\r\nne\n\n', 'field'},
     {""},
     {'"'},
@@ -100,7 +100,7 @@ t = {
 f = require("fio").open(file3, { "O_WRONLY", "O_TRUNC" , "O_CREAT"}, 0x1FF)
 csv.dump(t, {}, f)
 f:close()
-f = fio.open(file3, {'O_RDONLY'}) 
+f = fio.open(file3, {'O_RDONLY'})
 t2 = csv.load(f, {chunk_size = 5})
 f:close()
 
diff --git a/test/app-tap/logger.test.lua b/test/app-tap/logger.test.lua
index 492d5ea0b..6ec85d0e0 100755
--- a/test/app-tap/logger.test.lua
+++ b/test/app-tap/logger.test.lua
@@ -57,7 +57,7 @@ file:close()
 test:ok(log.pid() >= 0, "pid()")
 
 -- logger uses 'debug', try to set it to nil
-debug = nil
+local debug = nil
 log.info("debug is nil")
 debug = require('debug')
 
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"),
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/box.lua b/test/box/box.lua
index 6fad07015..2cf399f96 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')
 
diff --git a/test/box/hash_multipart.result b/test/box/hash_multipart.result
index e94313b62..e6915652f 100644
--- a/test/box/hash_multipart.result
+++ b/test/box/hash_multipart.result
@@ -62,7 +62,7 @@ test_run:cmd("setopt delimiter ';'")
 function select_all()
     local result = {}
     local tuple, v
-    for tuple, v in hash:pairs() do
+    for _, v in hash:pairs() do
         table.insert(result, v)
     end
     return result
diff --git a/test/box/hash_multipart.test.lua b/test/box/hash_multipart.test.lua
index c0a871bee..c572d13b6 100644
--- a/test/box/hash_multipart.test.lua
+++ b/test/box/hash_multipart.test.lua
@@ -24,7 +24,7 @@ test_run:cmd("setopt delimiter ';'")
 function select_all()
     local result = {}
     local tuple, v
-    for tuple, v in hash:pairs() do
+    for _, v in hash:pairs() do
         table.insert(result, v)
     end
     return result
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..8b6f9b31c 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"),
@@ -7,4 +7,4 @@ box.cfg{
 }
 
 require('console').listen(os.getenv('ADMIN'))
-box.schema.user.grant('guest', 'read,write,execute', 'universe')
\ No newline at end of file
+box.schema.user.grant('guest', 'read,write,execute', 'universe')
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/utils.lua b/test/box/lua/utils.lua
index 5f859fd19..058c4a471 100644
--- a/test/box/lua/utils.lua
+++ b/test/box/lua/utils.lua
@@ -212,10 +212,9 @@ function create_iterator(obj, key, opts)
         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..f74d6d7fe 100644
--- a/test/box/on_schema_init.lua
+++ b/test/box/on_schema_init.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
 
 function test_before_replace_trig(old, new)
     -- return multiple values so that the stack fills earlier.
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"),
diff --git a/test/box/tree_pk.result b/test/box/tree_pk.result
index df3c78bed..f2a4f5352 100644
--- a/test/box/tree_pk.result
+++ b/test/box/tree_pk.result
@@ -153,8 +153,8 @@ test_run:cmd("setopt delimiter ';'")
 ...
 function crossjoin(space0, space1, limit)
     local result = {}
-    for state, v0 in space0:pairs() do
-        for state, v1 in space1:pairs() do
+    for _, v0 in space0:pairs() do
+        for _, v1 in space1:pairs() do
             if limit <= 0 then
                 return result
             end
diff --git a/test/box/tree_pk.test.lua b/test/box/tree_pk.test.lua
index 1190ab424..86041a642 100644
--- a/test/box/tree_pk.test.lua
+++ b/test/box/tree_pk.test.lua
@@ -58,8 +58,8 @@ test_run = env.new()
 test_run:cmd("setopt delimiter ';'")
 function crossjoin(space0, space1, limit)
     local result = {}
-    for state, v0 in space0:pairs() do
-        for state, v1 in space1:pairs() do
+    for _, v0 in space0:pairs() do
+        for _, v1 in space1:pairs() do
             if limit <= 0 then
                 return result
             end
diff --git a/test/engine/tree_min_max_count.result b/test/engine/tree_min_max_count.result
index f55732aa6..9f1595a20 100644
--- a/test/engine/tree_min_max_count.result
+++ b/test/engine/tree_min_max_count.result
@@ -1189,7 +1189,7 @@ space6:drop()
 ---
 ...
 -- min max count after many inserts
-string = require('string')
+local string = require('string')
 ---
 ...
 space7 = box.schema.space.create('space7', { engine = engine })
diff --git a/test/engine/tree_min_max_count.test.lua b/test/engine/tree_min_max_count.test.lua
index 0633c56b3..19b5fe92d 100644
--- a/test/engine/tree_min_max_count.test.lua
+++ b/test/engine/tree_min_max_count.test.lua
@@ -337,7 +337,7 @@ space6:drop()
 
 -- min max count after many inserts
 
-string = require('string')
+local string = require('string')
 
 space7 = box.schema.space.create('space7', { engine = engine })
 index7 = space7:create_index('primary', { type = 'tree', parts = {1, 'scalar'} })
diff --git a/test/replication-py/master.lua b/test/replication-py/master.lua
index e924b5495..b43bafd54 100644
--- a/test/replication-py/master.lua
+++ b/test/replication-py/master.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
 box.cfg({
     listen              = os.getenv("LISTEN"),
     memtx_memory        = 107374182,
diff --git a/test/replication-py/panic.lua b/test/replication-py/panic.lua
index 75a738cbb..e72d11419 100644
--- a/test/replication-py/panic.lua
+++ b/test/replication-py/panic.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
 box.cfg({
     listen              = os.getenv("LISTEN"),
     memtx_memory        = 107374182,
diff --git a/test/replication/master.lua b/test/replication/master.lua
index e924b5495..b43bafd54 100644
--- a/test/replication/master.lua
+++ b/test/replication/master.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
 box.cfg({
     listen              = os.getenv("LISTEN"),
     memtx_memory        = 107374182,
diff --git a/test/replication/replicaset_ro_mostly.result b/test/replication/replicaset_ro_mostly.result
index a471779d3..e509e0da0 100644
--- a/test/replication/replicaset_ro_mostly.result
+++ b/test/replication/replicaset_ro_mostly.result
@@ -35,7 +35,7 @@ test_run:cmd("setopt delimiter ';'")
 - true
 ...
 function create_cluster_uuid(servers, uuids)
-    for i, name in ipairs(servers) do
+    for _, name in ipairs(servers) do
         test_run:cmd(create_cluster_cmd1:format(name, name))
     end
     for i, name in ipairs(servers) do
diff --git a/test/replication/replicaset_ro_mostly.test.lua b/test/replication/replicaset_ro_mostly.test.lua
index 19cd1fe4a..e06e29c8e 100644
--- a/test/replication/replicaset_ro_mostly.test.lua
+++ b/test/replication/replicaset_ro_mostly.test.lua
@@ -16,7 +16,7 @@ create_cluster_cmd2 = 'start server %s with args="%s", wait_load=False, wait=Fal
 
 test_run:cmd("setopt delimiter ';'")
 function create_cluster_uuid(servers, uuids)
-    for i, name in ipairs(servers) do
+    for _, name in ipairs(servers) do
         test_run:cmd(create_cluster_cmd1:format(name, name))
     end
     for i, name in ipairs(servers) do
diff --git a/test/sql-tap/analyze3.test.lua b/test/sql-tap/analyze3.test.lua
index dcbea1da5..5c9c28601 100755
--- a/test/sql-tap/analyze3.test.lua
+++ b/test/sql-tap/analyze3.test.lua
@@ -23,15 +23,15 @@ testprefix = "analyze3"
 ------------------------------------------------------------------------
 -- Test Organization:
 --
--- analyze3-1.*: Test that the values of bound parameters are considered 
+-- analyze3-1.*: Test that the values of bound parameters are considered
 --               in the same way as constants when planning queries that
 --               use range constraints.
 --
--- analyze3-2.*: Test that the values of bound parameters are considered 
+-- analyze3-2.*: Test that the values of bound parameters are considered
 --               in the same way as constants when planning queries that
 --               use LIKE expressions in the WHERE clause.
 --
--- analyze3-3.*: Test that binding to a variable does not invalidate the 
+-- analyze3-3.*: Test that binding to a variable does not invalidate the
 --               query plan when there is no way in which replanning the
 --               query may produce a superior outcome.
 --
diff --git a/test/sql-tap/analyze9.test.lua b/test/sql-tap/analyze9.test.lua
index 02eb49f69..7412ba5fe 100755
--- a/test/sql-tap/analyze9.test.lua
+++ b/test/sql-tap/analyze9.test.lua
@@ -609,7 +609,7 @@ test:do_execsql_test(
 test:do_test(
     "10.1.2",
     function()
-        local a = 0
+        local a
         for i = 1, 100 do
             if i > 90 then
                 a = i
@@ -657,7 +657,7 @@ test:do_execsql_test(
 test:do_test(
     "10.2.2",
     function()
-        local a = 0
+        local a
         for i = 1, 100 do
             if i > 90 then
                 a = i
@@ -711,7 +711,7 @@ test:do_execsql_test(
 test:do_test(
     11.1,
     function()
-        local a = 0
+        local a
         for i = 0, 100 do
             if i % 10 == 0 then 
                 a = "\"ABC\""
@@ -762,7 +762,7 @@ test:do_execsql_test(
 test:do_test(
     11.5,
     function()
-        local a = 0
+        local a
         for i = 0, 100 do
             if i % 10 == 0 then 
                 a = "\"ABC\""
@@ -823,7 +823,7 @@ test:do_execsql_test(
 test:do_test(
     12.1,
     function()
-        local a = 0
+        local a
         for i = 0, 100 do
             if i % 10 == 0 then 
                 a = "\"ABC\""
@@ -874,7 +874,7 @@ test:do_execsql_test(
 test:do_test(
     12.5,
     function()
-        local a = 0
+        local a
         for i = 0, 100 do
             if i % 10 == 0 then 
                 a = "\"ABC\""
@@ -931,7 +931,7 @@ test:do_test(
         test:execsql("CREATE TABLE t1(id INTEGER PRIMARY KEY AUTOINCREMENT, a TEXT, b INT, c INT, d INT);")
         test:execsql("CREATE INDEX i1 ON t1(a);")
         test:execsql("CREATE INDEX i2 ON t1(b, c);")
-        local a = 0
+        local a
         for i = 0, 100 do
             if i % 2 == 1 then
                 a = "\"abc\""
@@ -1161,7 +1161,7 @@ test:do_test(
             INSERT INTO t1 SELECT null, 2*a,2*b,2*c,d FROM t1;
             INSERT INTO t1 SELECT null, 2*a,2*b,2*c,d FROM t1;
         ]])
-        local b = 0
+        local b
         for i = 0, 31 do
             if (i < 8) then
                 b = 0
diff --git a/test/sql-tap/gh-4077-iproto-execute-no-bind.test.lua b/test/sql-tap/gh-4077-iproto-execute-no-bind.test.lua
index d4b597e35..2f71a68ea 100755
--- a/test/sql-tap/gh-4077-iproto-execute-no-bind.test.lua
+++ b/test/sql-tap/gh-4077-iproto-execute-no-bind.test.lua
@@ -41,10 +41,11 @@ local size = msgpack.encode(header:len() + body:len())
 sock:write(size .. header .. body)
 
 -- Read response.
-local size = msgpack.decode(sock:read(5))
+size = msgpack.decode(sock:read(5))
 local header_body = sock:read(size)
-local header, header_len = msgpack.decode(header_body)
-local body = msgpack.decode(header_body:sub(header_len))
+local header_len
+header, header_len = msgpack.decode(header_body)
+body = msgpack.decode(header_body:sub(header_len))
 sock:close()
 
 -- Verify response.
diff --git a/test/sql-tap/index1.test.lua b/test/sql-tap/index1.test.lua
index e173e685c..4c4a37ca7 100755
--- a/test/sql-tap/index1.test.lua
+++ b/test/sql-tap/index1.test.lua
@@ -106,7 +106,6 @@ test:do_test(
 test:do_test(
     "index-2.2",
     function()
-        local msg
         local v , msg= pcall(function()
             test:execsql("CREATE INDEX index1 ON test1(f1, f2, f4, f3)")
             end)
diff --git a/test/sql-tap/join3.test.lua b/test/sql-tap/join3.test.lua
index 876b3121a..030fbaba3 100755
--- a/test/sql-tap/join3.test.lua
+++ b/test/sql-tap/join3.test.lua
@@ -49,7 +49,7 @@ for N=1, bitmask_size do
 end
 -- Joins with a comparison
 --
-local result = {}
+result = {}
 --for _ in X(0, "X!for", [=[["set N 1","$N<=$bitmask_size","incr N"]]=]) do
 for N=1, bitmask_size do
     table.insert(result,N)
diff --git a/test/sql-tap/select9.test.lua b/test/sql-tap/select9.test.lua
index 1ae16a658..bcc270593 100755
--- a/test/sql-tap/select9.test.lua
+++ b/test/sql-tap/select9.test.lua
@@ -60,10 +60,8 @@ function subrange(t, first, last)
 end
 
 local function test_compound_select(testname, sql, result)
-    local nCol = 1
     local A = box.execute(sql) --test.box(sql)
-    nCol = #A.metadata
-    A = A.rows
+    local nCol = #A.metadata
     local nRow = #result / nCol
     local compound_sql = sql
     test:do_execsql_test(
@@ -274,10 +272,8 @@ test:do_execsql_test(
         -- </select9-2.0>
     })
 
-local t1_space_id = ""
-local t2_space_id = ""
-t1_space_id = test:execsql([[SELECT * from "_space" where "name"='T1']])["id"]
-t2_space_id = test:execsql([[SELECT * from "_space" where "name"='T2']])["id"]
+local t1_space_id = test:execsql([[SELECT * from "_space" where "name"='T1']])["id"]
+local t2_space_id = test:execsql([[SELECT * from "_space" where "name"='T2']])["id"]
 --X(276, "X!cmd", [=[["db","eval","SELECT * from _space where name='t2'","data","\n  set t2_space_id $data(id)\n"]]=])
 --local function reverse(lhs, rhs)
 --    return X(283, "X!cmd", [=[["string","compare",["rhs"],["lhs"]]]=])
diff --git a/test/sql-tap/tkt-fa7bf5ec.test.lua b/test/sql-tap/tkt-fa7bf5ec.test.lua
index 7152e028c..25d44c9d3 100755
--- a/test/sql-tap/tkt-fa7bf5ec.test.lua
+++ b/test/sql-tap/tkt-fa7bf5ec.test.lua
@@ -20,9 +20,9 @@ test:plan(1)
 -- The problem described by this ticket was that the sqlExprCompare()
 -- function was saying that expressions (x='a') and (x='A') were identical
 -- because it was using sqlStrICmp() instead of strcmp() to compare string
--- literals.  That was causing the query optimizer for aggregate queries to 
--- believe that both count() operations were identical, and thus only 
--- computing the first count() and making a copy of the result for the 
+-- literals.  That was causing the query optimizer for aggregate queries to
+-- believe that both count() operations were identical, and thus only
+-- computing the first count() and making a copy of the result for the
 -- second count().
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
diff --git a/test/sql-tap/where2.test.lua b/test/sql-tap/where2.test.lua
index f267be8e6..f2db6fcee 100755
--- a/test/sql-tap/where2.test.lua
+++ b/test/sql-tap/where2.test.lua
@@ -115,7 +115,7 @@ local function queryplan(sql)
                 table.insert(data, tab)
                 table.insert(data, idx)
             else
-                as, tab = string.match(v, "TABLE (%w+ AS) (%w+)")
+                _, tab = string.match(v, "TABLE (%w+ AS) (%w+)")
                 if tab == nil  then
                     tab = string.match(v, "TABLE (%w+)")
                 end
diff --git a/test/sql/lua/sql_tokenizer.lua b/test/sql/lua/sql_tokenizer.lua
index 9922d792d..ffe4fb4e8 100644
--- a/test/sql/lua/sql_tokenizer.lua
+++ b/test/sql/lua/sql_tokenizer.lua
@@ -134,7 +134,7 @@ end
 -- @retval Token type. If the rest of the SQL request consists of
 --         spaces and comments, then return TK_EMPTY.
 local function get_next_token(context)
-    local c = ''
+    local c
     repeat
         local i = context.offset
         c = context.sql:sub(i, i)
diff --git a/test/sql/savepoints.result b/test/sql/savepoints.result
index 509c33e59..b0915f398 100644
--- a/test/sql/savepoints.result
+++ b/test/sql/savepoints.result
@@ -102,12 +102,12 @@ collision_sv_2 = function()
     box.begin()
     box.execute('SAVEPOINT t1;')
     box.execute('SAVEPOINT t2;')
-    local _,err = box.execute('SAVEPOINT t1;')
+    local _, err = box.execute('SAVEPOINT t1;')
     assert(err == nil)
     box.execute('RELEASE SAVEPOINT t1;')
-    local _,err = box.execute('RELEASE SAVEPOINT t1;')
+    _, err = box.execute('RELEASE SAVEPOINT t1;')
     assert(err ~= nil)
-    local _, err = box.execute('ROLLBACK TO t2;')
+    _, err = box.execute('ROLLBACK TO t2;')
     assert(err == nil)
 end;
 ---
diff --git a/test/sql/savepoints.test.lua b/test/sql/savepoints.test.lua
index f1b15c748..eb7bea37d 100644
--- a/test/sql/savepoints.test.lua
+++ b/test/sql/savepoints.test.lua
@@ -65,12 +65,12 @@ collision_sv_2 = function()
     box.begin()
     box.execute('SAVEPOINT t1;')
     box.execute('SAVEPOINT t2;')
-    local _,err = box.execute('SAVEPOINT t1;')
+    local _, err = box.execute('SAVEPOINT t1;')
     assert(err == nil)
     box.execute('RELEASE SAVEPOINT t1;')
-    local _,err = box.execute('RELEASE SAVEPOINT t1;')
+    _, err = box.execute('RELEASE SAVEPOINT t1;')
     assert(err ~= nil)
-    local _, err = box.execute('ROLLBACK TO t2;')
+    _, err = box.execute('ROLLBACK TO t2;')
     assert(err == nil)
 end;
 collision_sv_2();
diff --git a/test/sql/triggers.result b/test/sql/triggers.result
index ceecb8ef2..e70d72947 100644
--- a/test/sql/triggers.result
+++ b/test/sql/triggers.result
@@ -11,7 +11,7 @@ _ = box.space._session_settings:update('sql_default_engine', {{'=', 2, engine}})
 ---
 ...
 -- Get invariant part of the tuple; name and opts don't change.
- function immutable_part(data) local r = {} for i, l in pairs(data) do table.insert(r, {l.name, l.opts}) end return r end
+ function immutable_part(data) local r = {} for _, l in pairs(data) do table.insert(r, {l.name, l.opts}) end return r end
 ---
 ...
 --
diff --git a/test/sql/triggers.test.lua b/test/sql/triggers.test.lua
index f5c8a3961..bc694ebc4 100644
--- a/test/sql/triggers.test.lua
+++ b/test/sql/triggers.test.lua
@@ -4,7 +4,7 @@ engine = test_run:get_cfg('engine')
 _ = box.space._session_settings:update('sql_default_engine', {{'=', 2, engine}})
 
 -- Get invariant part of the tuple; name and opts don't change.
- function immutable_part(data) local r = {} for i, l in pairs(data) do table.insert(r, {l.name, l.opts}) end return r end
+ function immutable_part(data) local r = {} for _, l in pairs(data) do table.insert(r, {l.name, l.opts}) end return r end
 
 --
 -- gh-3273: Move Triggers to server
diff --git a/test/vinyl/large.lua b/test/vinyl/large.lua
index e10e94c1a..a997aec7e 100644
--- a/test/vinyl/large.lua
+++ b/test/vinyl/large.lua
@@ -1,5 +1,4 @@
-fiber = require('fiber')
-digest = require('digest')
+local digest = require('digest')
 
 local PAGE_SIZE = 1024
 local RANGE_SIZE = 64 * PAGE_SIZE
diff --git a/test/vinyl/txn_proxy.lua b/test/vinyl/txn_proxy.lua
index 7a4d0b865..15b0e4add 100644
--- a/test/vinyl/txn_proxy.lua
+++ b/test/vinyl/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/vinyl/vinyl.lua b/test/vinyl/vinyl.lua
index 31307f4bc..02b5c010b 100644
--- a/test/vinyl/vinyl.lua
+++ b/test/vinyl/vinyl.lua
@@ -15,7 +15,7 @@ box.cfg {
     vinyl_max_tuple_size = 1024 * 1024 * 6,
 }
 
-function box_info_sort(data)
+local function box_info_sort(data)
     if type(data)~='table' then
         return data
     end
diff --git a/test/wal_off/rtree_benchmark.result b/test/wal_off/rtree_benchmark.result
index 8e01c9f2a..8deefca82 100644
--- a/test/wal_off/rtree_benchmark.result
+++ b/test/wal_off/rtree_benchmark.result
@@ -163,7 +163,7 @@ for i = 1, 0 do
    for j = 1, dimension do
       table.insert(rect, 180*math.random())
    end
-   for k,v in pairs(s.index.spatial:select(rect, {limit = n_neighbors, iterator = 'NEIGHBOR'})) do
+   for _,_ in pairs(s.index.spatial:select(rect, {limit = n_neighbors, iterator = 'NEIGHBOR'})) do
       n = n + 1
    end
 end;
diff --git a/test/wal_off/rtree_benchmark.test.lua b/test/wal_off/rtree_benchmark.test.lua
index 6fae977c9..6bdc0a758 100644
--- a/test/wal_off/rtree_benchmark.test.lua
+++ b/test/wal_off/rtree_benchmark.test.lua
@@ -96,7 +96,7 @@ for i = 1, 0 do
    for j = 1, dimension do
       table.insert(rect, 180*math.random())
    end
-   for k,v in pairs(s.index.spatial:select(rect, {limit = n_neighbors, iterator = 'NEIGHBOR'})) do
+   for _,_ in pairs(s.index.spatial:select(rect, {limit = n_neighbors, iterator = 'NEIGHBOR'})) do
       n = n + 1
    end
 end;
diff --git a/test/xlog-py/box.lua b/test/xlog-py/box.lua
index c87f7b94b..8b9e9434f 100644
--- a/test/xlog-py/box.lua
+++ b/test/xlog-py/box.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/xlog/panic.lua b/test/xlog/panic.lua
index 2d4eb8d2e..0fa855421 100644
--- a/test/xlog/panic.lua
+++ b/test/xlog/panic.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/xlog/reader.result b/test/xlog/reader.result
index 9985aa2ac..74ac3579e 100644
--- a/test/xlog/reader.result
+++ b/test/xlog/reader.result
@@ -40,7 +40,7 @@ trun:cmd("setopt delimiter ';'")
 ...
 function collect_results(file)
     local val = {}
-    for k, v in xlog(file) do
+    for _, v in xlog(file) do
         table.insert(val, setmetatable(v, { __serialize = "map"}))
     end
     return val
diff --git a/test/xlog/reader.test.lua b/test/xlog/reader.test.lua
index 327af54dd..707ba394b 100644
--- a/test/xlog/reader.test.lua
+++ b/test/xlog/reader.test.lua
@@ -21,7 +21,7 @@ pattern_ok_v13 = fio.pathjoin(pattern_prefix, "v13/")
 trun:cmd("setopt delimiter ';'")
 function collect_results(file)
     local val = {}
-    for k, v in xlog(file) do
+    for _, v in xlog(file) do
         table.insert(val, setmetatable(v, { __serialize = "map"}))
     end
     return val
diff --git a/test/xlog/snap_io_rate.test.lua b/test/xlog/snap_io_rate.test.lua
index f71296269..5626ea1f4 100644
--- a/test/xlog/snap_io_rate.test.lua
+++ b/test/xlog/snap_io_rate.test.lua
@@ -9,6 +9,6 @@ for i = 0, 127 do box.space.snap:replace({i, digest.urandom(512 * 1024)}) end
 t1 = fiber.time()
 box.snapshot()
 t2 = fiber.time()
-t2 - t1 > 64 / box.cfg.snap_io_rate_limit * 0.95
+assert(t2 - t1 > 64 / box.cfg.snap_io_rate_limit * 0.95)
 
 box.space.snap:drop()
diff --git a/test/xlog/transaction.result b/test/xlog/transaction.result
index 63adb0f25..d45b60b0a 100644
--- a/test/xlog/transaction.result
+++ b/test/xlog/transaction.result
@@ -16,7 +16,7 @@ test_run:cmd("setopt delimiter ';'")
 ...
 function read_xlog(file)
     local val = {}
-    for k, v in xlog(file) do
+    for _, v in xlog(file) do
         table.insert(val, setmetatable(v, { __serialize = "map"}))
     end
     return val
diff --git a/test/xlog/transaction.test.lua b/test/xlog/transaction.test.lua
index 2d8090b4c..5fdeec625 100644
--- a/test/xlog/transaction.test.lua
+++ b/test/xlog/transaction.test.lua
@@ -6,7 +6,7 @@ test_run = env.new()
 test_run:cmd("setopt delimiter ';'")
 function read_xlog(file)
     local val = {}
-    for k, v in xlog(file) do
+    for _, v in xlog(file) do
         table.insert(val, setmetatable(v, { __serialize = "map"}))
     end
     return val
diff --git a/test/xlog/xlog.lua b/test/xlog/xlog.lua
index 004096d2d..aaf1a0ae6 100644
--- a/test/xlog/xlog.lua
+++ b/test/xlog/xlog.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
 
 box.cfg{
     listen              = os.getenv("LISTEN"),
-- 
2.23.0


-- 
sergeyb@


More information about the Tarantool-patches mailing list