Skip to content

Commit

Permalink
test: fix luacheck warnings in test/sql-tap (W211)
Browse files Browse the repository at this point in the history
W211 (Unused local variable)

Part of #5464
  • Loading branch information
ligurio committed Jan 20, 2021
1 parent c6a4876 commit 8ca1cbe
Show file tree
Hide file tree
Showing 79 changed files with 18 additions and 143 deletions.
2 changes: 0 additions & 2 deletions .luacheckrc
Expand Up @@ -57,8 +57,6 @@ files["test/sql-tap/**/*.lua"] = {
ignore = {
-- Accessing an undefined global variable.
"113",
-- Unused local variable.
"211",
-- Unused argument.
"212",
-- Unused loop variable.
Expand Down
2 changes: 0 additions & 2 deletions test/sql-tap/analyze3.test.lua
Expand Up @@ -2,8 +2,6 @@
local test = require("sqltester")
test:plan(37)

local testprefix = "analyze3"

--!./tcltestrunner.lua
-- 2009 August 06
--
Expand Down
1 change: 0 additions & 1 deletion test/sql-tap/analyze5.test.lua
Expand Up @@ -21,7 +21,6 @@ local json = require("json")
-- with many repeated values and only a few distinct values.
--

local testprefix = "analyze5"
local function eqp(sql)
return test:execsql("EXPLAIN QUERY PLAN"..sql)
end
Expand Down
2 changes: 0 additions & 2 deletions test/sql-tap/analyze6.test.lua
Expand Up @@ -21,8 +21,6 @@ test:plan(13)
-- ["set","testdir",[["file","dirname",["argv0"]]]]
-- ["source",[["testdir"],"\/tester.tcl"]]

local testprefix = "analyze6"

test:do_test(
"analyze6-1.0",
function()
Expand Down
2 changes: 0 additions & 2 deletions test/sql-tap/analyze8.test.lua
Expand Up @@ -18,8 +18,6 @@ test:plan(15)
-- in this file is testing the capabilities of sql_stat3.
--

local testprefix = "analyze8"

-- Scenario:
--
-- Two indices. One has mostly singleton entries, but for a few
Expand Down
2 changes: 0 additions & 2 deletions test/sql-tap/analyze9.test.lua
Expand Up @@ -2,8 +2,6 @@
local test = require("sqltester")
test:plan(121)

local testprefix = "analyze9"

--!./tcltestrunner.lua
-- 2013 August 3
--
Expand Down
3 changes: 0 additions & 3 deletions test/sql-tap/analyzeC.test.lua
Expand Up @@ -2,9 +2,6 @@
local test = require("sqltester")
test:plan(20)

local testprefix = "analyzeC"


--!./tcltestrunner.lua
-- 2014-07-22
--
Expand Down
2 changes: 0 additions & 2 deletions test/sql-tap/analyzeD.test.lua
Expand Up @@ -2,8 +2,6 @@
local test = require("sqltester")
test:plan(15)

local testprefix = "analyzeD"

--!./tcltestrunner.lua
-- 2005 July 22
--
Expand Down
2 changes: 0 additions & 2 deletions test/sql-tap/analyzeE.test.lua
Expand Up @@ -2,8 +2,6 @@
local test = require("sqltester")
test:plan(48)

local testprefix = "analyzeE"

--!./tcltestrunner.lua
-- 2014-10-08
--
Expand Down
2 changes: 0 additions & 2 deletions test/sql-tap/analyzeF.test.lua
Expand Up @@ -2,8 +2,6 @@
local test = require("sqltester")
test:plan(18)

local testprefix = "analyzeF"

--!./tcltestrunner.lua
-- 2015-03-12
--
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/check.test.lua
Expand Up @@ -19,7 +19,7 @@ test:plan(61)
-- $Id: check.test,v 1.13 2009/06/05 17:09:12 drh Exp $
-- ["set","testdir",[["file","dirname",["argv0"]]]]
-- ["source",[["testdir"],"\/tester.tcl"]]
local testprefix = "check"

-- Only run these tests if the build includes support for CHECK constraints


Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/colname.test.lua
Expand Up @@ -35,7 +35,7 @@ test:plan(79)
--
-- Verify the default settings for full_column_name
--
local function lreplace(arr, pos, len, val)
local function lreplace(arr, pos, len, val) -- luacheck: no unused
for i = pos + 1, pos + len + 1, 1 do
arr[i] = val
end
Expand Down
1 change: 0 additions & 1 deletion test/sql-tap/count.test.lua
Expand Up @@ -105,7 +105,6 @@ for _, zIndex in ipairs(queries) do
})

end
local json = require("json")
local function uses_op_count(sql)
if test:lsearch(test:execsql("EXPLAIN "..sql), "Count")>0 then
return 1
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/delete4.test.lua
Expand Up @@ -18,7 +18,7 @@ test:plan(14)
--
-- ["set","testdir",[["file","dirname",["argv0"]]]]
-- ["source",[["testdir"],"\/tester.tcl"]]
local testprefix = "delete4"

test:do_execsql_test(
1.1,
[[
Expand Down
1 change: 0 additions & 1 deletion test/sql-tap/distinct.test.lua
Expand Up @@ -19,7 +19,6 @@ test:plan(56)
-- ["set","testdir",[["file","dirname",["argv0"]]]]
-- ["source",[["testdir"],"\/tester.tcl"]]

local testprefix = "distinct"
local function is_distinct_noop(sql)
local sql1 = sql
local sql2 = string.gsub(sql, "DISTINCT", "")
Expand Down
2 changes: 0 additions & 2 deletions test/sql-tap/e_expr.test.lua
Expand Up @@ -1080,7 +1080,6 @@ if (0>0) then
local function parameter_test(tn, sql, params, result)
local stmt = sql_prepare_v2("db", sql, -1)
for _ in X(0, "X!foreach", [=[["number name",["params"]]]=]) do
local nm = sql_bind_parameter_name(stmt, number)
X(480, "X!cmd", [=[["do_test",[["tn"],".name.",["number"]],[["list","set","",["nm"]]],["name"]]]=])
sql_bind_int(stmt, number, ((-1) * number))
end
Expand All @@ -1089,7 +1088,6 @@ if (0>0) then
for _ in X(0, "X!for", [=[["set i 0","$i < [sql_column_count $stmt]","incr i"]]=]) do
table.insert(res,sql_column_text(stmt, i))
end
local rc = sql_finalize(stmt)
X(491, "X!cmd", [=[["do_test",[["tn"],".rc"],[["list","set","",["rc"]]],"sql_OK"]]=])
X(492, "X!cmd", [=[["do_test",[["tn"],".res"],[["list","set","",["res"]]],["result"]]]=])
end
Expand Down
4 changes: 1 addition & 3 deletions test/sql-tap/e_select1.test.lua
Expand Up @@ -970,7 +970,7 @@ for _ in X(0, "X!foreach", [=[["tn select","\n 8.1 \"SELECT count(*) FROM a1\"
do
nRow = nRow + 1
end
local rc = sql_finalize(stmt)
sql_finalize(stmt)
-- Test that $nRow==1 and that statement execution was successful
-- (rc==sql_OK).
X(983, "X!cmd", [=[["do_test",["e_select-4.",["tn"]],[["list","list",["rc"],["nRow"]]],"sql_OK 1"]]=])
Expand Down Expand Up @@ -1421,7 +1421,6 @@ data = {
{23, "SELECT * FROM j1 INTERSECT SELECT * FROM j2,j3 LIMIT 10 OFFSET 5"},
{24, "SELECT a FROM j1 INTERSECT SELECT g FROM j2,j3 LIMIT (SELECT 10)"}
}
local json = require("json")
for _, val in ipairs(data) do
local tn = val[1]
local select = val[2]
Expand Down Expand Up @@ -2165,7 +2164,6 @@ for _, val in ipairs({
{"5", "SELECT b FROM f1 ORDER BY a LIMIT (SELECT group_concat(b) FROM f1)"}}) do
local tn = val[1]
local select = val[2]
local err_param = val[3]
test:do_catchsql_test(
"e_select-9.2."..tn,
select,
Expand Down
2 changes: 0 additions & 2 deletions test/sql-tap/eqp.test.lua
Expand Up @@ -17,8 +17,6 @@ test:plan(70)
-- ["set","testdir",[["file","dirname",["argv0"]]]]
-- ["source",[["testdir"],"\/tester.tcl"]]


local testprefix = "eqp"
---------------------------------------------------------------------------
--
-- eqp-1.*: Assorted tests.
Expand Down
9 changes: 2 additions & 7 deletions test/sql-tap/func.test.lua
Expand Up @@ -18,7 +18,7 @@ test:plan(14694)
--
-- ["set","testdir",[["file","dirname",["argv0"]]]]
-- ["source",[["testdir"],"\/tester.tcl"]]
local testprefix = "func"

-- Create a table to work with.
--
test:do_test(
Expand Down Expand Up @@ -1048,7 +1048,7 @@ test:do_execsql_test(
--
-- MUST_WORK_TEST testfunc not implemented
if 0 > 0 then
local DB = sql_connection_pointer("db")
sql_connection_pointer("db")
X(525, "X!cmd", [=[["sql_register_test_function",["::DB"],"testfunc"]]=])
test:do_catchsql_test(
"func-10.1",
Expand Down Expand Up @@ -1349,7 +1349,6 @@ test:do_execsql_test(
-- </13.8.3>
})

local V = "one"
test:do_execsql_test(
"13.8.4",
[[
Expand Down Expand Up @@ -1473,10 +1472,6 @@ test:do_test(
test:do_test(
"func-17.1",
function()
local function testfunc1(args)
X(768, "X!cmd", [=[["error","Error %d with %s percents %p"]]=])
end

db("function", "testfunc1", "::testfunc1")
return test:catchsql([[
SELECT testfunc1(1,2,3);
Expand Down
1 change: 0 additions & 1 deletion test/sql-tap/gh2250-trigger-chain-limit.test.lua
Expand Up @@ -74,7 +74,6 @@ for _, table_count in ipairs({30, 31}) do
end

local function check(sql)
local msg = ''
local _, msg = pcall(function () test:execsql(sql) end)
msg = tostring(msg)
test:do_test(sql,
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/in3.test.lua
Expand Up @@ -26,7 +26,7 @@ test:plan(28)
-- Return the number of OpenEphemeral instructions used in the
-- implementation of the sql statement passed as a an argument.
--
local function nEphemeral(sql)
local function nEphemeral(sql) -- luacheck: no unused
local nEph = 0
for _, op in ipairs(test:execsql("EXPLAIN "..sql.."")) do
if (op == "OpenTEphemeral")
Expand Down
1 change: 0 additions & 1 deletion test/sql-tap/in5.test.lua
Expand Up @@ -16,7 +16,6 @@ test:plan(22)
--
-- ["set","testdir",[["file","dirname",["argv0"]]]]
-- ["source",[["testdir"],"\/tester.tcl"]]
local testprefix = "in5"
test:do_execsql_test(
"in5-1.1",
[[
Expand Down
2 changes: 0 additions & 2 deletions test/sql-tap/index1.test.lua
Expand Up @@ -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)
Expand Down Expand Up @@ -585,7 +584,6 @@ test:do_test(
for i = 1, 50, 1 do
test:execsql(string.format("INSERT INTO t3 VALUES('x%sx',%s,0.%s)", i, i, i))
end
local sql_search_count = 0
return X(381, "X!cmd", [=[["concat",[["execsql","SELECT c FROM t3 WHERE b==10"]],["sql_search_count"]]]=])
end, {
-- <index-11.1>
Expand Down
1 change: 0 additions & 1 deletion test/sql-tap/index4.test.lua
Expand Up @@ -18,7 +18,6 @@ test:plan(7)
--
-- ["set","testdir",[["file","dirname",["argv0"]]]]
-- ["source",[["testdir"],"\/tester.tcl"]]
local testprefix = "index4"
test:do_execsql_test(
1.1,
[[
Expand Down
1 change: 0 additions & 1 deletion test/sql-tap/insert1.test.lua
@@ -1,6 +1,5 @@
#!/usr/bin/env tarantool
local test = require("sqltester")
local yaml = require('yaml')
test:plan(28)

--!./tcltestrunner.lua
Expand Down
1 change: 0 additions & 1 deletion test/sql-tap/limit.test.lua
Expand Up @@ -694,7 +694,6 @@ test:do_catchsql_test(
test:do_test(
"limit-10.1",
function()
local limit = 10
return test:execsql [[
SELECT x FROM t1 LIMIT 10;
]]
Expand Down
1 change: 0 additions & 1 deletion test/sql-tap/lua/sqltester.lua
Expand Up @@ -378,7 +378,6 @@ function test.randstr(Length)
for Loop = 0, 255 do
Chars[Loop+1] = string.char(Loop)
end
local String = table.concat(Chars)
local Result = {}
local Lookup = Chars
local Range = #Lookup
Expand Down
11 changes: 0 additions & 11 deletions test/sql-tap/misc1.test.lua
Expand Up @@ -726,19 +726,8 @@ test:do_execsql_test(
-- MUST_WORK_TEST collate
if 0>0 then
db("collate", "numeric", "numeric_collate")
local function numeric_collate(lhs, rhs)
if (lhs == rhs)
then
return 0
end
return X(0, "X!expr", [=[["?:",[">",["lhs"],["rhs"]],3,["-",1]]]=])
end

-- Mimic the sql 2 collation type TEXT.
db("collate", "text", "text_collate")
local function numeric_collate(lhs, rhs)
return X(34, "X!cmd", [=[["string","compare",["lhs"],["rhs"]]]=])
end

test:do_execsql_test(
"misc1-12.11",
Expand Down
1 change: 0 additions & 1 deletion test/sql-tap/misc3.test.lua
@@ -1,6 +1,5 @@
#!/usr/bin/env tarantool
local test = require("sqltester")
local json = require("json")
test:plan(34)

--!./tcltestrunner.lua
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/orderby1.test.lua
Expand Up @@ -19,7 +19,7 @@ test:plan(35)
--
-- ["set","testdir",[["file","dirname",["argv0"]]]]
-- ["source",[["testdir"],"\/tester.tcl"]]
local testprefix = "orderby1"

-- MUST_WORK_TEST
-- # Generate test data for a join. Verify that the join gets the
-- # correct answer.
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/orderby2.test.lua
Expand Up @@ -19,7 +19,7 @@ test:plan(9)
--
-- ["set","testdir",[["file","dirname",["argv0"]]]]
-- ["source",[["testdir"],"\/tester.tcl"]]
local testprefix = "orderby2"

-- Generate test data for a join. Verify that the join gets the
-- correct answer.
--
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/orderby3.test.lua
Expand Up @@ -20,7 +20,7 @@ test:plan(15)
--
-- ["set","testdir",[["file","dirname",["argv0"]]]]
-- ["source",[["testdir"],"\/tester.tcl"]]
local testprefix = "orderby3"

-- Generate test data for a join. Verify that the join gets the
-- correct answer.
--
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/orderby4.test.lua
Expand Up @@ -21,7 +21,7 @@ test:plan(6)
--
-- ["set","testdir",[["file","dirname",["argv0"]]]]
-- ["source",[["testdir"],"\/tester.tcl"]]
local testprefix = "orderby4"

-- Generate test data for a join. Verify that the join gets the
-- correct answer.
--
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/orderby5.test.lua
Expand Up @@ -19,7 +19,7 @@ test:plan(10)
--
-- ["set","testdir",[["file","dirname",["argv0"]]]]
-- ["source",[["testdir"],"\/tester.tcl"]]
local testprefix = "orderby5"

-- Generate test data for a join. Verify that the join gets the
-- correct answer.
--
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/orderby6.test.lua
Expand Up @@ -26,7 +26,7 @@ test:plan(34)
--
-- ["set","testdir",[["file","dirname",["argv0"]]]]
-- ["source",[["testdir"],"\/tester.tcl"]]
local testprefix = "orderby6"

-- Run all tests twice. Once with a normal table and a second time
-- with a WITHOUT ROWID table
--
Expand Down
1 change: 0 additions & 1 deletion test/sql-tap/orderby8.test.lua
Expand Up @@ -22,7 +22,6 @@ test:plan(203)
--
-- ["set","testdir",[["file","dirname",["argv0"]]]]
-- ["source",[["testdir"],"\/tester.tcl"]]
local testprefix = "orderby8"

local rs = ""
test:do_test(
Expand Down
1 change: 0 additions & 1 deletion test/sql-tap/orderby9.test.lua
Expand Up @@ -22,7 +22,6 @@ test:plan(4)
-- ["set","testdir",[["file","dirname",["argv0"]]]]
-- ["source",[["testdir"],"\/tester.tcl"]]

local testprefix = "orderby9"
test:do_execsql_test(
"setup",
[[
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/select4.test.lua
Expand Up @@ -30,7 +30,7 @@ test:execsql [[
CREATE TABLE t1(n int primary key, log int);
START TRANSACTION;
]]
local i, j
local j
for i = 1, 31, 1 do
j = 0
while math.pow(2, j) < i do
Expand Down

0 comments on commit 8ca1cbe

Please sign in to comment.