Skip to content

Commit

Permalink
test: fix laucheck warnings in test/sql-tap (W213)
Browse files Browse the repository at this point in the history
W213 (Unused loop variable)

Part of #5464
  • Loading branch information
ligurio committed Jan 20, 2021
1 parent dd6fc16 commit 1ca2bd6
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 25 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 loop variable.
"213",
-- Local variable is set but never accessed.
"231",
-- "Value assigned to a local variable is unused."
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/analyze9.test.lua
Expand Up @@ -242,7 +242,7 @@ test:do_execsql_test(
local function insert_filler_rows_n(iStart, nCopy, nVal)
for i = 0, nVal-1 do
local iVal = iStart+i
for j = 0, nCopy-1 do
for _ = 0, nCopy-1 do
box.execute(string.format("INSERT INTO t1 VALUES (null, %s, %s, '%s')", iVal, iVal, iVal))
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/between.test.lua
Expand Up @@ -61,7 +61,7 @@ local function queryplan(sql)
table.insert(data,x)
local eqp = box.execute("EXPLAIN QUERY PLAN "..sql.."").rows
-- puts eqp=$eqp
for i, val in ipairs(eqp) do
for _, val in ipairs(eqp) do
--local a = val[1]
--local b = val[2]
--local c = val[3]
Expand Down
6 changes: 3 additions & 3 deletions test/sql-tap/e_expr.test.lua
Expand Up @@ -2119,7 +2119,7 @@ test:do_execsql_test(
local likeargs = {}
local function likefunc(...)
local args = {...}
for i, v in ipairs(args) do
for _, v in ipairs(args) do
table.insert(likeargs, v)
end
return 1
Expand Down Expand Up @@ -2354,7 +2354,7 @@ end
local regexpargs = {}
local function regexpfunc(...)
local args = {...}
for i, v in ipairs(args) do
for _, v in ipairs(args) do
table.insert(regexpargs, v)
end
return 1
Expand Down Expand Up @@ -2413,7 +2413,7 @@ test:do_test(
local matchargs = { }
local function matchfunc(...)
local args = {...}
for i, v in ipairs(args) do
for _, v in ipairs(args) do
table.insert(matchargs, v)
end
return 1
Expand Down
8 changes: 4 additions & 4 deletions test/sql-tap/gh-2723-concurrency.test.lua
Expand Up @@ -20,7 +20,7 @@ for id = 1, N do
end
)
end
for id = 1, N do
for _ = 1, N do
ch:get()
end

Expand All @@ -46,7 +46,7 @@ for id = 1, N do
end
)
end
for id = 1, N do
for _ = 1, N do
ch:get()
end
test:do_test(
Expand All @@ -64,15 +64,15 @@ box.execute("create index i1 on t1(b);")
for id = 1, N*N do
box.execute(string.format("insert into t1 values(%s, %s, 3)", id, id))
end
for id = 1, N do
for _ = 1, N do
fiber.create(
function ()
box.execute("delete from t1")
ch:put(1)
end
)
end
for id = 1, N do
for _ = 1, N do
ch:get()
end
test:do_test(
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/gh-3083-ephemeral-unref-tuples.test.lua
Expand Up @@ -12,7 +12,7 @@ test:do_test(
box.execute("insert into test(id, k) values(" .. i .. "," .. i .. ")")
end

for i = 1, 10000 do
for i = 1, 10000 do -- luacheck: ignore unused i
box.execute("SELECT id, k FROM test WHERE k IN (5849, 4986, 4997, 5020, 5044, 4990, 5013, 4983)")
end
end, {
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/gh-3332-tuple-format-leak.test.lua
Expand Up @@ -21,7 +21,7 @@ test:do_test(
test:do_test(
"format-leak",
function()
for i = 1, 100000 do
for i = 1, 100000 do -- luacheck: ignore unused i
box.execute("SELECT id FROM t1 WHERE flags=3 ORDER BY id LIMIT 2");
end
end, {
Expand Down
10 changes: 5 additions & 5 deletions test/sql-tap/gh2127-indentifier-max-length.test.lua
Expand Up @@ -7,7 +7,7 @@ local tt = {}
local table_word = "АААААААААА"

-- Create 30kb table name
for i=1,300 do
for i=1,300 do -- luacheck: ignore unused i
table.insert(tt, table_word)
end

Expand All @@ -27,7 +27,7 @@ local vt = {}
local view_word = "BBBBBBBBBB"

-- Create 30kb view name
for i=1, 300 do
for i=1, 300 do -- luacheck: ignore unused i
table.insert(vt, view_word)
end

Expand All @@ -45,7 +45,7 @@ local it = {}
local index_word = "ЕЕЕЕЕЕЕЕЕЕ"

-- Create 30kb index name
for i=1, 300 do
for i=1, 300 do -- luacheck: ignore unused i
table.insert(it, index_word)
end

Expand All @@ -55,7 +55,7 @@ local field_table = {}
local field_word = 'ДДДДДДДДД'

-- Create 30kb field name
for i=1, 300 do
for i=1, 300 do -- luacheck: ignore unused i
table.insert(field_table, field_word)
end

Expand All @@ -75,7 +75,7 @@ test:do_execsql_test(
local trig_table = {}
local trigger_word = "ССССССССС"

for i=1, 300 do
for i=1, 300 do -- luacheck: ignore unused i
table.insert(trig_table, trigger_word)
end

Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/lua/sqltester.lua
Expand Up @@ -272,7 +272,7 @@ test.catchsql2 = catchsql2
-- that different SQL statements generate exactly the same VDBE code.
local function explain_no_trace(self, sql)
local tr = execsql(self, "EXPLAIN "..sql)
for i=1,8 do
for i=1,8 do -- luacheck: ignore unused i
table.remove(tr,1)
end
return tr
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/misc5.test.lua
Expand Up @@ -292,7 +292,7 @@ test:do_test(
local sql, tail
sql = "INSERT INTO t1 VALUES("
tail = ""
for i = 0, 199, 1 do
for i = 0, 199, 1 do -- luacheck: ignore unused i
sql = sql .. "(1+"
tail = tail .. ")"
end
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/select1.test.lua
Expand Up @@ -1970,7 +1970,7 @@ test:do_test(
START TRANSACTION;
INSERT INTO abc VALUES(1, 1, 1);
]]
for i = 0,9,1 do
for i = 0,9,1 do -- luacheck: ignore unused i
test:execsql [[
INSERT INTO abc SELECT a+(select max(a) FROM abc), b+(select max(a) FROM abc), c+(select max(a) FROM abc) FROM abc;
]]
Expand Down
4 changes: 2 additions & 2 deletions test/sql-tap/selectB.test.lua
Expand Up @@ -26,11 +26,11 @@ local function test_transform(testname, sql1, sql2, results)
local vdbe1 = { }
local vdbe2 = { }
local data = box.execute("explain "..sql1)
for i, line in ipairs(data) do
for _, line in ipairs(data) do
table.insert(vdbe1, line[2])
end
data = box.execute("explain "..sql2)
for i, line in ipairs(data) do
for _, line in ipairs(data) do
table.insert(vdbe2, line[2])
end
test:do_test(
Expand Down
4 changes: 2 additions & 2 deletions test/sql-tap/trigger2.test.lua
Expand Up @@ -127,12 +127,12 @@ for _, tbl_defn in ipairs(tbl_definitions) do
local raw_result = test:execsql [[
SELECT * FROM rlog ORDER BY idx;
]]
for k,v in pairs(raw_result) do table.insert(r, v) end
for _,v in pairs(raw_result) do table.insert(r, v) end

raw_result = test:execsql [[
SELECT * FROM clog ORDER BY idx;
]]
for k,v in pairs(raw_result) do table.insert(r, v) end
for _,v in pairs(raw_result) do table.insert(r, v) end

return r
end, {
Expand Down

0 comments on commit 1ca2bd6

Please sign in to comment.