[Tarantool-patches] [PATCH v8 08/14] test: fix luacheck warnings W311 in test/sql-tap

sergeyb at tarantool.org sergeyb at tarantool.org
Thu Jan 21 15:50:07 MSK 2021


From: Sergey Bronnikov <sergeyb at tarantool.org>

W311 (Value assigned to a local variable is unused)

Part of #5464
---
 .luacheckrc                    |  2 --
 test/sql-tap/analyze9.test.lua | 16 ++++++++--------
 test/sql-tap/select9.test.lua  |  3 +--
 test/sql-tap/triggerA.test.lua |  1 -
 test/sql-tap/where2.test.lua   |  2 +-
 5 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/.luacheckrc b/.luacheckrc
index bfce2a6b4..31f9528ad 100644
--- a/.luacheckrc
+++ b/.luacheckrc
@@ -51,8 +51,6 @@ exclude_files = {
 
 files["test/sql-tap/**/*.lua"] = {
     ignore = {
-        -- "Value assigned to a local variable is unused."
-        "311",
         -- Unreachable code.
         "511",
         -- Loop can be executed at most once.
diff --git a/test/sql-tap/analyze9.test.lua b/test/sql-tap/analyze9.test.lua
index 794bda379..7a24d6752 100755
--- a/test/sql-tap/analyze9.test.lua
+++ b/test/sql-tap/analyze9.test.lua
@@ -613,7 +613,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
@@ -661,7 +661,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
@@ -715,7 +715,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\""
@@ -766,7 +766,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\""
@@ -827,7 +827,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\""
@@ -878,7 +878,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\""
@@ -935,7 +935,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\""
@@ -1165,7 +1165,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/select9.test.lua b/test/sql-tap/select9.test.lua
index 045d0e4c8..769f70069 100755
--- a/test/sql-tap/select9.test.lua
+++ b/test/sql-tap/select9.test.lua
@@ -60,10 +60,9 @@ local function subrange(t, first, last)
 end
 
 local function test_compound_select(testname, sql, result)
-    local nCol = 1
+    local nCol
     local A = box.execute(sql) --test.box(sql)
     nCol = #A.metadata
-    A = A.rows
     local nRow = #result / nCol
     local compound_sql = sql
     test:do_execsql_test(
diff --git a/test/sql-tap/triggerA.test.lua b/test/sql-tap/triggerA.test.lua
index 6a801bda2..f0e11d627 100755
--- a/test/sql-tap/triggerA.test.lua
+++ b/test/sql-tap/triggerA.test.lua
@@ -45,7 +45,6 @@ test:do_test(
                 INSERT INTO t1 VALUES(%d,'%s');
                 INSERT INTO t2 VALUES(20-%d,%d,'%s');
             ]], i, word, i, j, word))
-            i = i + 1
         end
         return test:execsql [[
             SELECT count(*) FROM t1 UNION ALL SELECT count(*) FROM t2;
diff --git a/test/sql-tap/where2.test.lua b/test/sql-tap/where2.test.lua
index 19611a05f..db7edd539 100755
--- a/test/sql-tap/where2.test.lua
+++ b/test/sql-tap/where2.test.lua
@@ -103,7 +103,7 @@ local function queryplan(sql)
                 table.insert(data, tab)
                 table.insert(data, idx)
             else
-                as, tab = string.match(v, "TABLE (%w+ AS) (%w+)")
+                local _, tab = string.match(v, "TABLE (%w+ AS) (%w+)")
                 if tab == nil  then
                     tab = string.match(v, "TABLE (%w+)")
                 end
-- 
2.25.1



More information about the Tarantool-patches mailing list