From: "Alexander Tikhonov" <avtikhon@tarantool.org>
To: "Sergey Bronnikov" <estetus@gmail.com>
Cc: o.piskunov@tarantool.org, tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v2 1/6] Fix luacheck warnings in src/lua/
Date: Thu, 09 Apr 2020 07:31:46 +0300 [thread overview]
Message-ID: <1586406706.611331004@f347.i.mail.ru> (raw)
In-Reply-To: <2211143d95d0385682f79fb632bd7fd84c442c23.1586341316.git.sergeyb@tarantool.org>
[-- Attachment #1: Type: text/plain, Size: 29795 bytes --]
Hi Sergey, thank you for the patch, LGTM.
>Среда, 8 апреля 2020, 18:43 +03:00 от Sergey Bronnikov <estetus@gmail.com>:
>
>From: Sergey Bronnikov < sergeyb@tarantool.org >
>
>Many warnings fixed with help from Vladislav Shpilevoy.
>
>Closes #4681
>---
> src/lua/argparse.lua | 6 ++--
> src/lua/buffer.lua | 4 +--
> src/lua/clock.lua | 2 +-
> src/lua/crypto.lua | 4 +--
> src/lua/csv.lua | 5 ++-
> src/lua/digest.lua | 2 +-
> src/lua/env.lua | 2 +-
> src/lua/fio.lua | 25 +++++++-------
> src/lua/httpc.lua | 3 --
> src/lua/init.lua | 7 ++--
> src/lua/msgpackffi.lua | 16 +++------
> src/lua/socket.lua | 65 ++++++++++++++++++------------------
> src/lua/string.lua | 1 -
> src/lua/swim.lua | 16 ++++-----
> src/lua/tap.lua | 75 ++++++++++++++++++++----------------------
> src/lua/trigger.lua | 3 --
> 16 files changed, 109 insertions(+), 127 deletions(-)
>
>diff --git a/src/lua/argparse.lua b/src/lua/argparse.lua
>index faa0ae130..f58985425 100644
>--- a/src/lua/argparse.lua
>+++ b/src/lua/argparse.lua
>@@ -90,8 +90,8 @@ local function convert_parameter(name, convert_from, convert_to)
> return convert_from
> end
>
>-local function parameters_parse(t_in, options)
>- local t_out, t_in = {}, t_in or {}
>+local function parameters_parse(t__in, options)
>+ local t_out, t_in = {}, t__in or {}
>
> -- Prepare a lookup table for options. An option name -> a
> -- type name to convert a parameter into or true (which means
>@@ -145,7 +145,7 @@ local function parameters_parse(t_in, options)
> if parameter_has_value(lookup[command]) then
> -- in case next argument is value of this key (not --arg)
> local next_arg = t_in[i + 1]
>- local is_long, is_short, is_dash = parse_param_prefix(next_arg)
>+ is_long, is_short, is_dash = parse_param_prefix(next_arg)
> if is_dash then
> skip_param = true
> elseif is_long == false and not is_short and not is_dash then
>diff --git a/src/lua/buffer.lua b/src/lua/buffer.lua
>index 9aac82b39..43c7e1170 100644
>--- a/src/lua/buffer.lua
>+++ b/src/lua/buffer.lua
>@@ -182,7 +182,7 @@ local ibuf_methods = {
> unused = ibuf_unused;
> }
>
>-local function ibuf_tostring(ibuf)
>+local function ibuf_tostring()
> return '<ibuf>'
> end
> local ibuf_mt = {
>@@ -193,7 +193,7 @@ local ibuf_mt = {
>
> ffi.metatype(ibuf_t, ibuf_mt);
>
>-local function ibuf_new(arg, arg2)
>+local function ibuf_new(arg)
> local buf = ffi.new(ibuf_t)
> local slabc = builtin.tarantool_lua_slab_cache()
> builtin.ibuf_create(buf, slabc, READAHEAD)
>diff --git a/src/lua/clock.lua b/src/lua/clock.lua
>index 60c78663c..fee43ccde 100644
>--- a/src/lua/clock.lua
>+++ b/src/lua/clock.lua
>@@ -33,7 +33,7 @@ clock.bench = function(fun, ...)
> overhead = clock.proc() - overhead
> local start_time = clock.proc()
> local res = {0, fun(...)}
>- res[1] = clock.proc() - start_time - overhead, res
>+ res[1] = clock.proc() - start_time - overhead
> return res
> end
>
>diff --git a/src/lua/crypto.lua b/src/lua/crypto.lua
>index bf3064c70..c0eb0d303 100644
>--- a/src/lua/crypto.lua
>+++ b/src/lua/crypto.lua
>@@ -75,7 +75,7 @@ local function openssl_err_str()
> end
>
> local digests = {}
>-for class, name in pairs({
>+for class, _ in pairs({
> md2 = 'MD2', md4 = 'MD4', md5 = 'MD5',
> sha1 = 'SHA1', sha224 = 'SHA224',
> sha256 = 'SHA256', sha384 = 'SHA384', sha512 = 'SHA512',
>@@ -428,7 +428,7 @@ local public_methods = {
> }
>
> local module_mt = {
>- __serialize = function(s)
>+ __serialize = function()
> return public_methods
> end,
> __index = public_methods
>diff --git a/src/lua/csv.lua b/src/lua/csv.lua
>index 7dff2f213..de6726bb7 100644
>--- a/src/lua/csv.lua
>+++ b/src/lua/csv.lua
>@@ -188,10 +188,10 @@ module.dump = function(t, opts, writable)
> if type(writable) == 'nil' then
> result_table = {}
> end
>- for k, line in pairs(t) do
>+ for _, line in pairs(t) do
> local first = true
> local output_tuple = {}
>- for k2, field in pairs(line) do
>+ for _, field in pairs(line) do
> local strf = tostring(field)
> local buf_new_size = (strf:len() + 1) * 2
> if buf_new_size > bufsz then
>@@ -214,7 +214,6 @@ module.dump = function(t, opts, writable)
> else
> writable:write(table.concat(output_tuple))
> end
>- output_tuple = {}
> end
> ffi.C.csv_destroy(csv)
> csv.realloc(buf, 0)
>diff --git a/src/lua/digest.lua b/src/lua/digest.lua
>index 6ed91cfa2..7f1aea8d0 100644
>--- a/src/lua/digest.lua
>+++ b/src/lua/digest.lua
>@@ -246,7 +246,7 @@ local m = {
> end
> }
>
>-for digest, name in pairs(digest_shortcuts) do
>+for digest, _ in pairs(digest_shortcuts) do
> m[digest] = function (str)
> return crypto.digest[digest](str)
> end
>diff --git a/src/lua/env.lua b/src/lua/env.lua
>index dd1616a84..a31b7098f 100644
>--- a/src/lua/env.lua
>+++ b/src/lua/env.lua
>@@ -28,7 +28,7 @@ os.environ = function()
> end
>
> os.setenv = function(key, value)
>- local rv = nil
>+ local rv
> if value ~= nil then
> rv = ffi.C.setenv(key, value, 1)
> else
>diff --git a/src/lua/fio.lua b/src/lua/fio.lua
>index 83fddaa0a..b2b4b4c77 100644
>--- a/src/lua/fio.lua
>+++ b/src/lua/fio.lua
>@@ -329,7 +329,7 @@ fio.abspath = function(path)
> error("Usage: fio.abspath(path)")
> end
> path = path
>- local joined_path = ''
>+ local joined_path
> local path_tab = {}
> if string.sub(path, 1, 1) == '/' then
> joined_path = path
>@@ -366,7 +366,7 @@ fio.listdir = function(path)
> return t
> end
> local names = string.split(str, "\n")
>- for i, name in ipairs(names) do
>+ for _, name in ipairs(names) do
> table.insert(t, name)
> end
> return t
>@@ -378,15 +378,15 @@ fio.mktree = function(path, mode)
> end
> path = fio.abspath(path)
>
>- local path = string.gsub(path, '^/', '')
>+ path = string.gsub(path, '^/', '')
> local dirs = string.split(path, "/")
>
> local current_dir = "/"
>- for i, dir in ipairs(dirs) do
>+ for _, dir in ipairs(dirs) do
> current_dir = fio.pathjoin(current_dir, dir)
> local stat = fio.stat(current_dir)
> if stat == nil then
>- local st, err = fio.mkdir(current_dir, mode)
>+ local _, err = fio.mkdir(current_dir, mode)
> -- fio.stat() and fio.mkdir() above are separate calls
> -- and a file system may be changed between them. So
> -- if the error here is due to an existing directory,
>@@ -407,20 +407,20 @@ fio.rmtree = function(path)
> if type(path) ~= 'string' then
> error("Usage: fio.rmtree(path)")
> end
>- local status, err
>+ local status
> path = fio.abspath(path)
> local ls, err = fio.listdir(path)
> if err ~= nil then
> return nil, err
> end
>- for i, f in ipairs(ls) do
>+ for _, f in ipairs(ls) do
> local tmppath = fio.pathjoin(path, f)
> local st = fio.lstat(tmppath)
> if st then
> if st:is_dir() then
>- st, err = fio.rmtree(tmppath)
>+ _, err = fio.rmtree(tmppath)
> else
>- st, err = fio.unlink(tmppath)
>+ _, err = fio.unlink(tmppath)
> end
> if err ~= nil then
> return nil, err
>@@ -471,10 +471,10 @@ fio.copytree = function(from, to)
> if reason ~= nil then
> return false, reason
> end
>- for i, f in ipairs(ls) do
>+ for _, f in ipairs(ls) do
> local ffrom = fio.pathjoin(from, f)
> local fto = fio.pathjoin(to, f)
>- local st = fio.lstat(ffrom)
>+ st = fio.lstat(ffrom)
> if st and st:is_dir() then
> status, reason = fio.copytree(ffrom, fto)
> if reason ~= nil then
>@@ -488,7 +488,8 @@ fio.copytree = function(from, to)
> end
> end
> if st:is_link() then
>- local link_to, reason = fio.readlink(ffrom)
>+ local link_to
>+ link_to, reason = fio.readlink(ffrom)
> if reason ~= nil then
> return false, reason
> end
>diff --git a/src/lua/httpc.lua b/src/lua/httpc.lua
>index 6381c6a1a..9336dcee0 100644
>--- a/src/lua/httpc.lua
>+++ b/src/lua/httpc.lua
>@@ -29,8 +29,6 @@
> -- SUCH DAMAGE.
> --
>
>-local fiber = require('fiber')
>-
> local driver = package.loaded.http.client
> package.loaded.http = nil
>
>@@ -112,7 +110,6 @@ local special_characters = {
> [']'] = true,
> ['<'] = true,
> ['>'] = true,
>- ['>'] = true,
> ['@'] = true,
> [','] = true,
> [';'] = true,
>diff --git a/src/lua/init.lua b/src/lua/init.lua
>index ff3e74c3c..a831549d1 100644
>--- a/src/lua/init.lua
>+++ b/src/lua/init.lua
>@@ -144,9 +144,9 @@ local function gen_search_func(path_fn, templates, need_traverse)
>
> local searchpaths = {}
>
>- for _, path in ipairs(paths) do
>+ for _, p in ipairs(paths) do
> for _, template in pairs(templates) do
>- table.insert(searchpaths, fio.pathjoin(path, template))
>+ table.insert(searchpaths, fio.pathjoin(p, template))
> end
> end
>
>@@ -176,7 +176,8 @@ local function gen_loader_func(search_fn, load_fn)
> if not file then
> return err
> end
>- local loaded, err = load_fn(file, name)
>+ local loaded
>+ loaded, err = load_fn(file, name)
> if err == nil then
> return loaded
> else
>diff --git a/src/lua/msgpackffi.lua b/src/lua/msgpackffi.lua
>index f775f2d41..eacf2d1d5 100644
>--- a/src/lua/msgpackffi.lua
>+++ b/src/lua/msgpackffi.lua
>@@ -291,10 +291,6 @@ local function encode(obj)
> return r
> end
>
>-local function encode_ibuf(obj, ibuf)
>- encode_r(ibuf, obj, 0)
>-end
>-
> on_encode(ffi.typeof('uint8_t'), encode_int)
> on_encode(ffi.typeof('uint16_t'), encode_int)
> on_encode(ffi.typeof('uint32_t'), encode_int)
>@@ -320,7 +316,6 @@ local decode_r
>
> -- See similar constants in utils.cc
> local DBL_INT_MAX = 1e14 - 1
>-local DBL_INT_MIN = -1e14 + 1
>
> local function decode_u8(data)
> local num = ffi.cast(uint8_ptr_t, data[0])[0]
>@@ -465,8 +460,7 @@ end
> local function decode_array(data, size)
> assert (type(size) == "number")
> local arr = {}
>- local i
>- for i=1,size,1 do
>+ for _ = 1, size do
> table.insert(arr, decode_r(data))
> end
> if not msgpack.cfg.decode_save_metatables then
>@@ -478,8 +472,7 @@ end
> local function decode_map(data, size)
> assert (type(size) == "number")
> local map = {}
>- local i
>- for i=1,size,1 do
>+ for _ = 1, size do
> local key = decode_r(data);
> local val = decode_r(data);
> map[key] = val
>@@ -492,7 +485,7 @@ end
>
> local ext_decoder = {
> -- MP_UNKNOWN_EXTENSION
>- [0] = function(data, len) error("unsupported extension type") end,
>+ [0] = function() error("unsupported extension type") end,
> -- MP_DECIMAL
> [1] = function(data, len) local num = ffi.new("decimal_t") builtin.decimal_unpack(data, len, num) return num end,
> }
>@@ -502,7 +495,6 @@ local function decode_ext(data)
> -- mp_decode_extl and mp_decode_decimal
> -- need type code
> data[0] = data[0] - 1
>- local old_data = data[0]
> local len = builtin.mp_decode_extl(data, t)
> local fun = ext_decoder[t[0]]
> if type(fun) == 'function' then
>@@ -589,7 +581,7 @@ local function check_offset(offset, len)
> if offset == nil then
> return 1
> end
>- local offset = ffi.cast('ptrdiff_t', offset)
>+ offset = ffi.cast('ptrdiff_t', offset)
> if offset < 1 or offset > len then
> error(string.format("offset = %d is out of bounds [1..%d]",
> tonumber(offset), len))
>diff --git a/src/lua/socket.lua b/src/lua/socket.lua
>index a334ad45b..317acfe8e 100644
>--- a/src/lua/socket.lua
>+++ b/src/lua/socket.lua
>@@ -172,7 +172,7 @@ local function get_iflags(table, flags)
> if type(flags) ~= 'table' then
> flags = { flags }
> end
>- for i, f in pairs(flags) do
>+ for _, f in pairs(flags) do
> if table[f] == nil then
> return nil
> end
>@@ -660,7 +660,7 @@ local function check_delimiter(self, limit, eols)
> end
>
> local shortest
>- for i, eol in ipairs(eols) do
>+ for _, eol in ipairs(eols) do
> local data = ffi.C.memmem(rbuf.rpos, rbuf:size(), eol, #eol)
> if data ~= nil then
> local len = ffi.cast('char *', data) - rbuf.rpos + #eol
>@@ -706,16 +706,16 @@ local function read(self, limit, timeout, check, ...)
> local res = sysread(self, data, rbuf:unused())
> if res == 0 then -- eof
> self._errno = nil
>- local len = rbuf:size()
>- local data = ffi.string(rbuf.rpos, len)
>+ len = rbuf:size()
>+ data = ffi.string(rbuf.rpos, len)
> rbuf.rpos = rbuf.rpos + len
> return data
> elseif res ~= nil then
> rbuf.wpos = rbuf.wpos + res
>- local len = check(self, limit, ...)
>+ len = check(self, limit, ...)
> if len ~= nil then
> self._errno = nil
>- local data = ffi.string(rbuf.rpos, len)
>+ data = ffi.string(rbuf.rpos, len)
> rbuf.rpos = rbuf.rpos + len
> return data
> end
>@@ -1039,7 +1039,7 @@ local function tcp_connect(host, port, timeout)
> boxerrno(0)
> return s
> end
>- local timeout = timeout or TIMEOUT_INFINITY
>+ timeout = timeout or TIMEOUT_INFINITY
> local stop = fiber.clock() + timeout
> local dns = getaddrinfo(host, port, timeout, { type = 'SOCK_STREAM',
> protocol = 'tcp' })
>@@ -1047,7 +1047,7 @@ local function tcp_connect(host, port, timeout)
> boxerrno(boxerrno.EINVAL)
> return nil
> end
>- for i, remote in pairs(dns) do
>+ for _, remote in pairs(dns) do
> timeout = stop - fiber.clock()
> if timeout <= 0 then
> boxerrno(boxerrno.ETIMEDOUT)
>@@ -1078,8 +1078,8 @@ local function tcp_server_handler(server, sc, from)
> end
> end
>
>-local function tcp_server_loop(server, s, addr)
>- fiber.name(format("%s/%s:%s", server.name, addr.host, addr.port), {truncate = true})
>+local function tcp_server_loop(server, s, address)
>+ fiber.name(format("%s/%s:%s", server.name, address.host, address.port), {truncate = true})
> log.info("started")
> while socket_readable(s) do
> local sc, from = socket_accept(s)
>@@ -1104,15 +1104,15 @@ local function tcp_server_usage()
> error('Usage: socket.tcp_server(host, port, handler | opts)')
> end
>
>-local function tcp_server_do_bind(s, addr)
>- if socket_bind(s, addr.host, addr.port) then
>- if addr.family == 'AF_UNIX' then
>+local function tcp_server_do_bind(s, address)
>+ if socket_bind(s, address.host, address.port) then
>+ if address.family == 'AF_UNIX' then
> -- Make close() remove the unix socket file created
> -- by bind(). Note, this must be done before closing
> -- the socket fd so that no other tcp server can
> -- reuse the same path before we remove the file.
> s.close = function(self)
>- fio.unlink(addr.port)
>+ fio.unlink(address.port)
> return socket_close(self)
> end
> end
>@@ -1121,12 +1121,12 @@ local function tcp_server_do_bind(s, addr)
> return false
> end
>
>-local function tcp_server_bind_addr(s, addr)
>- if tcp_server_do_bind(s, addr) then
>+local function tcp_server_bind_addr(s, address)
>+ if tcp_server_do_bind(s, address) then
> return true
> end
>
>- if addr.family ~= 'AF_UNIX' then
>+ if address.family ~= 'AF_UNIX' then
> return false
> end
>
>@@ -1136,7 +1136,7 @@ local function tcp_server_bind_addr(s, addr)
>
> local save_errno = boxerrno()
>
>- local sc = tcp_connect(addr.host, addr.port)
>+ local sc = tcp_connect(address.host, address.port)
> if sc ~= nil then
> sc:close()
> boxerrno(save_errno)
>@@ -1148,13 +1148,13 @@ local function tcp_server_bind_addr(s, addr)
> return false
> end
>
>- log.info("tcp_server: remove dead UNIX socket: %s", addr.port)
>- if not fio.unlink(addr.port) then
>+ log.info("tcp_server: remove dead UNIX socket: %s", address.port)
>+ if not fio.unlink(address.port) then
> log.warn("tcp_server: %s", boxerrno.strerror())
> boxerrno(save_errno)
> return false
> end
>- return tcp_server_do_bind(s, addr)
>+ return tcp_server_do_bind(s, address)
> end
>
>
>@@ -1172,8 +1172,8 @@ local function tcp_server_bind(host, port, prepare, timeout)
> end
> end
>
>- for _, addr in ipairs(dns) do
>- local s = socket_new(addr.family, addr.type, addr.protocol)
>+ for _, address in ipairs(dns) do
>+ local s = socket_new(address.family, address.type, address.protocol)
> if s ~= nil then
> local backlog
> if prepare then
>@@ -1181,13 +1181,13 @@ local function tcp_server_bind(host, port, prepare, timeout)
> else
> socket_setsockopt(s, 'SOL_SOCKET', 'SO_REUSEADDR', 1) -- ignore error
> end
>- if not tcp_server_bind_addr(s, addr) or not s:listen(backlog) then
>+ if not tcp_server_bind_addr(s, address) or not s:listen(backlog) then
> local save_errno = boxerrno()
> socket_close(s)
> boxerrno(save_errno)
> return nil
> end
>- return s, addr
>+ return s, address
> end
> end
> -- DNS resolved successfully, but addresss family is not supported
>@@ -1211,12 +1211,12 @@ local function tcp_server(host, port, opts, timeout)
> tcp_server_usage()
> end
> server.name = server.name or 'server'
>- local s, addr = tcp_server_bind(host, port, server.prepare, timeout)
>+ local s, address = tcp_server_bind(host, port, server.prepare, timeout)
> if not s then
> return nil
> end
>- fiber.create(tcp_server_loop, server, s, addr)
>- return s, addr
>+ fiber.create(tcp_server_loop, server, s, address)
>+ return s, address
> end
>
> socket_mt = {
>@@ -1311,10 +1311,9 @@ local function lsocket_tcp_getpeername(self)
> return peer.host, tostring(peer.port), peer.family:match("AF_(.*)"):lower()
> end
>
>-local function lsocket_tcp_settimeout(self, value, mode)
>+local function lsocket_tcp_settimeout(self, value)
> check_socket(self)
> self.timeout = value
>- -- mode is effectively ignored
> return 1
> end
>
>@@ -1467,7 +1466,7 @@ local function lsocket_tcp_receive(self, pattern, prefix)
> local result = { prefix }
> local deadline = fiber.clock() + (self.timeout or TIMEOUT_INFINITY)
> repeat
>- local data = read(self, LIMIT_INFINITY, timeout, check_infinity)
>+ data = read(self, LIMIT_INFINITY, timeout, check_infinity)
> if data == nil then
> if not errno_is_transient[self._errno] then
> return nil, socket_error(self)
>@@ -1535,7 +1534,7 @@ lsocket_tcp_mt.__index.send = lsocket_tcp_send;
> -- TCP Constructor and Shortcuts
> --
>
>-local function lsocket_tcp()
>+local function lsocket_tcp(self)
> local s = socket_new('AF_INET', 'SOCK_STREAM', 'tcp')
> if not s then
> return nil, socket_error(self)
>@@ -1559,7 +1558,7 @@ local function lsocket_bind(host, port, backlog)
> if host == nil or port == nil then
> error("Usage: luasocket.bind(host, port [, backlog])")
> end
>- local function prepare(s) return backlog end
>+ local function prepare() return backlog end
> local s = tcp_server_bind(host, port, prepare)
> if not s then
> return nil, boxerrno.strerror()
>diff --git a/src/lua/string.lua b/src/lua/string.lua
>index 6e12c59ae..d3a846645 100644
>--- a/src/lua/string.lua
>+++ b/src/lua/string.lua
>@@ -233,7 +233,6 @@ local function string_startswith(inp, head, _start, _end)
> return false
> end
> _start = _start - 1
>- _end = _start + head_len - 1
> return memcmp(c_char_ptr(inp) + _start, c_char_ptr(head), head_len) == 0
> end
>
>diff --git a/src/lua/swim.lua b/src/lua/swim.lua
>index 0859915c9..466e77ce4 100644
>--- a/src/lua/swim.lua
>+++ b/src/lua/swim.lua
>@@ -371,7 +371,7 @@ end
> --
> local function swim_member_payload_str(m)
> local ptr = swim_check_member(m, 'member:payload_str()')
>- local cdata, size = swim_member_payload_raw(ptr)
>+ local _, size = swim_member_payload_raw(ptr)
> if size > 0 then
> return ffi.string(swim_member_payload_raw(ptr))
> end
>@@ -462,7 +462,7 @@ local swim_member_mt = {
> is_dropped = swim_member_is_dropped,
> },
> __serialize = swim_member_serialize,
>- __newindex = function(m)
>+ __newindex = function()
> return error('swim_member is a read-only object')
> end
> }
>@@ -782,20 +782,20 @@ local swim_member_event_mt = {
> --
> -- Create a closure function for preprocessing raw SWIM member
> -- event trigger parameters.
>--- @param s SWIM instance.
>+-- @param instance SWIM instance.
> -- @param callback User functions to call.
> -- @param ctx An optional parameter for @a callback passed as is.
> -- @return A function to set as a trigger.
> --
>-local function swim_on_member_event_new(s, callback, ctx)
>+local function swim_on_member_event_new(instance, callback, ctx)
> -- Do not keep a hard reference to a SWIM instance. Otherwise
> -- it is a cyclic reference, and both the instance and the
> -- trigger will never be GC-ed.
>- s = setmetatable({s}, {__mode = 'v'})
>+ instance = setmetatable({instance}, {__mode = 'v'})
> return function(member_ptr, event_mask)
>- local s = s[1]
>- if s then
>- local m = swim_wrap_member(s, member_ptr)
>+ local i = instance[1]
>+ if i then
>+ local m = swim_wrap_member(i, member_ptr)
> local event = setmetatable({event_mask}, swim_member_event_mt)
> return callback(m, event, ctx)
> end
>diff --git a/src/lua/tap.lua b/src/lua/tap.lua
>index 94b080d5a..04497386e 100644
>--- a/src/lua/tap.lua
>+++ b/src/lua/tap.lua
>@@ -53,7 +53,7 @@ local function ok(test, cond, message, extra)
> io.write(string.format("not ok - %s\n", message))
> extra = extra or {}
> if test.trace then
>- local frame = debug.getinfo(3, "Sl")
>+ debug.getinfo(3, "Sl")
> extra.trace = traceback()
> extra.filename = extra.trace[#extra.trace].filename
> extra.line = extra.trace[#extra.trace].line
>@@ -76,9 +76,6 @@ local function skip(test, message, extra)
> ok(test, true, message.." # skip", extra)
> end
>
>-
>-local nan = 0/0
>-
> local function cmpdeeply(got, expected, extra)
> if type(expected) == "number" or type(got) == "number" then
> extra.got = got
>@@ -190,38 +187,38 @@ local function isboolean(test, v, message, extra)
> return is(test, type(v), 'boolean', message, extra)
> end
>
>-local function isfunction(test, v, message, extra)
>- return is(test, type(v), 'function', message, extra)
>+local function isfunction(testcase, v, message, extra)
>+ return is(testcase, type(v), 'function', message, extra)
> end
>
>-local function isudata(test, v, utype, message, extra)
>+local function isudata(testcase, v, utype, message, extra)
> extra = extra or {}
> extra.expected = 'userdata<'..utype..'>'
> if type(v) == 'userdata' then
> extra.got = 'userdata<'..getmetatable(v)..'>'
>- return ok(test, getmetatable(v) == utype, message, extra)
>+ return ok(testcase, getmetatable(v) == utype, message, extra)
> else
> extra.got = type(v)
>- return fail(test, message, extra)
>+ return fail(testcase, message, extra)
> end
> end
>
>-local function iscdata(test, v, ctype, message, extra)
>+local function iscdata(testcase, v, ctype, message, extra)
> extra = extra or {}
> extra.expected = ffi.typeof(ctype)
> if type(v) == 'cdata' then
> extra.got = ffi.typeof(v)
>- return ok(test, ffi.istype(ctype, v), message, extra)
>+ return ok(testcase, ffi.istype(ctype, v), message, extra)
> else
> extra.got = type(v)
>- return fail(test, message, extra)
>+ return fail(testcase, message, extra)
> end
> end
>
> local test_mt
> local function test(parent, name, fun, ...)
> local level = parent ~= nil and parent.level + 1 or 0
>- local test = setmetatable({
>+ local testcase = setmetatable({
> parent = parent;
> name = name;
> level = level;
>@@ -232,48 +229,48 @@ local function test(parent, name, fun, ...)
> strict = false;
> }, test_mt)
> if fun ~= nil then
>- test:diag('%s', test.name)
>- fun(test, ...)
>- test:diag('%s: end', test.name)
>- return test:check()
>+ testcase:diag('%s', testcase.name)
>+ fun(testcase, ...)
>+ testcase:diag('%s: end', testcase.name)
>+ return testcase:check()
> else
>- return test
>+ return testcase
> end
> end
>
>-local function plan(test, planned)
>- test.planned = planned
>- io.write(string.rep(' ', 4 * test.level), string.format("1..%d\n", planned))
>+local function plan(testcase, planned)
>+ testcase.planned = planned
>+ io.write(string.rep(' ', 4 * testcase.level), string.format("1..%d\n", planned))
> end
>
>-local function check(test)
>- if test.checked then
>+local function check(testcase)
>+ if testcase.checked then
> error('check called twice')
> end
>- test.checked = true
>- if test.planned ~= test.total then
>- if test.parent ~= nil then
>- ok(test.parent, false, "bad plan", { planned = test.planned;
>- run = test.total})
>+ testcase.checked = true
>+ if testcase.planned ~= testcase.total then
>+ if testcase.parent ~= nil then
>+ ok(testcase.parent, false, "bad plan", { planned = testcase.planned;
>+ run = testcase.total})
> else
>- diag(test, string.format("bad plan: planned %d run %d",
>- test.planned, test.total))
>+ diag(testcase, string.format("bad plan: planned %d run %d",
>+ testcase.planned, testcase.total))
> end
>- elseif test.failed > 0 then
>- if test.parent ~= nil then
>- ok(test.parent, false, "failed subtests", {
>- failed = test.failed;
>- planned = test.planned;
>+ elseif testcase.failed > 0 then
>+ if testcase.parent ~= nil then
>+ ok(testcase.parent, false, "failed subtests", {
>+ failed = testcase.failed;
>+ planned = testcase.planned;
> })
> else
>- diag(test, "failed subtest: %d", test.failed)
>+ diag(testcase, "failed subtest: %d", testcase.failed)
> end
> else
>- if test.parent ~= nil then
>- ok(test.parent, true, test.name)
>+ if testcase.parent ~= nil then
>+ ok(testcase.parent, true, testcase.name)
> end
> end
>- return test.planned == test.total and test.failed == 0
>+ return testcase.planned == testcase.total and testcase.failed == 0
> end
>
> test_mt = {
>diff --git a/src/lua/trigger.lua b/src/lua/trigger.lua
>index 76a582c47..1330ecdd4 100644
>--- a/src/lua/trigger.lua
>+++ b/src/lua/trigger.lua
>@@ -1,7 +1,4 @@
> local fun = require('fun')
>-local log = require('log')
>-
>-local table_clear = require('table.clear')
>
> --
> -- Checks that argument is a callable, i.e. a function or a table
>--
>2.23.0
>
--
Alexander Tikhonov
[-- Attachment #2: Type: text/html, Size: 42596 bytes --]
next prev parent reply other threads:[~2020-04-09 4:31 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-08 15:42 [Tarantool-patches] [PATCH v2 0/6] Add static analysis with luacheck Sergey Bronnikov
2020-04-08 15:43 ` [Tarantool-patches] [PATCH v2 1/6] Fix luacheck warnings in src/lua/ Sergey Bronnikov
2020-04-09 4:31 ` Alexander Tikhonov [this message]
2020-04-11 16:54 ` Vladislav Shpilevoy
2020-04-08 15:43 ` [Tarantool-patches] [PATCH v2 2/6] Fix luacheck warnings in test/ Sergey Bronnikov
2020-04-09 4:31 ` Alexander Tikhonov
2020-04-11 16:54 ` Vladislav Shpilevoy
2020-04-14 7:49 ` Sergey Bronnikov
2020-04-11 16:54 ` Vladislav Shpilevoy
2020-04-08 15:43 ` [Tarantool-patches] [PATCH v2 3/6] Fix luacheck warnings in src/box/lua/ Sergey Bronnikov
2020-04-09 4:29 ` Alexander Tikhonov
2020-04-08 15:43 ` [Tarantool-patches] [PATCH v2 4/6] Fix luacheck warnings in extra/dist/tarantoolctl.in Sergey Bronnikov
2020-04-09 4:29 ` Alexander Tikhonov
2020-04-09 7:30 ` Oleg Babin
2020-04-10 14:05 ` Sergey Bronnikov
2020-04-15 15:14 ` Igor Munkin
2020-04-15 15:37 ` Igor Munkin
2020-04-08 15:43 ` [Tarantool-patches] [PATCH v2 5/6] Add luacheck config Sergey Bronnikov
2020-04-09 4:27 ` Alexander Tikhonov
2020-04-11 16:54 ` Vladislav Shpilevoy
2020-04-13 15:16 ` Sergey Bronnikov
2020-04-14 23:29 ` Vladislav Shpilevoy
2020-04-15 8:30 ` Sergey Bronnikov
2020-04-08 15:43 ` [Tarantool-patches] [PATCH v2 6/6] gitlab-ci: enable static analysis with luacheck Sergey Bronnikov
2020-04-09 4:20 ` Alexander Tikhonov
2020-04-10 14:53 ` Sergey Bronnikov
2020-04-22 8:45 ` Alexander Tikhonov
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=1586406706.611331004@f347.i.mail.ru \
--to=avtikhon@tarantool.org \
--cc=estetus@gmail.com \
--cc=o.piskunov@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH v2 1/6] Fix luacheck warnings in src/lua/' \
/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