From: sergeyb@tarantool.org To: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org, imun@tarantool.org Cc: o.piskunov@tarantool.org, alexander.turenko@tarantool.org Subject: [Tarantool-patches] [PATCH v6 09/25] Fix luacheck warnings in test/box Date: Fri, 29 May 2020 18:09:10 +0300 [thread overview] Message-ID: <8c80f5ce9c990027db258b1915d2e054a0fa90b3.1590764167.git.sergeyb@tarantool.org> (raw) In-Reply-To: <cover.1590764167.git.sergeyb@tarantool.org> From: Sergey Bronnikov <sergeyb@tarantool.org> Part of #4681 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 | 13 +++++++++++++ test/box/box.lua | 2 +- test/box/hash_multipart.result | 2 +- test/box/hash_multipart.test.lua | 2 +- 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 | 4 ++-- test/box/lua/cfg_test6.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/require_init.lua | 3 --- test/box/lua/test_init.lua | 10 +++++----- test/box/lua/utils.lua | 13 ++++++------- 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 ++-- 24 files changed, 51 insertions(+), 46 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index 630834e16..f99cc17eb 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -41,3 +41,16 @@ files["src/box/lua/schema.lua"] = {globals = {"tonumber64"}, ignore = {"431", "4 files["test/app/lua/fiber.lua"] = {globals = {"box_fiber_run_test"}} files["test/app-tap/lua/require_mod.lua"] = {globals = {"exports"}} files["test/app-tap/string.test.lua"] = {globals = {"utf8"}} +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 = {"space_field_types", "iterate", "arithmetic", "table_shuffle", + "table_generate", "tuple_to_string", "check_space", "space_bsize", + "create_iterator", "setmap", "sort"}} +files["test/box/lua/bitset.lua"] = { + globals = {"create_space", "fill", "delete", "clear", "drop_space", + "dump", "test_insert_delete"} +} +files["test/box/lua/fifo.lua"] = {globals = {"fifomax", "find_or_create_fifo", "fifo_push", "fifo_top"}} +files["test/box/lua/identifier.lua"] = {globals = {"run_test"}} +files["test/box/lua/require_mod.lua"] = {globals = {"exports"}} 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/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..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/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..c42840aaf 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/require_init.lua b/test/box/lua/require_init.lua index c9ab07dce..8a2b477cc 100644 --- a/test/box/lua/require_init.lua +++ b/test/box/lua/require_init.lua @@ -1,5 +1,2 @@ #!/usr/bin/env tarantool box.load_cfg() -mod = require("require_mod") -package_path = package.path -package_cpath = package.cpath diff --git a/test/box/lua/test_init.lua b/test/box/lua/test_init.lua index 88cc3acdc..3823a0d13 100644 --- a/test/box/lua/test_init.lua +++ b/test/box/lua/test_init.lua @@ -1,15 +1,15 @@ #!/usr/bin/env tarantool box.load_cfg() -- testing start-up script -floor = require("math").floor +require("math").floor -- -- Access to box.cfg from start-up script -- -box_cfg = box.cfg() +local box_cfg = box.cfg() -function print_config() +local function print_config() return box_cfg end @@ -24,10 +24,10 @@ local function do_insert() box.space[0]:insert{1, 2, 4, 8} end -space = box.schema.create_space('tweedledum', { id = 0 }) +local space = box.schema.create_space('tweedledum', { id = 0 }) space:create_index('primary', { type = 'hash' }) -fiber = box.fiber.create(do_insert) +local fiber = box.fiber.create(do_insert) box.fiber.resume(fiber) -- diff --git a/test/box/lua/utils.lua b/test/box/lua/utils.lua index 5f859fd19..fd562b767 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 @@ -205,17 +204,17 @@ function space_bsize(s) end function create_iterator(obj, key, opts) - local iter, key, state = obj:pairs(key, opts) + local iter, state + 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..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 -- 2.23.0
next prev parent reply other threads:[~2020-05-29 15:13 UTC|newest] Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-29 15:08 [Tarantool-patches] [PATCH v6 00/25] Add static analysis with luacheck sergeyb 2020-05-29 15:08 ` [Tarantool-patches] [PATCH v6 01/25] Add initial luacheck config sergeyb 2020-05-29 16:04 ` Igor Munkin 2020-05-29 16:27 ` Igor Munkin 2020-05-30 12:19 ` Sergey Bronnikov 2020-05-30 12:18 ` Sergey Bronnikov 2020-05-29 15:08 ` [Tarantool-patches] [PATCH v6 02/25] build: enable 'make luacheck' target sergeyb 2020-05-29 16:28 ` Igor Munkin 2020-05-29 15:08 ` [Tarantool-patches] [PATCH v6 03/25] gitlab-ci: enable static analysis with luacheck sergeyb 2020-05-29 19:25 ` Igor Munkin 2020-06-01 9:29 ` Sergey Bronnikov 2020-06-01 9:48 ` Igor Munkin 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 04/25] Fix luacheck warnings in extra/dist/tarantoolctl.in sergeyb 2020-05-29 16:35 ` Igor Munkin 2020-06-01 14:10 ` Alexander Turenko 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 05/25] Fix luacheck warnings in src/lua/ sergeyb 2020-05-29 16:51 ` Igor Munkin 2020-05-29 19:13 ` Igor Munkin 2020-05-30 12:15 ` Sergey Bronnikov 2020-06-01 9:43 ` Igor Munkin 2020-06-01 10:36 ` Sergey Bronnikov 2020-06-01 9:38 ` Sergey Bronnikov 2020-06-01 14:47 ` Alexander Turenko 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 06/25] Fix luacheck warnings in src/box/lua/ sergeyb 2020-05-29 19:11 ` Igor Munkin 2020-05-30 12:22 ` Sergey Bronnikov 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 07/25] Supress luacheck warnings in test/app sergeyb 2020-06-01 10:11 ` Igor Munkin 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 08/25] Fix luacheck warnings in test/app-tap sergeyb 2020-06-01 11:41 ` Igor Munkin 2020-07-16 11:44 ` Sergey Bronnikov 2020-07-16 12:42 ` Igor Munkin 2020-07-16 13:25 ` Sergey Bronnikov 2020-06-01 13:37 ` Alexander Turenko 2020-06-01 16:37 ` Igor Munkin 2020-06-01 17:13 ` Alexander Turenko 2020-06-01 17:38 ` Igor Munkin 2020-05-29 15:09 ` sergeyb [this message] 2020-06-01 16:06 ` [Tarantool-patches] [PATCH v6 09/25] Fix luacheck warnings in test/box Igor Munkin 2020-07-16 13:23 ` Sergey Bronnikov 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 10/25] Fix luacheck warnings in test/box-py sergeyb 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 11/25] Fix luacheck warnings in test/box-tap sergeyb 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 12/25] Fix luacheck warnings in test/engine sergeyb 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 13/25] Fix luacheck warnings in test/engine_long sergeyb 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 14/25] Fix luacheck warnings in test/long_run-py sergeyb 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 15/25] Fix luacheck warnings in test/replication sergeyb 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 16/25] Fix luacheck warnings in test/replication-py sergeyb 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 17/25] Fix luacheck warnings in test/sql sergeyb 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 18/25] Fix luacheck warnings in test/sql-tap sergeyb 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 19/25] Fix luacheck warnings in test/swim sergeyb 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 20/25] Fix luacheck warnings in test/vinyl sergeyb 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 21/25] Fix luacheck warnings in test/wal_off sergeyb 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 22/25] Fix luacheck warnings in test/xlog sergeyb 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 23/25] Fix luacheck warnings in test/xlog-py sergeyb 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 24/25] Add luacheck supressions for luajit tests sergeyb 2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 25/25] luajit: bump new version sergeyb 2020-06-01 17:08 ` [Tarantool-patches] [PATCH v6 00/25] Add static analysis with luacheck Vladislav Shpilevoy 2020-06-01 17:29 ` Alexander Turenko 2020-06-01 18:13 ` Igor Munkin 2020-06-02 14:42 ` Alexander Turenko 2020-06-02 15:58 ` Igor Munkin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=8c80f5ce9c990027db258b1915d2e054a0fa90b3.1590764167.git.sergeyb@tarantool.org \ --to=sergeyb@tarantool.org \ --cc=alexander.turenko@tarantool.org \ --cc=imun@tarantool.org \ --cc=o.piskunov@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v6 09/25] Fix luacheck warnings in test/box' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox