* [Tarantool-patches] [PATCH v2 0/6] Add static analysis with luacheck
@ 2020-04-08 15:42 Sergey Bronnikov
2020-04-08 15:43 ` [Tarantool-patches] [PATCH v2 1/6] Fix luacheck warnings in src/lua/ Sergey Bronnikov
` (5 more replies)
0 siblings, 6 replies; 27+ messages in thread
From: Sergey Bronnikov @ 2020-04-08 15:42 UTC (permalink / raw)
To: tarantool-patches; +Cc: o.piskunov
From: Sergey Bronnikov <sergeyb@tarantool.org>
GitHub branch: https://github.com/tarantool/tarantool/tree/ligurio/gh-4681-fix-luacheck-warnings
Closes: #4681
Sergey Bronnikov (6):
Fix luacheck warnings in src/lua/
Fix luacheck warnings in test/
Fix luacheck warnings in src/box/lua/
Fix luacheck warnings in extra/dist/tarantoolctl.in
Add luacheck config
gitlab-ci: enable static analysis with luacheck
.gitlab-ci.yml | 9 +
.luacheckrc | 162 ++++++++++++++++++
.travis.mk | 12 +-
extra/dist/tarantoolctl.in | 20 +--
src/box/lua/upgrade.lua | 12 +-
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 -
test/app-tap/console.test.lua | 4 -
test/app-tap/csv.test.lua | 28 +--
test/box-py/box.lua | 2 +-
test/box-tap/gc.test.lua | 4 +-
test/box/box.lua | 2 +-
test/box/hash_multipart.result | 2 +-
test/box/hash_multipart.test.lua | 2 +-
test/box/iproto_stress.result | 8 +-
test/box/iproto_stress.test.lua | 4 +-
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/utils.lua | 3 +-
test/box/on_schema_init.lua | 2 +-
test/box/proxy.lua | 2 +-
test/box/tiny.lua | 2 +-
test/box/tree_pk.result | 6 +-
test/box/tree_pk.test.lua | 6 +-
test/engine/tree_min_max_count.result | 2 +-
test/engine/tree_min_max_count.test.lua | 2 +-
test/replication-py/master.lua | 2 +-
test/replication-py/panic.lua | 2 +-
test/replication/master.lua | 2 +-
test/replication/replicaset_ro_mostly.result | 2 +-
.../replication/replicaset_ro_mostly.test.lua | 2 +-
test/sql-tap/analyze3.test.lua | 6 +-
test/sql-tap/analyze9.test.lua | 16 +-
.../gh-4077-iproto-execute-no-bind.test.lua | 7 +-
test/sql-tap/index1.test.lua | 1 -
test/sql-tap/join3.test.lua | 2 +-
test/sql-tap/select9.test.lua | 10 +-
test/sql-tap/tkt-fa7bf5ec.test.lua | 6 +-
test/sql-tap/where2.test.lua | 2 +-
test/sql/lua/sql_tokenizer.lua | 2 +-
test/sql/savepoints.result | 6 +-
test/sql/savepoints.test.lua | 6 +-
test/sql/triggers.result | 2 +-
test/sql/triggers.test.lua | 2 +-
test/vinyl/large.lua | 4 +-
test/vinyl/stat.result | 33 ++--
test/vinyl/stat.test.lua | 22 +--
test/vinyl/txn_proxy.lua | 6 +-
test/vinyl/vinyl.lua | 2 +-
test/wal_off/rtree_benchmark.result | 2 +-
test/wal_off/rtree_benchmark.test.lua | 2 +-
test/xlog-py/box.lua | 2 +-
test/xlog/big_tx.result | 2 +-
test/xlog/big_tx.test.lua | 2 +-
test/xlog/checkpoint_daemon.result | 4 +-
test/xlog/checkpoint_daemon.test.lua | 4 +-
test/xlog/panic.lua | 2 +-
test/xlog/panic_on_wal_error.result | 2 +-
test/xlog/panic_on_wal_error.test.lua | 2 +-
test/xlog/reader.result | 2 +-
test/xlog/reader.test.lua | 2 +-
test/xlog/snap_io_rate.test.lua | 2 +-
test/xlog/transaction.result | 18 +-
test/xlog/transaction.test.lua | 18 +-
test/xlog/xlog.lua | 2 +-
85 files changed, 463 insertions(+), 300 deletions(-)
create mode 100644 .luacheckrc
--
2.23.0
^ permalink raw reply [flat|nested] 27+ messages in thread
* [Tarantool-patches] [PATCH v2 1/6] Fix luacheck warnings in src/lua/
2020-04-08 15:42 [Tarantool-patches] [PATCH v2 0/6] Add static analysis with luacheck Sergey Bronnikov
@ 2020-04-08 15:43 ` Sergey Bronnikov
2020-04-09 4:31 ` Alexander Tikhonov
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
` (4 subsequent siblings)
5 siblings, 2 replies; 27+ messages in thread
From: Sergey Bronnikov @ 2020-04-08 15:43 UTC (permalink / raw)
To: tarantool-patches; +Cc: o.piskunov
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
^ permalink raw reply [flat|nested] 27+ messages in thread
* [Tarantool-patches] [PATCH v2 2/6] Fix luacheck warnings in test/
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-08 15:43 ` Sergey Bronnikov
2020-04-09 4:31 ` Alexander Tikhonov
` (2 more replies)
2020-04-08 15:43 ` [Tarantool-patches] [PATCH v2 3/6] Fix luacheck warnings in src/box/lua/ Sergey Bronnikov
` (3 subsequent siblings)
5 siblings, 3 replies; 27+ messages in thread
From: Sergey Bronnikov @ 2020-04-08 15:43 UTC (permalink / raw)
To: tarantool-patches; +Cc: o.piskunov
From: Sergey Bronnikov <sergeyb@tarantool.org>
Closes #4681
---
test/app-tap/console.test.lua | 4 ---
test/app-tap/csv.test.lua | 28 ++++++++--------
test/box-py/box.lua | 2 +-
test/box-tap/gc.test.lua | 4 +--
test/box/box.lua | 2 +-
test/box/hash_multipart.result | 2 +-
test/box/hash_multipart.test.lua | 2 +-
test/box/iproto_stress.result | 8 ++---
test/box/iproto_stress.test.lua | 4 +--
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/utils.lua | 3 +-
test/box/on_schema_init.lua | 2 +-
test/box/proxy.lua | 2 +-
test/box/tiny.lua | 2 +-
test/box/tree_pk.result | 6 ++--
test/box/tree_pk.test.lua | 6 ++--
test/engine/tree_min_max_count.result | 2 +-
test/engine/tree_min_max_count.test.lua | 2 +-
test/replication-py/master.lua | 2 +-
test/replication-py/panic.lua | 2 +-
test/replication/master.lua | 2 +-
test/replication/replicaset_ro_mostly.result | 2 +-
.../replication/replicaset_ro_mostly.test.lua | 2 +-
test/sql-tap/analyze3.test.lua | 6 ++--
test/sql-tap/analyze9.test.lua | 16 ++++-----
.../gh-4077-iproto-execute-no-bind.test.lua | 7 ++--
test/sql-tap/index1.test.lua | 1 -
test/sql-tap/join3.test.lua | 2 +-
test/sql-tap/select9.test.lua | 10 ++----
test/sql-tap/tkt-fa7bf5ec.test.lua | 6 ++--
test/sql-tap/where2.test.lua | 2 +-
test/sql/lua/sql_tokenizer.lua | 2 +-
test/sql/savepoints.result | 6 ++--
test/sql/savepoints.test.lua | 6 ++--
test/sql/triggers.result | 2 +-
test/sql/triggers.test.lua | 2 +-
test/vinyl/large.lua | 4 +--
test/vinyl/stat.result | 33 ++++++++++++-------
test/vinyl/stat.test.lua | 22 ++++++-------
test/vinyl/txn_proxy.lua | 6 ++--
test/vinyl/vinyl.lua | 2 +-
test/wal_off/rtree_benchmark.result | 2 +-
test/wal_off/rtree_benchmark.test.lua | 2 +-
test/xlog-py/box.lua | 2 +-
test/xlog/big_tx.result | 2 +-
test/xlog/big_tx.test.lua | 2 +-
test/xlog/checkpoint_daemon.result | 4 +--
test/xlog/checkpoint_daemon.test.lua | 4 +--
test/xlog/panic.lua | 2 +-
test/xlog/panic_on_wal_error.result | 2 +-
test/xlog/panic_on_wal_error.test.lua | 2 +-
test/xlog/reader.result | 2 +-
test/xlog/reader.test.lua | 2 +-
test/xlog/snap_io_rate.test.lua | 2 +-
test/xlog/transaction.result | 18 +++++-----
test/xlog/transaction.test.lua | 18 +++++-----
test/xlog/xlog.lua | 2 +-
64 files changed, 157 insertions(+), 155 deletions(-)
diff --git a/test/app-tap/console.test.lua b/test/app-tap/console.test.lua
index da5c1e71e..737450387 100755
--- a/test/app-tap/console.test.lua
+++ b/test/app-tap/console.test.lua
@@ -5,7 +5,6 @@ local console = require('console')
local socket = require('socket')
local yaml = require('yaml')
local fiber = require('fiber')
-local ffi = require('ffi')
local log = require('log')
local fio = require('fio')
@@ -59,12 +58,9 @@ test:is(#client:read(EOL) > 0, true, "_G")
client:write("require('fiber').id()\n")
local fid1 = yaml.decode(client:read(EOL))[1]
local state = fiber.find(fid1).storage.console
-local server_info = state.client:peer()
local client_info = state.client:name()
test:is(client_info.host, client_info.host, "state.socker:peer().host")
test:is(client_info.port, client_info.port, "state.socker:peer().port")
-server_info = nil
-client_info = nil
-- Check console.delimiter()
client:write("require('console').delimiter(';')\n")
diff --git a/test/app-tap/csv.test.lua b/test/app-tap/csv.test.lua
index a7f17b1ea..689db7997 100755
--- a/test/app-tap/csv.test.lua
+++ b/test/app-tap/csv.test.lua
@@ -2,9 +2,9 @@
local function table2str(t)
local res = ""
- for k, line in pairs(t) do
+ for _, line in pairs(t) do
local s = ""
- for k2, field in pairs(line) do
+ for _, field in pairs(line) do
s = s .. '|' .. field .. '|\t'
end
res = res .. s .. '\n'
@@ -12,9 +12,9 @@ local function table2str(t)
return res
end
-local function myread(self, bytes)
+local function myread(self, bytes)
self.i = self.i + bytes
- return self.v:sub(self.i - bytes + 1, self.i)
+ return self.v:sub(self.i - bytes + 1, self.i)
end
local csv = require('csv')
local fio = require('fio')
@@ -27,10 +27,10 @@ local test4_ans = '|123|\t|5|\t|92|\t|0|\t|0|\t\n|1|\t|12 34|\t|56|\t' ..
local test5_ans = "|1|\t\n|23|\t|456|\t|abcac|\t|'multiword field 4'|\t\n" ..
"|none|\t|none|\t|0|\t\n||\t||\t||\t\n|aba|\t|adda|\t|f" ..
"3|\t|0|\t\n|local res = internal.pwrite(self.fh|\t|dat" ..
- "a|\t|len|\t|offset)|\t\n|iflag = bit.bor(iflag|\t|fio." ..
+ "a|\t|len|\t|offset)|\t\n|iflag = bit.bor(iflag|\t|fio." ..
"c.flag[ flag ])|\t\n||\t||\t||\t\n"
local test6_ans = "|23|\t|456|\t|abcac|\t|'multiword field 4'|\t\n|none|" ..
- "\t|none|\t|0|\t\n||\t||\t||\t\n|aba|\t|adda|\t|f3|\t|" ..
+ "\t|none|\t|0|\t\n||\t||\t||\t\n|aba|\t|adda|\t|f3|\t|" ..
"0|\t\n|local res = internal.pwrite(self.fh|\t|data|\t" ..
"|len|\t|offset)|\t\n|iflag = bit.bor(iflag|\t|fio.c.f" ..
"lag[ flag ])|\t\n||\t||\t||\t\n"
@@ -62,7 +62,7 @@ local f = fio.open(file1, { 'O_WRONLY', 'O_TRUNC', 'O_CREAT' }, tonumber('0777',
f:write("123 , 5 , 92 , 0, 0\n" ..
"1, 12 34, 56, \"quote , \", 66\nok")
f:close()
-f = fio.open(file1, {'O_RDONLY'})
+f = fio.open(file1, {'O_RDONLY'})
test:is(table2str(csv.load(f, {chunk_size = 10})), test4_ans, "fio test1")
f:close()
@@ -77,20 +77,20 @@ f:write("1\n23,456,abcac,\'multiword field 4\'\n" ..
",,"
)
f:close()
-f = fio.open(file2, {'O_RDONLY'})
+f = fio.open(file2, {'O_RDONLY'})
--symbol by symbol reading
-test:is(table2str(csv.load(f, {chunk_size = 1})), test5_ans, "fio test2")
+test:is(table2str(csv.load(f, {chunk_size = 1})), test5_ans, "fio test2")
f:close()
-f = fio.open(file2, {'O_RDONLY'})
+f = fio.open(file2, {'O_RDONLY'})
opts = {chunk_size = 7, skip_head_lines = 1}
--7 symbols per chunk
-test:is(table2str(csv.load(f, opts)), test6_ans, "fio test3")
+test:is(table2str(csv.load(f, opts)), test6_ans, "fio test3")
f:close()
t = {
- {'quote" d', ',and, comma', 'both " of " t,h,e,m'},
- {'"""', ',","'},
+ {'quote" d', ',and, comma', 'both " of " t,h,e,m'},
+ {'"""', ',","'},
{'mul\nti\nli\r\nne\n\n', 'field'},
{""},
{'"'},
@@ -100,7 +100,7 @@ t = {
f = require("fio").open(file3, { "O_WRONLY", "O_TRUNC" , "O_CREAT"}, 0x1FF)
csv.dump(t, {}, f)
f:close()
-f = fio.open(file3, {'O_RDONLY'})
+f = fio.open(file3, {'O_RDONLY'})
t2 = csv.load(f, {chunk_size = 5})
f:close()
diff --git a/test/box-py/box.lua b/test/box-py/box.lua
index e9403774c..35a087de9 100644
--- a/test/box-py/box.lua
+++ b/test/box-py/box.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-tap/gc.test.lua b/test/box-tap/gc.test.lua
index f88752e71..f0155779c 100755
--- a/test/box-tap/gc.test.lua
+++ b/test/box-tap/gc.test.lua
@@ -4,7 +4,7 @@ local fiber = require('fiber')
box.cfg{}
-local debug = type(box.error.injection) == "table"
+local debug = type(box.error.injection) == "table"
-- check box.info.gc() is false if snapshot is not in progress
local test = tap.test('box.info.gc')
@@ -19,7 +19,7 @@ test:is(gc.checkpoint_is_in_progress, false, "checkpoint is not in progress")
if debug then
box.error.injection.set("ERRINJ_SNAP_COMMIT_DELAY", true)
local snapshot_f = function()
- box.snapshot()
+ box.snapshot()
end
fiber.create(snapshot_f)
local gc = box.info.gc()
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/iproto_stress.result b/test/box/iproto_stress.result
index 7149d6c52..3b5b0a031 100644
--- a/test/box/iproto_stress.result
+++ b/test/box/iproto_stress.result
@@ -76,13 +76,13 @@ test_run:wait_cond(function() return n_workers == 0 end, 60)
---
- true
...
-n_workers -- 0
+assert(n_workers == 0)
---
-- 0
+- true
...
-n_errors -- 0
+assert(n_errors == 0)
---
-- 0
+- true
...
box.schema.user.revoke('guest', 'read,write,execute', 'universe')
---
diff --git a/test/box/iproto_stress.test.lua b/test/box/iproto_stress.test.lua
index 1e1a6578b..68d1f56fd 100644
--- a/test/box/iproto_stress.test.lua
+++ b/test/box/iproto_stress.test.lua
@@ -42,8 +42,8 @@ fiber.sleep(0.1)
box.error.injection.set("ERRINJ_WAL_DELAY", false)
test_run:wait_cond(function() return n_workers == 0 end, 60)
-n_workers -- 0
-n_errors -- 0
+assert(n_workers == 0)
+assert(n_errors == 0)
box.schema.user.revoke('guest', 'read,write,execute', 'universe')
s:drop()
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/utils.lua b/test/box/lua/utils.lua
index 5f859fd19..058c4a471 100644
--- a/test/box/lua/utils.lua
+++ b/test/box/lua/utils.lua
@@ -212,10 +212,9 @@ function create_iterator(obj, key, opts)
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..4489d8cd9 100644
--- a/test/box/tree_pk.result
+++ b/test/box/tree_pk.result
@@ -27,7 +27,7 @@ box.snapshot()
---
- ok
...
-i0:bsize() > bsize
+assert(i0:bsize() > bsize)
---
- true
...
@@ -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..bc3784a98 100644
--- a/test/box/tree_pk.test.lua
+++ b/test/box/tree_pk.test.lua
@@ -11,7 +11,7 @@ box.snapshot()
s0:insert{2, 'tuple 2'}
box.snapshot()
-i0:bsize() > bsize
+assert(i0:bsize() > bsize)
s0:insert{3, 'tuple 3'}
s0.index['primary']:get{1}
@@ -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
diff --git a/test/engine/tree_min_max_count.result b/test/engine/tree_min_max_count.result
index f55732aa6..9f1595a20 100644
--- a/test/engine/tree_min_max_count.result
+++ b/test/engine/tree_min_max_count.result
@@ -1189,7 +1189,7 @@ space6:drop()
---
...
-- min max count after many inserts
-string = require('string')
+local string = require('string')
---
...
space7 = box.schema.space.create('space7', { engine = engine })
diff --git a/test/engine/tree_min_max_count.test.lua b/test/engine/tree_min_max_count.test.lua
index 0633c56b3..19b5fe92d 100644
--- a/test/engine/tree_min_max_count.test.lua
+++ b/test/engine/tree_min_max_count.test.lua
@@ -337,7 +337,7 @@ space6:drop()
-- min max count after many inserts
-string = require('string')
+local string = require('string')
space7 = box.schema.space.create('space7', { engine = engine })
index7 = space7:create_index('primary', { type = 'tree', parts = {1, 'scalar'} })
diff --git a/test/replication-py/master.lua b/test/replication-py/master.lua
index e924b5495..b43bafd54 100644
--- a/test/replication-py/master.lua
+++ b/test/replication-py/master.lua
@@ -1,5 +1,5 @@
#!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
box.cfg({
listen = os.getenv("LISTEN"),
memtx_memory = 107374182,
diff --git a/test/replication-py/panic.lua b/test/replication-py/panic.lua
index 75a738cbb..e72d11419 100644
--- a/test/replication-py/panic.lua
+++ b/test/replication-py/panic.lua
@@ -1,5 +1,5 @@
#!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
box.cfg({
listen = os.getenv("LISTEN"),
memtx_memory = 107374182,
diff --git a/test/replication/master.lua b/test/replication/master.lua
index e924b5495..b43bafd54 100644
--- a/test/replication/master.lua
+++ b/test/replication/master.lua
@@ -1,5 +1,5 @@
#!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
box.cfg({
listen = os.getenv("LISTEN"),
memtx_memory = 107374182,
diff --git a/test/replication/replicaset_ro_mostly.result b/test/replication/replicaset_ro_mostly.result
index a471779d3..e509e0da0 100644
--- a/test/replication/replicaset_ro_mostly.result
+++ b/test/replication/replicaset_ro_mostly.result
@@ -35,7 +35,7 @@ test_run:cmd("setopt delimiter ';'")
- true
...
function create_cluster_uuid(servers, uuids)
- for i, name in ipairs(servers) do
+ for _, name in ipairs(servers) do
test_run:cmd(create_cluster_cmd1:format(name, name))
end
for i, name in ipairs(servers) do
diff --git a/test/replication/replicaset_ro_mostly.test.lua b/test/replication/replicaset_ro_mostly.test.lua
index 19cd1fe4a..e06e29c8e 100644
--- a/test/replication/replicaset_ro_mostly.test.lua
+++ b/test/replication/replicaset_ro_mostly.test.lua
@@ -16,7 +16,7 @@ create_cluster_cmd2 = 'start server %s with args="%s", wait_load=False, wait=Fal
test_run:cmd("setopt delimiter ';'")
function create_cluster_uuid(servers, uuids)
- for i, name in ipairs(servers) do
+ for _, name in ipairs(servers) do
test_run:cmd(create_cluster_cmd1:format(name, name))
end
for i, name in ipairs(servers) do
diff --git a/test/sql-tap/analyze3.test.lua b/test/sql-tap/analyze3.test.lua
index dcbea1da5..5c9c28601 100755
--- a/test/sql-tap/analyze3.test.lua
+++ b/test/sql-tap/analyze3.test.lua
@@ -23,15 +23,15 @@ testprefix = "analyze3"
------------------------------------------------------------------------
-- Test Organization:
--
--- analyze3-1.*: Test that the values of bound parameters are considered
+-- analyze3-1.*: Test that the values of bound parameters are considered
-- in the same way as constants when planning queries that
-- use range constraints.
--
--- analyze3-2.*: Test that the values of bound parameters are considered
+-- analyze3-2.*: Test that the values of bound parameters are considered
-- in the same way as constants when planning queries that
-- use LIKE expressions in the WHERE clause.
--
--- analyze3-3.*: Test that binding to a variable does not invalidate the
+-- analyze3-3.*: Test that binding to a variable does not invalidate the
-- query plan when there is no way in which replanning the
-- query may produce a superior outcome.
--
diff --git a/test/sql-tap/analyze9.test.lua b/test/sql-tap/analyze9.test.lua
index 02eb49f69..7412ba5fe 100755
--- a/test/sql-tap/analyze9.test.lua
+++ b/test/sql-tap/analyze9.test.lua
@@ -609,7 +609,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
@@ -657,7 +657,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
@@ -711,7 +711,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\""
@@ -762,7 +762,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\""
@@ -823,7 +823,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\""
@@ -874,7 +874,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\""
@@ -931,7 +931,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\""
@@ -1161,7 +1161,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/gh-4077-iproto-execute-no-bind.test.lua b/test/sql-tap/gh-4077-iproto-execute-no-bind.test.lua
index d4b597e35..2f71a68ea 100755
--- a/test/sql-tap/gh-4077-iproto-execute-no-bind.test.lua
+++ b/test/sql-tap/gh-4077-iproto-execute-no-bind.test.lua
@@ -41,10 +41,11 @@ local size = msgpack.encode(header:len() + body:len())
sock:write(size .. header .. body)
-- Read response.
-local size = msgpack.decode(sock:read(5))
+size = msgpack.decode(sock:read(5))
local header_body = sock:read(size)
-local header, header_len = msgpack.decode(header_body)
-local body = msgpack.decode(header_body:sub(header_len))
+local header_len
+header, header_len = msgpack.decode(header_body)
+body = msgpack.decode(header_body:sub(header_len))
sock:close()
-- Verify response.
diff --git a/test/sql-tap/index1.test.lua b/test/sql-tap/index1.test.lua
index e173e685c..4c4a37ca7 100755
--- a/test/sql-tap/index1.test.lua
+++ b/test/sql-tap/index1.test.lua
@@ -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)
diff --git a/test/sql-tap/join3.test.lua b/test/sql-tap/join3.test.lua
index 876b3121a..030fbaba3 100755
--- a/test/sql-tap/join3.test.lua
+++ b/test/sql-tap/join3.test.lua
@@ -49,7 +49,7 @@ for N=1, bitmask_size do
end
-- Joins with a comparison
--
-local result = {}
+result = {}
--for _ in X(0, "X!for", [=[["set N 1","$N<=$bitmask_size","incr N"]]=]) do
for N=1, bitmask_size do
table.insert(result,N)
diff --git a/test/sql-tap/select9.test.lua b/test/sql-tap/select9.test.lua
index 1ae16a658..bcc270593 100755
--- a/test/sql-tap/select9.test.lua
+++ b/test/sql-tap/select9.test.lua
@@ -60,10 +60,8 @@ function subrange(t, first, last)
end
local function test_compound_select(testname, sql, result)
- local nCol = 1
local A = box.execute(sql) --test.box(sql)
- nCol = #A.metadata
- A = A.rows
+ local nCol = #A.metadata
local nRow = #result / nCol
local compound_sql = sql
test:do_execsql_test(
@@ -274,10 +272,8 @@ test:do_execsql_test(
-- </select9-2.0>
})
-local t1_space_id = ""
-local t2_space_id = ""
-t1_space_id = test:execsql([[SELECT * from "_space" where "name"='T1']])["id"]
-t2_space_id = test:execsql([[SELECT * from "_space" where "name"='T2']])["id"]
+local t1_space_id = test:execsql([[SELECT * from "_space" where "name"='T1']])["id"]
+local t2_space_id = test:execsql([[SELECT * from "_space" where "name"='T2']])["id"]
--X(276, "X!cmd", [=[["db","eval","SELECT * from _space where name='t2'","data","\n set t2_space_id $data(id)\n"]]=])
--local function reverse(lhs, rhs)
-- return X(283, "X!cmd", [=[["string","compare",["rhs"],["lhs"]]]=])
diff --git a/test/sql-tap/tkt-fa7bf5ec.test.lua b/test/sql-tap/tkt-fa7bf5ec.test.lua
index 7152e028c..25d44c9d3 100755
--- a/test/sql-tap/tkt-fa7bf5ec.test.lua
+++ b/test/sql-tap/tkt-fa7bf5ec.test.lua
@@ -20,9 +20,9 @@ test:plan(1)
-- The problem described by this ticket was that the sqlExprCompare()
-- function was saying that expressions (x='a') and (x='A') were identical
-- because it was using sqlStrICmp() instead of strcmp() to compare string
--- literals. That was causing the query optimizer for aggregate queries to
--- believe that both count() operations were identical, and thus only
--- computing the first count() and making a copy of the result for the
+-- literals. That was causing the query optimizer for aggregate queries to
+-- believe that both count() operations were identical, and thus only
+-- computing the first count() and making a copy of the result for the
-- second count().
--
-- ["set","testdir",[["file","dirname",["argv0"]]]]
diff --git a/test/sql-tap/where2.test.lua b/test/sql-tap/where2.test.lua
index f267be8e6..f2db6fcee 100755
--- a/test/sql-tap/where2.test.lua
+++ b/test/sql-tap/where2.test.lua
@@ -115,7 +115,7 @@ local function queryplan(sql)
table.insert(data, tab)
table.insert(data, idx)
else
- as, tab = string.match(v, "TABLE (%w+ AS) (%w+)")
+ _, tab = string.match(v, "TABLE (%w+ AS) (%w+)")
if tab == nil then
tab = string.match(v, "TABLE (%w+)")
end
diff --git a/test/sql/lua/sql_tokenizer.lua b/test/sql/lua/sql_tokenizer.lua
index 9922d792d..ffe4fb4e8 100644
--- a/test/sql/lua/sql_tokenizer.lua
+++ b/test/sql/lua/sql_tokenizer.lua
@@ -134,7 +134,7 @@ end
-- @retval Token type. If the rest of the SQL request consists of
-- spaces and comments, then return TK_EMPTY.
local function get_next_token(context)
- local c = ''
+ local c
repeat
local i = context.offset
c = context.sql:sub(i, i)
diff --git a/test/sql/savepoints.result b/test/sql/savepoints.result
index 509c33e59..b0915f398 100644
--- a/test/sql/savepoints.result
+++ b/test/sql/savepoints.result
@@ -102,12 +102,12 @@ collision_sv_2 = function()
box.begin()
box.execute('SAVEPOINT t1;')
box.execute('SAVEPOINT t2;')
- local _,err = box.execute('SAVEPOINT t1;')
+ local _, err = box.execute('SAVEPOINT t1;')
assert(err == nil)
box.execute('RELEASE SAVEPOINT t1;')
- local _,err = box.execute('RELEASE SAVEPOINT t1;')
+ _, err = box.execute('RELEASE SAVEPOINT t1;')
assert(err ~= nil)
- local _, err = box.execute('ROLLBACK TO t2;')
+ _, err = box.execute('ROLLBACK TO t2;')
assert(err == nil)
end;
---
diff --git a/test/sql/savepoints.test.lua b/test/sql/savepoints.test.lua
index f1b15c748..eb7bea37d 100644
--- a/test/sql/savepoints.test.lua
+++ b/test/sql/savepoints.test.lua
@@ -65,12 +65,12 @@ collision_sv_2 = function()
box.begin()
box.execute('SAVEPOINT t1;')
box.execute('SAVEPOINT t2;')
- local _,err = box.execute('SAVEPOINT t1;')
+ local _, err = box.execute('SAVEPOINT t1;')
assert(err == nil)
box.execute('RELEASE SAVEPOINT t1;')
- local _,err = box.execute('RELEASE SAVEPOINT t1;')
+ _, err = box.execute('RELEASE SAVEPOINT t1;')
assert(err ~= nil)
- local _, err = box.execute('ROLLBACK TO t2;')
+ _, err = box.execute('ROLLBACK TO t2;')
assert(err == nil)
end;
collision_sv_2();
diff --git a/test/sql/triggers.result b/test/sql/triggers.result
index ceecb8ef2..e70d72947 100644
--- a/test/sql/triggers.result
+++ b/test/sql/triggers.result
@@ -11,7 +11,7 @@ _ = box.space._session_settings:update('sql_default_engine', {{'=', 2, engine}})
---
...
-- Get invariant part of the tuple; name and opts don't change.
- function immutable_part(data) local r = {} for i, l in pairs(data) do table.insert(r, {l.name, l.opts}) end return r end
+ function immutable_part(data) local r = {} for _, l in pairs(data) do table.insert(r, {l.name, l.opts}) end return r end
---
...
--
diff --git a/test/sql/triggers.test.lua b/test/sql/triggers.test.lua
index f5c8a3961..bc694ebc4 100644
--- a/test/sql/triggers.test.lua
+++ b/test/sql/triggers.test.lua
@@ -4,7 +4,7 @@ engine = test_run:get_cfg('engine')
_ = box.space._session_settings:update('sql_default_engine', {{'=', 2, engine}})
-- Get invariant part of the tuple; name and opts don't change.
- function immutable_part(data) local r = {} for i, l in pairs(data) do table.insert(r, {l.name, l.opts}) end return r end
+ function immutable_part(data) local r = {} for _, l in pairs(data) do table.insert(r, {l.name, l.opts}) end return r end
--
-- gh-3273: Move Triggers to server
diff --git a/test/vinyl/large.lua b/test/vinyl/large.lua
index e10e94c1a..a11642ff0 100644
--- a/test/vinyl/large.lua
+++ b/test/vinyl/large.lua
@@ -1,5 +1,5 @@
-fiber = require('fiber')
-digest = require('digest')
+local fiber = require('fiber')
+local digest = require('digest')
local PAGE_SIZE = 1024
local RANGE_SIZE = 64 * PAGE_SIZE
diff --git a/test/vinyl/stat.result b/test/vinyl/stat.result
index d35def13d..914c2ede4 100644
--- a/test/vinyl/stat.result
+++ b/test/vinyl/stat.result
@@ -1792,13 +1792,15 @@ dump(1, 100) -- split + compaction
wait_compaction(3)
---
...
-i:stat().range_count -- 2
+assert(i:stat().range_count, 2)
---
- 2
+- 2
...
-i:stat().dumps_per_compaction -- 1
+assert(i:stat().dumps_per_compaction, 1)
---
- 1
+- 1
...
dump(1, 10)
---
@@ -1809,9 +1811,10 @@ dump(1, 40) -- compaction in range 1
wait_compaction(4)
---
...
-i:stat().dumps_per_compaction -- 1
+assert(i:stat().dumps_per_compaction, 1)
---
- 1
+- 1
...
dump(90, 100)
---
@@ -1822,9 +1825,10 @@ dump(60, 100) -- compaction in range 2
wait_compaction(5)
---
...
-i:stat().dumps_per_compaction -- 2
+assert(i:stat().dumps_per_compaction, 2)
---
- 2
+- 2
...
-- Forcing compaction manually doesn't affect dumps_per_compaction.
dump(40, 60)
@@ -1836,9 +1840,10 @@ i:compact()
wait_compaction(7)
---
...
-i:stat().dumps_per_compaction -- 2
+assert(i:stat().dumps_per_compaction, 2)
---
- 2
+- 2
...
test_run:cmd('restart server test')
fiber = require('fiber')
@@ -1853,9 +1858,10 @@ s = box.space.test
i = s.index.primary
---
...
-i:stat().dumps_per_compaction -- 2
+assert(i:stat().dumps_per_compaction, 2)
---
- 2
+- 2
...
for i = 1, 100 do s:replace{i, digest.urandom(100)} end
---
@@ -1868,9 +1874,10 @@ test_run:wait_cond(function() return i:stat().disk.compaction.count == 2 end, 10
---
- true
...
-i:stat().dumps_per_compaction -- 1
+assert(i:stat().dumps_per_compaction, 1)
---
- 1
+- 1
...
s:drop()
---
@@ -1892,9 +1899,10 @@ s:insert{1}
---
- [1]
...
-i:stat().txw.rows -- 1
+assert(i:stat().txw.rows, 1)
---
- 1
+- 1
...
sv = box.savepoint()
---
@@ -1903,23 +1911,26 @@ s:insert{2}
---
- [2]
...
-i:stat().txw.rows -- 2
+assert(i:stat().txw.rows, 2)
---
- 2
+- 2
...
box.rollback_to_savepoint(sv)
---
...
-i:stat().txw.rows -- 1
+assert(i:stat().txw.rows, 1)
---
- 1
+- 1
...
box.commit()
---
...
-i:stat().txw.rows -- 0
+assert(i:stat().txw.rows, 0)
---
- 0
+- 0
...
s:drop()
---
diff --git a/test/vinyl/stat.test.lua b/test/vinyl/stat.test.lua
index a8657ccf4..7ff2d95f3 100644
--- a/test/vinyl/stat.test.lua
+++ b/test/vinyl/stat.test.lua
@@ -555,24 +555,24 @@ i:stat().dumps_per_compaction -- 1
dump(1, 100) -- compaction
dump(1, 100) -- split + compaction
wait_compaction(3)
-i:stat().range_count -- 2
-i:stat().dumps_per_compaction -- 1
+assert(i:stat().range_count, 2)
+assert(i:stat().dumps_per_compaction, 1)
dump(1, 10)
dump(1, 40) -- compaction in range 1
wait_compaction(4)
-i:stat().dumps_per_compaction -- 1
+assert(i:stat().dumps_per_compaction, 1)
dump(90, 100)
dump(60, 100) -- compaction in range 2
wait_compaction(5)
-i:stat().dumps_per_compaction -- 2
+assert(i:stat().dumps_per_compaction, 2)
-- Forcing compaction manually doesn't affect dumps_per_compaction.
dump(40, 60)
i:compact()
wait_compaction(7)
-i:stat().dumps_per_compaction -- 2
+assert(i:stat().dumps_per_compaction, 2)
test_run:cmd('restart server test')
@@ -582,12 +582,12 @@ digest = require('digest')
s = box.space.test
i = s.index.primary
-i:stat().dumps_per_compaction -- 2
+assert(i:stat().dumps_per_compaction, 2)
for i = 1, 100 do s:replace{i, digest.urandom(100)} end
box.snapshot()
test_run:wait_cond(function() return i:stat().disk.compaction.count == 2 end, 10)
-i:stat().dumps_per_compaction -- 1
+assert(i:stat().dumps_per_compaction, 1)
s:drop()
@@ -599,14 +599,14 @@ s = box.schema.space.create('test', {engine = 'vinyl'})
i = s:create_index('pk')
box.begin()
s:insert{1}
-i:stat().txw.rows -- 1
+assert(i:stat().txw.rows, 1)
sv = box.savepoint()
s:insert{2}
-i:stat().txw.rows -- 2
+assert(i:stat().txw.rows, 2)
box.rollback_to_savepoint(sv)
-i:stat().txw.rows -- 1
+assert(i:stat().txw.rows, 1)
box.commit()
-i:stat().txw.rows -- 0
+assert(i:stat().txw.rows, 0)
s:drop()
test_run:cmd('switch default')
diff --git a/test/vinyl/txn_proxy.lua b/test/vinyl/txn_proxy.lua
index 7a4d0b865..15b0e4add 100644
--- a/test/vinyl/txn_proxy.lua
+++ b/test/vinyl/txn_proxy.lua
@@ -1,11 +1,11 @@
--- A fiber can't use multiple transactions simultaneously;
+-- A fiber can't use multiple transactions simultaneously;
-- i.e. [fiber] --? [transaction] in UML parlor.
--
-- This module provides a simple transaction proxy facility
--- to control multiple transactions at once. A proxy executes
+-- to control multiple transactions at once. A proxy executes
-- statements in a worker fiber in order to overcome
-- "one transaction per fiber" limitation.
---
+--
-- Ex:
-- proxy = require('txn_proxy').new()
-- proxy:begin()
diff --git a/test/vinyl/vinyl.lua b/test/vinyl/vinyl.lua
index 31307f4bc..02b5c010b 100644
--- a/test/vinyl/vinyl.lua
+++ b/test/vinyl/vinyl.lua
@@ -15,7 +15,7 @@ box.cfg {
vinyl_max_tuple_size = 1024 * 1024 * 6,
}
-function box_info_sort(data)
+local function box_info_sort(data)
if type(data)~='table' then
return data
end
diff --git a/test/wal_off/rtree_benchmark.result b/test/wal_off/rtree_benchmark.result
index 8e01c9f2a..8deefca82 100644
--- a/test/wal_off/rtree_benchmark.result
+++ b/test/wal_off/rtree_benchmark.result
@@ -163,7 +163,7 @@ for i = 1, 0 do
for j = 1, dimension do
table.insert(rect, 180*math.random())
end
- for k,v in pairs(s.index.spatial:select(rect, {limit = n_neighbors, iterator = 'NEIGHBOR'})) do
+ for _,_ in pairs(s.index.spatial:select(rect, {limit = n_neighbors, iterator = 'NEIGHBOR'})) do
n = n + 1
end
end;
diff --git a/test/wal_off/rtree_benchmark.test.lua b/test/wal_off/rtree_benchmark.test.lua
index 6fae977c9..6bdc0a758 100644
--- a/test/wal_off/rtree_benchmark.test.lua
+++ b/test/wal_off/rtree_benchmark.test.lua
@@ -96,7 +96,7 @@ for i = 1, 0 do
for j = 1, dimension do
table.insert(rect, 180*math.random())
end
- for k,v in pairs(s.index.spatial:select(rect, {limit = n_neighbors, iterator = 'NEIGHBOR'})) do
+ for _,_ in pairs(s.index.spatial:select(rect, {limit = n_neighbors, iterator = 'NEIGHBOR'})) do
n = n + 1
end
end;
diff --git a/test/xlog-py/box.lua b/test/xlog-py/box.lua
index c87f7b94b..8b9e9434f 100644
--- a/test/xlog-py/box.lua
+++ b/test/xlog-py/box.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/xlog/big_tx.result b/test/xlog/big_tx.result
index 48085031b..837a4b478 100644
--- a/test/xlog/big_tx.result
+++ b/test/xlog/big_tx.result
@@ -11,7 +11,7 @@ t = box.space.big_tx:insert({1, digest.urandom(512 * 1024)})
---
...
env:cmd('restart server default')
-#box.space.big_tx:select()
+assert(#box.space.big_tx:select())
---
- 1
...
diff --git a/test/xlog/big_tx.test.lua b/test/xlog/big_tx.test.lua
index b90a14a82..09624ed53 100644
--- a/test/xlog/big_tx.test.lua
+++ b/test/xlog/big_tx.test.lua
@@ -5,7 +5,7 @@ _ = box.schema.space.create('big_tx'):create_index('pk')
t = box.space.big_tx:insert({1, digest.urandom(512 * 1024)})
env:cmd('restart server default')
-#box.space.big_tx:select()
+assert(#box.space.big_tx:select())
box.space.big_tx:drop()
diff --git a/test/xlog/checkpoint_daemon.result b/test/xlog/checkpoint_daemon.result
index 5be7124fe..dc806ea1d 100644
--- a/test/xlog/checkpoint_daemon.result
+++ b/test/xlog/checkpoint_daemon.result
@@ -118,11 +118,11 @@ wait_snapshot_gc(WAIT_COND_TIMEOUT)
---
- true
...
-#snaps == 2 or snaps
+assert(#snaps == 2 or snaps)
---
- true
...
-#xlogs > 0
+assert(#xlogs > 0)
---
- true
...
diff --git a/test/xlog/checkpoint_daemon.test.lua b/test/xlog/checkpoint_daemon.test.lua
index d3138f356..0ef3d89da 100644
--- a/test/xlog/checkpoint_daemon.test.lua
+++ b/test/xlog/checkpoint_daemon.test.lua
@@ -70,8 +70,8 @@ for i = 1, row_count_per_wal + 10 do space:insert { no } no = no + 1 end
wait_snapshot(WAIT_COND_TIMEOUT)
wait_snapshot_gc(WAIT_COND_TIMEOUT)
-#snaps == 2 or snaps
-#xlogs > 0
+assert(#snaps == 2 or snaps)
+assert(#xlogs > 0)
-- gh-2780: check that a last snapshot mtime will be changed at
-- least two times.
diff --git a/test/xlog/panic.lua b/test/xlog/panic.lua
index 2d4eb8d2e..0fa855421 100644
--- a/test/xlog/panic.lua
+++ b/test/xlog/panic.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/xlog/panic_on_wal_error.result b/test/xlog/panic_on_wal_error.result
index 22f14f912..7bdd5119a 100644
--- a/test/xlog/panic_on_wal_error.result
+++ b/test/xlog/panic_on_wal_error.result
@@ -19,7 +19,7 @@ _ = box.space.test:create_index('pk')
-- reopen xlog
--
test_run:cmd("restart server default")
-box.space.test ~= nil
+assert(box.space.test ~= nil)
---
- true
...
diff --git a/test/xlog/panic_on_wal_error.test.lua b/test/xlog/panic_on_wal_error.test.lua
index 2e95431c6..0a72bf44b 100644
--- a/test/xlog/panic_on_wal_error.test.lua
+++ b/test/xlog/panic_on_wal_error.test.lua
@@ -10,7 +10,7 @@ _ = box.space.test:create_index('pk')
-- reopen xlog
--
test_run:cmd("restart server default")
-box.space.test ~= nil
+assert(box.space.test ~= nil)
-- insert some stuff
--
box.space.test:auto_increment{'before snapshot'}
diff --git a/test/xlog/reader.result b/test/xlog/reader.result
index 9985aa2ac..74ac3579e 100644
--- a/test/xlog/reader.result
+++ b/test/xlog/reader.result
@@ -40,7 +40,7 @@ trun:cmd("setopt delimiter ';'")
...
function collect_results(file)
local val = {}
- for k, v in xlog(file) do
+ for _, v in xlog(file) do
table.insert(val, setmetatable(v, { __serialize = "map"}))
end
return val
diff --git a/test/xlog/reader.test.lua b/test/xlog/reader.test.lua
index 327af54dd..707ba394b 100644
--- a/test/xlog/reader.test.lua
+++ b/test/xlog/reader.test.lua
@@ -21,7 +21,7 @@ pattern_ok_v13 = fio.pathjoin(pattern_prefix, "v13/")
trun:cmd("setopt delimiter ';'")
function collect_results(file)
local val = {}
- for k, v in xlog(file) do
+ for _, v in xlog(file) do
table.insert(val, setmetatable(v, { __serialize = "map"}))
end
return val
diff --git a/test/xlog/snap_io_rate.test.lua b/test/xlog/snap_io_rate.test.lua
index f71296269..5626ea1f4 100644
--- a/test/xlog/snap_io_rate.test.lua
+++ b/test/xlog/snap_io_rate.test.lua
@@ -9,6 +9,6 @@ for i = 0, 127 do box.space.snap:replace({i, digest.urandom(512 * 1024)}) end
t1 = fiber.time()
box.snapshot()
t2 = fiber.time()
-t2 - t1 > 64 / box.cfg.snap_io_rate_limit * 0.95
+assert(t2 - t1 > 64 / box.cfg.snap_io_rate_limit * 0.95)
box.space.snap:drop()
diff --git a/test/xlog/transaction.result b/test/xlog/transaction.result
index 63adb0f25..376fea486 100644
--- a/test/xlog/transaction.result
+++ b/test/xlog/transaction.result
@@ -16,7 +16,7 @@ test_run:cmd("setopt delimiter ';'")
...
function read_xlog(file)
local val = {}
- for k, v in xlog(file) do
+ for _, v in xlog(file) do
table.insert(val, setmetatable(v, { __serialize = "map"}))
end
return val
@@ -69,37 +69,37 @@ data = read_xlog(fio.pathjoin(box.cfg.wal_dir, string.rep('0', 20 - #lsn_str) ..
---
...
-- check nothing changed for single row transactions
-data[1].HEADER.tsn == nil and data[1].HEADER.commit == nil
+assert(data[1].HEADER.tsn == nil and data[1].HEADER.commit == nil)
---
- true
...
-data[2].HEADER.tsn == nil and data[2].HEADER.commit == nil
+assert(data[2].HEADER.tsn == nil and data[2].HEADER.commit == nil)
---
- true
...
-- check two row transaction
-data[3].HEADER.tsn == data[3].HEADER.lsn and data[3].HEADER.commit == nil
+assert(data[3].HEADER.tsn == data[3].HEADER.lsn and data[3].HEADER.commit == nil)
---
- true
...
-data[4].HEADER.tsn == data[3].HEADER.tsn and data[4].HEADER.commit == true
+assert(data[4].HEADER.tsn == data[3].HEADER.tsn and data[4].HEADER.commit == true)
---
- true
...
-- check four row transaction
-data[5].HEADER.tsn == data[5].HEADER.lsn and data[5].HEADER.commit == nil
+assert(data[5].HEADER.tsn == data[5].HEADER.lsn and data[5].HEADER.commit == nil)
---
- true
...
-data[6].HEADER.tsn == data[5].HEADER.tsn and data[6].HEADER.commit == nil
+assert(data[6].HEADER.tsn == data[5].HEADER.tsn and data[6].HEADER.commit == nil)
---
- true
...
-data[7].HEADER.tsn == data[5].HEADER.tsn and data[7].HEADER.commit == nil
+assert(data[7].HEADER.tsn == data[5].HEADER.tsn and data[7].HEADER.commit == nil)
---
- true
...
-data[8].HEADER.tsn == data[5].HEADER.tsn and data[8].HEADER.commit == true
+assert(data[8].HEADER.tsn == data[5].HEADER.tsn and data[8].HEADER.commit == true)
---
- true
...
diff --git a/test/xlog/transaction.test.lua b/test/xlog/transaction.test.lua
index 2d8090b4c..c196064ef 100644
--- a/test/xlog/transaction.test.lua
+++ b/test/xlog/transaction.test.lua
@@ -6,7 +6,7 @@ test_run = env.new()
test_run:cmd("setopt delimiter ';'")
function read_xlog(file)
local val = {}
- for k, v in xlog(file) do
+ for _, v in xlog(file) do
table.insert(val, setmetatable(v, { __serialize = "map"}))
end
return val
@@ -33,14 +33,14 @@ box.snapshot()
lsn_str = tostring(lsn)
data = read_xlog(fio.pathjoin(box.cfg.wal_dir, string.rep('0', 20 - #lsn_str) .. tostring(lsn_str) .. '.xlog'))
-- check nothing changed for single row transactions
-data[1].HEADER.tsn == nil and data[1].HEADER.commit == nil
-data[2].HEADER.tsn == nil and data[2].HEADER.commit == nil
+assert(data[1].HEADER.tsn == nil and data[1].HEADER.commit == nil)
+assert(data[2].HEADER.tsn == nil and data[2].HEADER.commit == nil)
-- check two row transaction
-data[3].HEADER.tsn == data[3].HEADER.lsn and data[3].HEADER.commit == nil
-data[4].HEADER.tsn == data[3].HEADER.tsn and data[4].HEADER.commit == true
+assert(data[3].HEADER.tsn == data[3].HEADER.lsn and data[3].HEADER.commit == nil)
+assert(data[4].HEADER.tsn == data[3].HEADER.tsn and data[4].HEADER.commit == true)
-- check four row transaction
-data[5].HEADER.tsn == data[5].HEADER.lsn and data[5].HEADER.commit == nil
-data[6].HEADER.tsn == data[5].HEADER.tsn and data[6].HEADER.commit == nil
-data[7].HEADER.tsn == data[5].HEADER.tsn and data[7].HEADER.commit == nil
-data[8].HEADER.tsn == data[5].HEADER.tsn and data[8].HEADER.commit == true
+assert(data[5].HEADER.tsn == data[5].HEADER.lsn and data[5].HEADER.commit == nil)
+assert(data[6].HEADER.tsn == data[5].HEADER.tsn and data[6].HEADER.commit == nil)
+assert(data[7].HEADER.tsn == data[5].HEADER.tsn and data[7].HEADER.commit == nil)
+assert(data[8].HEADER.tsn == data[5].HEADER.tsn and data[8].HEADER.commit == true)
box.space.test:drop()
diff --git a/test/xlog/xlog.lua b/test/xlog/xlog.lua
index 004096d2d..aaf1a0ae6 100644
--- a/test/xlog/xlog.lua
+++ b/test/xlog/xlog.lua
@@ -1,5 +1,5 @@
#!/usr/bin/env tarantool
-os = require('os')
+local os = require('os')
box.cfg{
listen = os.getenv("LISTEN"),
--
2.23.0
^ permalink raw reply [flat|nested] 27+ messages in thread
* [Tarantool-patches] [PATCH v2 3/6] Fix luacheck warnings in src/box/lua/
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-08 15:43 ` [Tarantool-patches] [PATCH v2 2/6] Fix luacheck warnings in test/ Sergey Bronnikov
@ 2020-04-08 15:43 ` 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
` (2 subsequent siblings)
5 siblings, 1 reply; 27+ messages in thread
From: Sergey Bronnikov @ 2020-04-08 15:43 UTC (permalink / raw)
To: tarantool-patches; +Cc: o.piskunov
From: Sergey Bronnikov <sergeyb@tarantool.org>
Closes #4681
---
src/box/lua/upgrade.lua | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua
index 075cc236e..6b8ece513 100644
--- a/src/box/lua/upgrade.lua
+++ b/src/box/lua/upgrade.lua
@@ -173,7 +173,7 @@ local function initial_1_7_5()
format[5] = {name='field_count', type='unsigned'}
format[6] = {name='flags', type='map'}
format[7] = {name='format', type='array'}
- local def = _space:insert{_space.id, ADMIN, '_space', 'memtx', 0, MAP, format}
+ _space:insert{_space.id, ADMIN, '_space', 'memtx', 0, MAP, format}
-- space name is unique
log.info("create index primary on _space")
_index:insert{_space.id, 0, 'primary', 'tree', { unique = true }, {{0, 'unsigned'}}}
@@ -194,7 +194,7 @@ local function initial_1_7_5()
format[4] = {name = 'type', type = 'string'}
format[5] = {name = 'opts', type = 'map'}
format[6] = {name = 'parts', type = 'array'}
- def = _space:insert{_index.id, ADMIN, '_index', 'memtx', 0, MAP, format}
+ _space:insert{_index.id, ADMIN, '_index', 'memtx', 0, MAP, format}
-- index name is unique within a space
log.info("create index primary on _index")
_index:insert{_index.id, 0, 'primary', 'tree', {unique = true}, {{0, 'unsigned'}, {1, 'unsigned'}}}
@@ -211,7 +211,7 @@ local function initial_1_7_5()
format[2] = {name='owner', type='unsigned'}
format[3] = {name='name', type='string'}
format[4] = {name='setuid', type='unsigned'}
- def = _space:insert{_func.id, ADMIN, '_func', 'memtx', 0, MAP, format}
+ _space:insert{_func.id, ADMIN, '_func', 'memtx', 0, MAP, format}
-- function name and id are unique
log.info("create index _func:primary")
_index:insert{_func.id, 0, 'primary', 'tree', {unique = true}, {{0, 'unsigned'}}}
@@ -231,7 +231,7 @@ local function initial_1_7_5()
format[3] = {name='name', type='string'}
format[4] = {name='type', type='string'}
format[5] = {name='auth', type='map'}
- def = _space:insert{_user.id, ADMIN, '_user', 'memtx', 0, MAP, format}
+ _space:insert{_user.id, ADMIN, '_user', 'memtx', 0, MAP, format}
-- user name and id are unique
log.info("create index _func:primary")
_index:insert{_user.id, 0, 'primary', 'tree', {unique = true}, {{0, 'unsigned'}}}
@@ -251,7 +251,7 @@ local function initial_1_7_5()
format[3] = {name='object_type', type='string'}
format[4] = {name='object_id', type='unsigned'}
format[5] = {name='privilege', type='unsigned'}
- def = _space:insert{_priv.id, ADMIN, '_priv', 'memtx', 0, MAP, format}
+ _space:insert{_priv.id, ADMIN, '_priv', 'memtx', 0, MAP, format}
-- user id, object type and object id are unique
log.info("create index primary on _priv")
_index:insert{_priv.id, 0, 'primary', 'tree', {unique = true}, {{1, 'unsigned'}, {2, 'string'}, {3, 'unsigned'}}}
@@ -580,7 +580,7 @@ local function upgrade_to_2_1_0()
-- Now, abscent field means NULL, so we can safely set second
-- field in format, marking it nullable.
log.info("Add nullable value field to space _schema")
- local format = {}
+ format = {}
format[1] = {type='string', name='key'}
format[2] = {type='any', name='value', is_nullable=true}
box.space._schema:format(format)
--
2.23.0
^ permalink raw reply [flat|nested] 27+ messages in thread
* [Tarantool-patches] [PATCH v2 4/6] Fix luacheck warnings in extra/dist/tarantoolctl.in
2020-04-08 15:42 [Tarantool-patches] [PATCH v2 0/6] Add static analysis with luacheck Sergey Bronnikov
` (2 preceding siblings ...)
2020-04-08 15:43 ` [Tarantool-patches] [PATCH v2 3/6] Fix luacheck warnings in src/box/lua/ Sergey Bronnikov
@ 2020-04-08 15:43 ` Sergey Bronnikov
2020-04-09 4:29 ` Alexander Tikhonov
` (2 more replies)
2020-04-08 15:43 ` [Tarantool-patches] [PATCH v2 5/6] Add luacheck config Sergey Bronnikov
2020-04-08 15:43 ` [Tarantool-patches] [PATCH v2 6/6] gitlab-ci: enable static analysis with luacheck Sergey Bronnikov
5 siblings, 3 replies; 27+ messages in thread
From: Sergey Bronnikov @ 2020-04-08 15:43 UTC (permalink / raw)
To: tarantool-patches; +Cc: o.piskunov
From: Sergey Bronnikov <sergeyb@tarantool.org>
Closes #4681
---
| 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
--git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in
index f5a912ccd..3bcbe5b79 100755
--- a/extra/dist/tarantoolctl.in
+++ b/extra/dist/tarantoolctl.in
@@ -46,7 +46,6 @@ local instance_dir
local default_cfg
local positional_arguments
local keyword_arguments
-local lua_arguments = arg
local language
-- function for printing usage reference
@@ -64,7 +63,7 @@ end
local function check_user_level()
local uid = os.getenv('UID')
- local udir = nil
+ local udir
if uid == 0 or os.getenv("NOTIFY_SOCKET") then
return nil
end
@@ -420,7 +419,7 @@ local cat_formats = setmetatable({
json = cat_json_cb,
lua = cat_lua_cb,
}, {
- __index = function(self, cmd)
+ __index = function(cmd)
error(("Unknown formatter '%s'"):format(cmd))
end
})
@@ -790,7 +789,7 @@ end
local function eval()
local console_sock_path = uri.parse(console_sock).service
local filename = arg[3]
- local code = nil
+ local code
if filename == nil then
if stdin_isatty() then
log.error("Usage:")
@@ -848,7 +847,6 @@ end
-- xlog / snap file, so even when it stops on LSN >= @a opts.to on
-- a current file a next file will be processed.
local function filter_xlog(gen, param, state, opts, cb)
- local spaces = opts.spaces
local from, to, spaces = opts.from, opts.to, opts.space
local show_system, replicas = opts['show-system'], opts.replica
@@ -875,7 +873,7 @@ local function cat()
local cat_format = opts.format
local format_cb = cat_formats[cat_format]
local is_printed = false
- for id, file in ipairs(positional_arguments) do
+ for _, file in ipairs(positional_arguments) do
log.error("Processing file '%s'", file)
local gen, param, state = xlog.pairs(file)
filter_xlog(gen, param, state, opts, function(record)
@@ -901,7 +899,7 @@ local function play()
if not remote:wait_connected() then
error(("Error while connecting to host '%s'"):format(uri))
end
- for id, file in ipairs(positional_arguments) do
+ for _, file in ipairs(positional_arguments) do
log.info(("Processing file '%s'"):format(file))
local gen, param, state = xlog.pairs(file)
filter_xlog(gen, param, state, opts, function(record)
@@ -923,7 +921,7 @@ local function play()
end
local function find_arg(name_arg)
- for i, key in ipairs(arg) do
+ for _, key in ipairs(arg) do
if key:find(name_arg) ~= nil then
return key
end
@@ -937,7 +935,7 @@ local function rocks()
local util = require("luarocks.util")
local command_line = require("luarocks.cmd")
local options = keyword_arguments
- local key = nil
+ local key
if options["only-server"] ~= nil then
key = find_arg("only%-server")
else
@@ -954,7 +952,7 @@ local function rocks()
end
-- Tweak help messages
- util.see_help = function(command, program)
+ util.see_help = function()
-- TODO: print extended help message here
return "See Tarantool documentation for help."
end
@@ -1321,7 +1319,7 @@ local function usage_command(name, cmd)
if type(header) == 'string' then
header = { header }
end
- for no, line in ipairs(header) do
+ for _, line in ipairs(header) do
log.error(" " .. line, name)
end
end
--
2.23.0
^ permalink raw reply [flat|nested] 27+ messages in thread
* [Tarantool-patches] [PATCH v2 5/6] Add luacheck config
2020-04-08 15:42 [Tarantool-patches] [PATCH v2 0/6] Add static analysis with luacheck Sergey Bronnikov
` (3 preceding siblings ...)
2020-04-08 15:43 ` [Tarantool-patches] [PATCH v2 4/6] Fix luacheck warnings in extra/dist/tarantoolctl.in Sergey Bronnikov
@ 2020-04-08 15:43 ` Sergey Bronnikov
2020-04-09 4:27 ` Alexander Tikhonov
2020-04-11 16:54 ` Vladislav Shpilevoy
2020-04-08 15:43 ` [Tarantool-patches] [PATCH v2 6/6] gitlab-ci: enable static analysis with luacheck Sergey Bronnikov
5 siblings, 2 replies; 27+ messages in thread
From: Sergey Bronnikov @ 2020-04-08 15:43 UTC (permalink / raw)
To: tarantool-patches; +Cc: o.piskunov
From: Sergey Bronnikov <sergeyb@tarantool.org>
From the beginning we haven't use static analysis for Lua source code and
therefore now we have about 32k warnings and errors produced by luacheck. Sure
these issues are not real bugs but fixing them will make source code better and
clear. Aim to fix all of them at once looks insane and perhaps it is not worth
it.
Summary of static analysis:
There were no errors found by luacheck in production source code (src/),
many warnings were fixed in previous commits and non-interested warnings were
supressed using luacheck config.
Lua source code in test/ directory contains both errors and warnings and there
are a lot of them. Some of these warnings were fixed by previous commits and
most part of warnings and errors supressed in luacheck config. Regarding
errors: all found errors belongs to a single error class - "Syntax error"
(E011). All of them have a single root cause - at the of testscases we write
conditions without assignments and it is confuses luacheck. Usually such
conditions used together with asserts, but in our tests we uses reference outputs
instead of asserts.
How-to check:
$ tarantoolctl rocks install luacheck
$ .rocks/bin/luacheck --codes --config .luacheckrc .
Closes #4681
---
.luacheckrc | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 162 insertions(+)
create mode 100644 .luacheckrc
diff --git a/.luacheckrc b/.luacheckrc
new file mode 100644
index 000000000..2550f9f1a
--- /dev/null
+++ b/.luacheckrc
@@ -0,0 +1,162 @@
+include_files = {
+ "**/*.lua",
+ "extra/dist/tarantoolctl.in",
+}
+
+exclude_files = {
+ "third_party/**/*.lua",
+ "test-run/**/*.lua",
+ "test/wal_off/*.lua", -- E011
+ "test/xlog/*.lua", -- E011
+ "test/vinyl/*.lua", -- E011
+ "test/sql/*.lua", -- E011
+ "test/replication/*.lua", -- E011
+ "test/engine/*.lua", -- E011
+ "test/swim/*.lua", -- E011
+ "test/box/*.lua", -- E011
+ "test/app/*.lua", -- E011
+ "test/app-tap/*.lua", -- E011
+ "test/app-tap/lua/serializer_test.lua", -- E011
+ "build/**/*.lua",
+ ".rocks/**/*.lua",
+ ".git/**/*.lua",
+}
+
+files["**/*.lua"] = {ignore = {"212", "122"}}
+files["extra/dist/tarantoolctl.in"] = {ignore = {"431", "411", "122", "542"}}
+files["src/lua/help.lua"] = {globals = {"help", "tutorial"}, ignore = {"113", "211"}}
+files["src/lua/swim.lua"] = {ignore = {"431"}}
+files["src/lua/fio.lua"] = {ignore = {"231"}}
+files["src/lua/init.lua"] = {ignore = {"122", "121"}}
+files["src/lua/fiber.lua"] = {ignore = {"331", "311"}}
+files["src/box/lua/serpent.lua"] = {globals = {"_ENV"}, ignore = {"431", "421", "631", "432", "542", "412", "422"}}
+files["src/box/lua/load_cfg.lua"] = {ignore = {"431", "143", "311", "542"}}
+files["src/box/lua/net_box.lua"] = {ignore = {"431", "211", "421", "432", "311", "231", "411", "412"}}
+files["src/box/lua/schema.lua"] = {globals = {"update_format", "iid", "role_check_grant_revoke_of_sys_priv"}, ignore = {"431", "122", "211", "421", "213", "432", "311", "542", "412"}}
+files["src/box/lua/key_def.lua"] = {ignore = {"431"}}
+files["src/box/lua/feedback_daemon.lua"] = {ignore = {"122", "211"}}
+files["src/box/lua/tuple.lua"] = {ignore = {"122", "211", "421", "412"}}
+files["src/box/lua/upgrade.lua"] = {ignore = {"122", "211", "421", "213"}}
+files["src/box/lua/console.lua"] = {globals = {"help"}, ignore = {"211", "143"}}
+files["test/**/*.lua"] = {ignore = {"631", "611", "614", "613", "612", "621", "112", "211", "432"}}
+files["test/app/*.lua"] = {ignore = {"111", "113"}}
+files["test/app/lua/fiber.lua"] = {ignore = {"111"}}
+files["test/app-tap/*.lua"] = {ignore = {"111", "113"}}
+files["test/app-tap/tarantoolctl.test.lua"] = {ignore = {"511"}}
+files["test/app-tap/lua/require_mod.lua"] = {ignore = {"113", "111"}}
+files["test/box/admin.test.lua"] = {ignore = {"213"}}
+files["test/box/lua/*.lua"] = {ignore = {"111"}}
+files["test/box/*.lua"] = {ignore = {"111", "113"}}
+files["test/box/lua/utils.lua"] = {ignore = {"421", "113", "213", "412"}}
+files["test/box/lua/bitset.lua"] = {ignore = {"113", "213"}}
+files["test/box/lua/fifo.lua"] = {ignore = {"113", "213"}}
+files["test/box/lua/identifier.lua"] = {ignore = {"113"}}
+files["test/box/lua/require_mod.lua"] = {ignore = {"113"}}
+files["test/box/lua/require_init.lua"] = {ignore = {"412", "143"}}
+files["test/box/lua/test_init.lua"] = {ignore = {"113", "412", "143"}}
+files["test/box/lua/index_random_test.lua"] = {ignore = {"213"}}
+files["test/box-tap/*.lua"] = {ignore = {"111"}}
+files["test/box-tap/auth.test.lua"] = {ignore = {"311", "411", "113"}}
+files["test/box-tap/cfg.test.lua"] = {ignore = {"311", "411", "113"}}
+files["test/box-tap/cfgup.test.lua"] = {ignore = {"113"}}
+files["test/box-tap/feedback_daemon.test.lua"] = {ignore = {"411"}}
+files["test/box-tap/gc.test.lua"] = {ignore = {"421"}}
+files["test/box-tap/on_schema_init.test.lua"] = {ignore = {"113"}}
+files["test/box-tap/schema_mt.test.lua"] = {ignore = {"113", "122"}}
+files["test/box-tap/key_def.test.lua"] = {ignore = {"411", "431"}}
+files["test/box-tap/merger.test.lua"] = {ignore = {"411", "431", "412", "213"}}
+files["test/box-tap/session.storage.test.lua"] = {ignore = {"113"}}
+files["test/box-tap/session.test.lua"] = {ignore = {"411", "113", "412", "143"}}
+files["test/box-tap/trigger_atexit.test.lua"] = {ignore = {"113"}}
+files["test/box-tap/trigger_yield.test.lua"] = {ignore = {"213", "113"}}
+files["test/luajit-tap/fix_string_find_recording.test.lua"] = {ignore = {"111", "113", "231"}}
+files["test/luajit-tap/gh-4476-fix-string-find-recording.test.lua"] = {ignore = {"231"}}
+files["test/luajit-tap/fold_bug_LuaJIT_505.test.lua"] = {ignore = {"111", "113"}}
+files["test/luajit-tap/gh.test.lua"] = {ignore = {"111", "113"}}
+files["test/luajit-tap/table_chain_bug_LuaJIT_494.test.lua"] = {ignore = {"111", "113"}}
+files["test/luajit-tap/unsink_64_kptr.test.lua"] = {ignore = {"111", "113", "551", "542"}}
+files["test/luajit-tap/or-232-unsink-64-kptr.test.lua"] = {ignore = {"542"}}
+files["test/luajit-tap/lj-494-table-chain-infinite-loop.test.lua"] = {ignore = {"111", "113", "213"}}
+files["test/engine/*.lua"] = {ignore = {"111", "113"}}
+files["test/engine_long/suite.lua"] = {ignore = {"421", "111", "213"}}
+files["test/engine_long/delete_replace_update.test.lua"] = {ignore = {"113", "111"}}
+files["test/engine_long/delete_insert.test.lua"] = {ignore = {"113", "111"}}
+files["test/long_run-py/suite.lua"] = {ignore = {"421", "111", "113", "213"}}
+files["test/long_run-py/lua/finalizers.lua"] = {ignore = {"241", "511", "111", "113"}}
+files["test/replication/*.lua"] = {ignore = {"113", "111"}}
+files["test/replication/lua/fast_replica.lua"] = {ignore = {"113", "213"}}
+files["test/replication/lua/rlimit.lua"] = {ignore = {"113"}}
+files["test/replication-py/replica.lua"] = {ignore = {"111"}}
+files["test/replication/lua/fast_replica.lua"] = {ignore = {"113", "111", "213"}}
+files["test/replication/lua/rlimit.lua"] = {ignore = {"113", "111"}}
+files["test/sql/*.lua"] = {ignore = {"113", "111"}}
+files["test/sql/triggers.test.lua"] = {ignore = {"631", "113", "111"}}
+files["test/sql/tokenizer.test.lua"] = {ignore = {"113", "111"}}
+files["test/sql/transitive-transactions.test.lua"] = {ignore = {"113", "111"}}
+files["test/sql/savepoints.test.lua"] = {ignore = {"113", "111"}}
+files["test/sql/persistency.test.lua"] = {ignore = {"113", "111"}}
+files["test/sql-tap/*.lua"] = {ignore = {"113", "111"}}
+files["test/sql-tap/lua_sql.test.lua"] = {ignore = {"412"}}
+files["test/sql-tap/subquery.test.lua"] = {ignore = {"412", "143"}}
+files["test/sql-tap/alias.test.lua"] = {ignore = {"412", "143"}}
+files["test/sql-tap/analyze9.test.lua"] = {ignore = {"213", "411"}}
+files["test/sql-tap/between.test.lua"] = {ignore = {"421", "213"}}
+files["test/sql-tap/check.test.lua"] = {ignore = {"412", "143"}}
+files["test/sql-tap/date.test.lua"] = {ignore = {"511"}}
+files["test/sql-tap/e_expr.test.lua"] = {ignore = {"512", "431", "213", "411"}}
+files["test/sql-tap/func.test.lua"] = {ignore = {"412", "143"}}
+files["test/sql-tap/func5.test.lua"] = {ignore = {"412", "143"}}
+files["test/sql-tap/misc1.test.lua"] = {ignore = {"411"}}
+files["test/sql-tap/select1.test.lua"] = {ignore = {"511", "213"}}
+files["test/sql-tap/select2.test.lua"] = {ignore = {"421"}}
+files["test/sql-tap/select4.test.lua"] = {ignore = {"421"}}
+files["test/sql-tap/select5.test.lua"] = {ignore = {"421"}}
+files["test/sql-tap/selectA.test.lua"] = {ignore = {"542"}}
+files["test/sql-tap/selectB.test.lua"] = {ignore = {"213", "542"}}
+files["test/sql-tap/selectG.test.lua"] = {ignore = {"421"}}
+files["test/sql-tap/table.test.lua"] = {ignore = {"511"}}
+files["test/sql-tap/tkt-bd484a090c.test.lua"] = {ignore = {"511"}}
+files["test/sql-tap/tkt-38cb5df375.test.lua"] = {ignore = {"421"}}
+files["test/sql-tap/tkt-91e2e8ba6f.test.lua"] = {ignore = {"542"}}
+files["test/sql-tap/tkt-9a8b09f8e6.test.lua"] = {ignore = {"542"}}
+files["test/sql-tap/tkt2192.test.lua"] = {ignore = {"511"}}
+files["test/sql-tap/tkt3493.test.lua"] = {ignore = {"542"}}
+files["test/sql-tap/triggerA.test.lua"] = {ignore = {"311"}}
+files["test/sql-tap/trigger2.test.lua"] = {ignore = {"213"}}
+files["test/sql-tap/trigger9.test.lua"] = {ignore = {"143", "412"}}
+files["test/sql-tap/update.test.lua"] = {ignore = {"611"}}
+files["test/sql-tap/whereB.test.lua"] = {ignore = {"611"}}
+files["test/sql-tap/with1.test.lua"] = {ignore = {"542"}}
+files["test/sql-tap/with2.test.lua"] = {ignore = {"213", "412"}}
+files["test/sql-tap/lua_sql.test.lua"] = {ignore = {"143"}}
+files["test/sql-tap/lua/sqltester.lua"] = {ignore = {"111", "113", "431", "213"}}
+files["test/sql-tap/gh-2723-concurrency.test.lua"] = {ignore = {"213"}}
+files["test/sql-tap/gh-3307-xfer-optimization-issue.test.lua"] = {ignore = {"412", "213"}}
+files["test/sql-tap/gh-3083-ephemeral-unref-tuples.test.lua"] = {ignore = {"213"}}
+files["test/sql-tap/gh-3332-tuple-format-leak.test.lua"] = {ignore = {"213"}}
+files["test/sql-tap/gh2127-indentifier-max-length.test.lua"] = {ignore = {"213"}}
+files["test/sql-tap/misc5.test.lua"] = {ignore = {"213"}}
+files["test/wal_off/rtree_benchmark.test.lua"] = {ignore = {"213", "113", "111"}}
+files["test/wal_off/func_max.test.lua"] = {ignore = {"511", "113", "111"}}
+files["test/vinyl/upgrade/fill.lua"] = {ignore = {"111", "113"}}
+files["test/vinyl/write_iterator_rand.test.lua"] = {ignore = {"113", "111"}}
+files["test/vinyl/savepoint.test.lua"] = {ignore = {"113", "111"}}
+files["test/vinyl/replica_quota.test.lua"] = {ignore = {"113", "111", "213"}}
+files["test/vinyl/stress.test.lua"] = {ignore = {"431", "213"}}
+files["test/vinyl/hermitage.test.lua"] = {ignore = {"113", "111"}}
+files["test/vinyl/dump_stress.test.lua"] = {ignore = {"113", "111"}}
+files["test/vinyl/constraint.test.lua"] = {ignore = {"113", "111"}}
+files["test/vinyl/large.test.lua"] = {ignore = {"113", "111"}}
+files["test/vinyl/options.test.lua"] = {ignore = {"113", "111"}}
+files["test/xlog/upgrade/2.1.3/gh-4771-upgrade-sequence/fill.lua"] = {ignore = {"111", "113"}}
+files["test/xlog/transaction.test.lua"] = {ignore = {"113", "111"}}
+files["test/xlog/snap_io_rate.test.lua"] = {ignore = {"113", "111"}}
+files["test/xlog/reader.test.lua"] = {ignore = {"113", "111"}}
+files["test/xlog/panic_on_broken_lsn.test.lua"] = {ignore = {"113", "111"}}
+files["test/xlog/gh1433.test.lua"] = {ignore = {"113", "111"}}
+files["test/xlog/header.test.lua"] = {ignore = {"113", "111"}}
+files["test/xlog/errinj.test.lua"] = {ignore = {"113", "111"}}
+files["test/xlog/force_recovery.test.lua"] = {ignore = {"113", "111"}}
+files["test/xlog/big_tx.test.lua"] = {ignore = {"113", "111"}}
+files["test/xlog/checkpoint_threshold.test.lua"] = {ignore = {"113", "111", "213"}}
+files["test/swim/box.lua"] = {ignore = {"113", "111"}}
--
2.23.0
^ permalink raw reply [flat|nested] 27+ messages in thread
* [Tarantool-patches] [PATCH v2 6/6] gitlab-ci: enable static analysis with luacheck
2020-04-08 15:42 [Tarantool-patches] [PATCH v2 0/6] Add static analysis with luacheck Sergey Bronnikov
` (4 preceding siblings ...)
2020-04-08 15:43 ` [Tarantool-patches] [PATCH v2 5/6] Add luacheck config Sergey Bronnikov
@ 2020-04-08 15:43 ` Sergey Bronnikov
2020-04-09 4:20 ` Alexander Tikhonov
5 siblings, 1 reply; 27+ messages in thread
From: Sergey Bronnikov @ 2020-04-08 15:43 UTC (permalink / raw)
To: tarantool-patches; +Cc: o.piskunov
From: Sergey Bronnikov <sergeyb@tarantool.org>
Closes #4681
---
.gitlab-ci.yml | 9 +++++++++
.travis.mk | 12 +++++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cd710027f..adbd892c8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,5 @@
stages:
+ - static_analysis
- test
- perf
- cleanup
@@ -96,6 +97,14 @@ variables:
script:
- ${GITLAB_MAKE} perf_run
+# Static Analysis
+
+luacheck:
+ <<: *docker_test_definition
+ stage: static_analysis
+ script:
+ - ${GITLAB_MAKE} test_debian_luacheck
+
# Tests
release:
diff --git a/.travis.mk b/.travis.mk
index f709a18b6..32222621b 100644
--- a/.travis.mk
+++ b/.travis.mk
@@ -77,8 +77,9 @@ deps_buster_clang_8: deps_debian
# Release
build_debian:
- cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_WERROR=ON ${CMAKE_EXTRA_PARAMS}
+ cmake . -DENABLE_DIST=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_WERROR=ON ${CMAKE_EXTRA_PARAMS}
make -j
+ sudo make install
test_debian_no_deps: build_debian
cd test && /usr/bin/python test-run.py --force $(TEST_RUN_EXTRA_PARAMS)
@@ -145,6 +146,15 @@ test_static_build: deps_debian_static
test_static_docker_build:
docker build --network=host --build-arg RUN_TESTS=ON -f Dockerfile.staticbuild .
+# ###################
+# Static Analysis
+# ###################
+
+test_debian_luacheck: build_debian
+ tarantoolctl rocks install luacheck
+ # TODO: run in parallel with LuaLanes
+ .rocks/bin/luacheck --codes --config .luacheckrc .
+
#######
# OSX #
#######
--
2.23.0
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 6/6] gitlab-ci: enable static analysis with luacheck
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
0 siblings, 1 reply; 27+ messages in thread
From: Alexander Tikhonov @ 2020-04-09 4:20 UTC (permalink / raw)
To: Sergey Bronnikov; +Cc: o.piskunov, tarantool-patches
[-- Attachment #1: Type: text/plain, Size: 3381 bytes --]
Hi Sergey, thank you for the patch, please check my comments below.
>Среда, 8 апреля 2020, 18:43 +03:00 от Sergey Bronnikov <estetus@gmail.com>:
>
>From: Sergey Bronnikov < sergeyb@tarantool.org >
>
>Closes #4681
>---
Please add in the review letter the link to the branch here, also the issue link.
> .gitlab-ci.yml | 9 +++++++++
> .travis.mk | 12 +++++++++++-
> 2 files changed, 20 insertions(+), 1 deletion(-)
>
>diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
>index cd710027f..adbd892c8 100644
>--- a/.gitlab-ci.yml
>+++ b/.gitlab-ci.yml
>@@ -1,4 +1,5 @@
> stages:
>+ - static_analysis
Do we really need the separate stage for this job ? As we agreed with A. Turenko before, we create stages only for jobs that needs additional steps w/o next steps wont work and which can be used in the next stage for more than single job.
Anyway separate stage will add depends for the rest of the jobs, which can be blocked because of any issue with luacheck, like it can be luacheck cloning either its depends installations:
Installing http://rocks.tarantool.org/luacheck-scm-1.rockspec
Missing dependencies for luacheck scm-1:
argparse >= 0.6.0 (not installed)
luacheck scm-1 depends on argparse >= 0.6.0 (not installed)
Installing http://rocks.tarantool.org/argparse-0.6.0-1.rockspec
Cloning into 'luacheck'...
remote: Enumerating objects: 42, done.
remote: Counting objects: 100% (42/42), done.
remote: Compressing objects: 100% (25/25), done.
remote: Total 6077 (delta 15), reused 30 (delta 13), pack-reused 6035
Receiving objects: 100% (6077/6077), 2.18 MiB | 1.57 MiB/s, done.
Resolving deltas: 100% (3980/3980), done.
luacheck scm-1 is now installed in /root/tarantool/.rocks (license: MIT)
> - test
> - perf
> - cleanup
>@@ -96,6 +97,14 @@ variables:
> script:
> - ${GITLAB_MAKE} perf_run
>
>+# Static Analysis
>+
>+luacheck:
>+ <<: *docker_test_definition
>+ stage: static_analysis
>+ script:
>+ - ${GITLAB_MAKE} test_debian_luacheck
>+
> # Tests
>
> release:
>diff --git a/.travis.mk b/.travis.mk
>index f709a18b6..32222621b 100644
>--- a/.travis.mk
>+++ b/.travis.mk
>@@ -77,8 +77,9 @@ deps_buster_clang_8: deps_debian
> # Release
>
> build_debian:
>- cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_WERROR=ON ${CMAKE_EXTRA_PARAMS}
>+ cmake . -DENABLE_DIST=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_WERROR=ON ${CMAKE_EXTRA_PARAMS}
This target is common wide along all the jobs and if ENABLE_DIST define is not adding changes for them may be just need add the comment the purpose on its adding.
> make -j
>+ sudo make install
This target is common wide along all the jobs and may be it better to move the installation to the target ‘luacheck’ which only needs it.
>
> test_debian_no_deps: build_debian
> cd test && /usr/bin/python test-run.py --force $(TEST_RUN_EXTRA_PARAMS)
>@@ -145,6 +146,15 @@ test_static_build: deps_debian_static
> test_static_docker_build:
> docker build --network=host --build-arg RUN_TESTS=ON -f Dockerfile.staticbuild .
>
>+# ###################
>+# Static Analysis
>+# ###################
>+
>+test_debian_luacheck: build_debian
>+ tarantoolctl rocks install luacheck
>+ # TODO: run in parallel with LuaLanes
>+ .rocks/bin/luacheck --codes --config .luacheckrc .
>+
> #######
> # OSX #
> #######
>--
>2.23.0
>
--
Alexander Tikhonov
[-- Attachment #2: Type: text/html, Size: 5055 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 5/6] Add luacheck config
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
1 sibling, 0 replies; 27+ messages in thread
From: Alexander Tikhonov @ 2020-04-09 4:27 UTC (permalink / raw)
To: Sergey Bronnikov; +Cc: o.piskunov, tarantool-patches
[-- Attachment #1: Type: text/plain, Size: 12364 bytes --]
Hi Sergey, thank you for the patch. As I understood from the comments there are no actual issues blocked in the exclusions for which the new issue should be created and commented into the code, if so, then LGTM.
>Среда, 8 апреля 2020, 18:43 +03:00 от Sergey Bronnikov <estetus@gmail.com>:
>
>From: Sergey Bronnikov < sergeyb@tarantool.org >
>
>From the beginning we haven't use static analysis for Lua source code and
>therefore now we have about 32k warnings and errors produced by luacheck. Sure
>these issues are not real bugs but fixing them will make source code better and
>clear. Aim to fix all of them at once looks insane and perhaps it is not worth
>it.
>
>Summary of static analysis:
>
>There were no errors found by luacheck in production source code (src/),
>many warnings were fixed in previous commits and non-interested warnings were
>supressed using luacheck config.
>
>Lua source code in test/ directory contains both errors and warnings and there
>are a lot of them. Some of these warnings were fixed by previous commits and
>most part of warnings and errors supressed in luacheck config. Regarding
>errors: all found errors belongs to a single error class - "Syntax error"
>(E011). All of them have a single root cause - at the of testscases we write
>conditions without assignments and it is confuses luacheck. Usually such
>conditions used together with asserts, but in our tests we uses reference outputs
>instead of asserts.
>
>How-to check:
>
>$ tarantoolctl rocks install luacheck
>$ .rocks/bin/luacheck --codes --config .luacheckrc .
>
>Closes #4681
>---
> .luacheckrc | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 162 insertions(+)
> create mode 100644 .luacheckrc
>
>diff --git a/.luacheckrc b/.luacheckrc
>new file mode 100644
>index 000000000..2550f9f1a
>--- /dev/null
>+++ b/.luacheckrc
>@@ -0,0 +1,162 @@
>+include_files = {
>+ "**/*.lua",
>+ "extra/dist/tarantoolctl.in",
>+}
>+
>+exclude_files = {
>+ "third_party/**/*.lua",
>+ "test-run/**/*.lua",
>+ "test/wal_off/*.lua", -- E011
>+ "test/xlog/*.lua", -- E011
>+ "test/vinyl/*.lua", -- E011
>+ "test/sql/*.lua", -- E011
>+ "test/replication/*.lua", -- E011
>+ "test/engine/*.lua", -- E011
>+ "test/swim/*.lua", -- E011
>+ "test/box/*.lua", -- E011
>+ "test/app/*.lua", -- E011
>+ "test/app-tap/*.lua", -- E011
>+ "test/app-tap/lua/serializer_test.lua", -- E011
>+ "build/**/*.lua",
>+ ".rocks/**/*.lua",
>+ ".git/**/*.lua",
>+}
>+
>+files["**/*.lua"] = {ignore = {"212", "122"}}
>+files["extra/dist/tarantoolctl.in"] = {ignore = {"431", "411", "122", "542"}}
>+files["src/lua/help.lua"] = {globals = {"help", "tutorial"}, ignore = {"113", "211"}}
>+files["src/lua/swim.lua"] = {ignore = {"431"}}
>+files["src/lua/fio.lua"] = {ignore = {"231"}}
>+files["src/lua/init.lua"] = {ignore = {"122", "121"}}
>+files["src/lua/fiber.lua"] = {ignore = {"331", "311"}}
>+files["src/box/lua/serpent.lua"] = {globals = {"_ENV"}, ignore = {"431", "421", "631", "432", "542", "412", "422"}}
>+files["src/box/lua/load_cfg.lua"] = {ignore = {"431", "143", "311", "542"}}
>+files["src/box/lua/net_box.lua"] = {ignore = {"431", "211", "421", "432", "311", "231", "411", "412"}}
>+files["src/box/lua/schema.lua"] = {globals = {"update_format", "iid", "role_check_grant_revoke_of_sys_priv"}, ignore = {"431", "122", "211", "421", "213", "432", "311", "542", "412"}}
>+files["src/box/lua/key_def.lua"] = {ignore = {"431"}}
>+files["src/box/lua/feedback_daemon.lua"] = {ignore = {"122", "211"}}
>+files["src/box/lua/tuple.lua"] = {ignore = {"122", "211", "421", "412"}}
>+files["src/box/lua/upgrade.lua"] = {ignore = {"122", "211", "421", "213"}}
>+files["src/box/lua/console.lua"] = {globals = {"help"}, ignore = {"211", "143"}}
>+files["test/**/*.lua"] = {ignore = {"631", "611", "614", "613", "612", "621", "112", "211", "432"}}
>+files["test/app/*.lua"] = {ignore = {"111", "113"}}
>+files["test/app/lua/fiber.lua"] = {ignore = {"111"}}
>+files["test/app-tap/*.lua"] = {ignore = {"111", "113"}}
>+files["test/app-tap/tarantoolctl.test.lua"] = {ignore = {"511"}}
>+files["test/app-tap/lua/require_mod.lua"] = {ignore = {"113", "111"}}
>+files["test/box/admin.test.lua"] = {ignore = {"213"}}
>+files["test/box/lua/*.lua"] = {ignore = {"111"}}
>+files["test/box/*.lua"] = {ignore = {"111", "113"}}
>+files["test/box/lua/utils.lua"] = {ignore = {"421", "113", "213", "412"}}
>+files["test/box/lua/bitset.lua"] = {ignore = {"113", "213"}}
>+files["test/box/lua/fifo.lua"] = {ignore = {"113", "213"}}
>+files["test/box/lua/identifier.lua"] = {ignore = {"113"}}
>+files["test/box/lua/require_mod.lua"] = {ignore = {"113"}}
>+files["test/box/lua/require_init.lua"] = {ignore = {"412", "143"}}
>+files["test/box/lua/test_init.lua"] = {ignore = {"113", "412", "143"}}
>+files["test/box/lua/index_random_test.lua"] = {ignore = {"213"}}
>+files["test/box-tap/*.lua"] = {ignore = {"111"}}
>+files["test/box-tap/auth.test.lua"] = {ignore = {"311", "411", "113"}}
>+files["test/box-tap/cfg.test.lua"] = {ignore = {"311", "411", "113"}}
>+files["test/box-tap/cfgup.test.lua"] = {ignore = {"113"}}
>+files["test/box-tap/feedback_daemon.test.lua"] = {ignore = {"411"}}
>+files["test/box-tap/gc.test.lua"] = {ignore = {"421"}}
>+files["test/box-tap/on_schema_init.test.lua"] = {ignore = {"113"}}
>+files["test/box-tap/schema_mt.test.lua"] = {ignore = {"113", "122"}}
>+files["test/box-tap/key_def.test.lua"] = {ignore = {"411", "431"}}
>+files["test/box-tap/merger.test.lua"] = {ignore = {"411", "431", "412", "213"}}
>+files["test/box-tap/session.storage.test.lua"] = {ignore = {"113"}}
>+files["test/box-tap/session.test.lua"] = {ignore = {"411", "113", "412", "143"}}
>+files["test/box-tap/trigger_atexit.test.lua"] = {ignore = {"113"}}
>+files["test/box-tap/trigger_yield.test.lua"] = {ignore = {"213", "113"}}
>+files["test/luajit-tap/fix_string_find_recording.test.lua"] = {ignore = {"111", "113", "231"}}
>+files["test/luajit-tap/gh-4476-fix-string-find-recording.test.lua"] = {ignore = {"231"}}
>+files["test/luajit-tap/fold_bug_LuaJIT_505.test.lua"] = {ignore = {"111", "113"}}
>+files["test/luajit-tap/gh.test.lua"] = {ignore = {"111", "113"}}
>+files["test/luajit-tap/table_chain_bug_LuaJIT_494.test.lua"] = {ignore = {"111", "113"}}
>+files["test/luajit-tap/unsink_64_kptr.test.lua"] = {ignore = {"111", "113", "551", "542"}}
>+files["test/luajit-tap/or-232-unsink-64-kptr.test.lua"] = {ignore = {"542"}}
>+files["test/luajit-tap/lj-494-table-chain-infinite-loop.test.lua"] = {ignore = {"111", "113", "213"}}
>+files["test/engine/*.lua"] = {ignore = {"111", "113"}}
>+files["test/engine_long/suite.lua"] = {ignore = {"421", "111", "213"}}
>+files["test/engine_long/delete_replace_update.test.lua"] = {ignore = {"113", "111"}}
>+files["test/engine_long/delete_insert.test.lua"] = {ignore = {"113", "111"}}
>+files["test/long_run-py/suite.lua"] = {ignore = {"421", "111", "113", "213"}}
>+files["test/long_run-py/lua/finalizers.lua"] = {ignore = {"241", "511", "111", "113"}}
>+files["test/replication/*.lua"] = {ignore = {"113", "111"}}
>+files["test/replication/lua/fast_replica.lua"] = {ignore = {"113", "213"}}
>+files["test/replication/lua/rlimit.lua"] = {ignore = {"113"}}
>+files["test/replication-py/replica.lua"] = {ignore = {"111"}}
>+files["test/replication/lua/fast_replica.lua"] = {ignore = {"113", "111", "213"}}
>+files["test/replication/lua/rlimit.lua"] = {ignore = {"113", "111"}}
>+files["test/sql/*.lua"] = {ignore = {"113", "111"}}
>+files["test/sql/triggers.test.lua"] = {ignore = {"631", "113", "111"}}
>+files["test/sql/tokenizer.test.lua"] = {ignore = {"113", "111"}}
>+files["test/sql/transitive-transactions.test.lua"] = {ignore = {"113", "111"}}
>+files["test/sql/savepoints.test.lua"] = {ignore = {"113", "111"}}
>+files["test/sql/persistency.test.lua"] = {ignore = {"113", "111"}}
>+files["test/sql-tap/*.lua"] = {ignore = {"113", "111"}}
>+files["test/sql-tap/lua_sql.test.lua"] = {ignore = {"412"}}
>+files["test/sql-tap/subquery.test.lua"] = {ignore = {"412", "143"}}
>+files["test/sql-tap/alias.test.lua"] = {ignore = {"412", "143"}}
>+files["test/sql-tap/analyze9.test.lua"] = {ignore = {"213", "411"}}
>+files["test/sql-tap/between.test.lua"] = {ignore = {"421", "213"}}
>+files["test/sql-tap/check.test.lua"] = {ignore = {"412", "143"}}
>+files["test/sql-tap/date.test.lua"] = {ignore = {"511"}}
>+files["test/sql-tap/e_expr.test.lua"] = {ignore = {"512", "431", "213", "411"}}
>+files["test/sql-tap/func.test.lua"] = {ignore = {"412", "143"}}
>+files["test/sql-tap/func5.test.lua"] = {ignore = {"412", "143"}}
>+files["test/sql-tap/misc1.test.lua"] = {ignore = {"411"}}
>+files["test/sql-tap/select1.test.lua"] = {ignore = {"511", "213"}}
>+files["test/sql-tap/select2.test.lua"] = {ignore = {"421"}}
>+files["test/sql-tap/select4.test.lua"] = {ignore = {"421"}}
>+files["test/sql-tap/select5.test.lua"] = {ignore = {"421"}}
>+files["test/sql-tap/selectA.test.lua"] = {ignore = {"542"}}
>+files["test/sql-tap/selectB.test.lua"] = {ignore = {"213", "542"}}
>+files["test/sql-tap/selectG.test.lua"] = {ignore = {"421"}}
>+files["test/sql-tap/table.test.lua"] = {ignore = {"511"}}
>+files["test/sql-tap/tkt-bd484a090c.test.lua"] = {ignore = {"511"}}
>+files["test/sql-tap/tkt-38cb5df375.test.lua"] = {ignore = {"421"}}
>+files["test/sql-tap/tkt-91e2e8ba6f.test.lua"] = {ignore = {"542"}}
>+files["test/sql-tap/tkt-9a8b09f8e6.test.lua"] = {ignore = {"542"}}
>+files["test/sql-tap/tkt2192.test.lua"] = {ignore = {"511"}}
>+files["test/sql-tap/tkt3493.test.lua"] = {ignore = {"542"}}
>+files["test/sql-tap/triggerA.test.lua"] = {ignore = {"311"}}
>+files["test/sql-tap/trigger2.test.lua"] = {ignore = {"213"}}
>+files["test/sql-tap/trigger9.test.lua"] = {ignore = {"143", "412"}}
>+files["test/sql-tap/update.test.lua"] = {ignore = {"611"}}
>+files["test/sql-tap/whereB.test.lua"] = {ignore = {"611"}}
>+files["test/sql-tap/with1.test.lua"] = {ignore = {"542"}}
>+files["test/sql-tap/with2.test.lua"] = {ignore = {"213", "412"}}
>+files["test/sql-tap/lua_sql.test.lua"] = {ignore = {"143"}}
>+files["test/sql-tap/lua/sqltester.lua"] = {ignore = {"111", "113", "431", "213"}}
>+files["test/sql-tap/gh-2723-concurrency.test.lua"] = {ignore = {"213"}}
>+files["test/sql-tap/gh-3307-xfer-optimization-issue.test.lua"] = {ignore = {"412", "213"}}
>+files["test/sql-tap/gh-3083-ephemeral-unref-tuples.test.lua"] = {ignore = {"213"}}
>+files["test/sql-tap/gh-3332-tuple-format-leak.test.lua"] = {ignore = {"213"}}
>+files["test/sql-tap/gh2127-indentifier-max-length.test.lua"] = {ignore = {"213"}}
>+files["test/sql-tap/misc5.test.lua"] = {ignore = {"213"}}
>+files["test/wal_off/rtree_benchmark.test.lua"] = {ignore = {"213", "113", "111"}}
>+files["test/wal_off/func_max.test.lua"] = {ignore = {"511", "113", "111"}}
>+files["test/vinyl/upgrade/fill.lua"] = {ignore = {"111", "113"}}
>+files["test/vinyl/write_iterator_rand.test.lua"] = {ignore = {"113", "111"}}
>+files["test/vinyl/savepoint.test.lua"] = {ignore = {"113", "111"}}
>+files["test/vinyl/replica_quota.test.lua"] = {ignore = {"113", "111", "213"}}
>+files["test/vinyl/stress.test.lua"] = {ignore = {"431", "213"}}
>+files["test/vinyl/hermitage.test.lua"] = {ignore = {"113", "111"}}
>+files["test/vinyl/dump_stress.test.lua"] = {ignore = {"113", "111"}}
>+files["test/vinyl/constraint.test.lua"] = {ignore = {"113", "111"}}
>+files["test/vinyl/large.test.lua"] = {ignore = {"113", "111"}}
>+files["test/vinyl/options.test.lua"] = {ignore = {"113", "111"}}
>+files["test/xlog/upgrade/2.1.3/gh-4771-upgrade-sequence/fill.lua"] = {ignore = {"111", "113"}}
>+files["test/xlog/transaction.test.lua"] = {ignore = {"113", "111"}}
>+files["test/xlog/snap_io_rate.test.lua"] = {ignore = {"113", "111"}}
>+files["test/xlog/reader.test.lua"] = {ignore = {"113", "111"}}
>+files["test/xlog/panic_on_broken_lsn.test.lua"] = {ignore = {"113", "111"}}
>+files["test/xlog/gh1433.test.lua"] = {ignore = {"113", "111"}}
>+files["test/xlog/header.test.lua"] = {ignore = {"113", "111"}}
>+files["test/xlog/errinj.test.lua"] = {ignore = {"113", "111"}}
>+files["test/xlog/force_recovery.test.lua"] = {ignore = {"113", "111"}}
>+files["test/xlog/big_tx.test.lua"] = {ignore = {"113", "111"}}
>+files["test/xlog/checkpoint_threshold.test.lua"] = {ignore = {"113", "111", "213"}}
>+files["test/swim/box.lua"] = {ignore = {"113", "111"}}
>--
>2.23.0
>
--
Alexander Tikhonov
[-- Attachment #2: Type: text/html, Size: 13278 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 4/6] Fix luacheck warnings in extra/dist/tarantoolctl.in
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-15 15:14 ` Igor Munkin
2 siblings, 0 replies; 27+ messages in thread
From: Alexander Tikhonov @ 2020-04-09 4:29 UTC (permalink / raw)
To: Sergey Bronnikov; +Cc: o.piskunov, tarantool-patches
[-- Attachment #1: Type: text/plain, Size: 4141 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 >
>
>Closes #4681
>---
> extra/dist/tarantoolctl.in | 20 +++++++++-----------
> 1 file changed, 9 insertions(+), 11 deletions(-)
>
>diff --git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in
>index f5a912ccd..3bcbe5b79 100755
>--- a/extra/dist/tarantoolctl.in
>+++ b/extra/dist/tarantoolctl.in
>@@ -46,7 +46,6 @@ local instance_dir
> local default_cfg
> local positional_arguments
> local keyword_arguments
>-local lua_arguments = arg
> local language
>
> -- function for printing usage reference
>@@ -64,7 +63,7 @@ end
>
> local function check_user_level()
> local uid = os.getenv('UID')
>- local udir = nil
>+ local udir
> if uid == 0 or os.getenv("NOTIFY_SOCKET") then
> return nil
> end
>@@ -420,7 +419,7 @@ local cat_formats = setmetatable({
> json = cat_json_cb,
> lua = cat_lua_cb,
> }, {
>- __index = function(self, cmd)
>+ __index = function(cmd)
> error(("Unknown formatter '%s'"):format(cmd))
> end
> })
>@@ -790,7 +789,7 @@ end
> local function eval()
> local console_sock_path = uri.parse(console_sock).service
> local filename = arg[3]
>- local code = nil
>+ local code
> if filename == nil then
> if stdin_isatty() then
> log.error("Usage:")
>@@ -848,7 +847,6 @@ end
> -- xlog / snap file, so even when it stops on LSN >= @a opts.to on
> -- a current file a next file will be processed.
> local function filter_xlog(gen, param, state, opts, cb)
>- local spaces = opts.spaces
> local from, to, spaces = opts.from, opts.to, opts.space
> local show_system, replicas = opts['show-system'], opts.replica
>
>@@ -875,7 +873,7 @@ local function cat()
> local cat_format = opts.format
> local format_cb = cat_formats[cat_format]
> local is_printed = false
>- for id, file in ipairs(positional_arguments) do
>+ for _, file in ipairs(positional_arguments) do
> log.error("Processing file '%s'", file)
> local gen, param, state = xlog.pairs(file)
> filter_xlog(gen, param, state, opts, function(record)
>@@ -901,7 +899,7 @@ local function play()
> if not remote:wait_connected() then
> error(("Error while connecting to host '%s'"):format(uri))
> end
>- for id, file in ipairs(positional_arguments) do
>+ for _, file in ipairs(positional_arguments) do
> log.info(("Processing file '%s'"):format(file))
> local gen, param, state = xlog.pairs(file)
> filter_xlog(gen, param, state, opts, function(record)
>@@ -923,7 +921,7 @@ local function play()
> end
>
> local function find_arg(name_arg)
>- for i, key in ipairs(arg) do
>+ for _, key in ipairs(arg) do
> if key:find(name_arg) ~= nil then
> return key
> end
>@@ -937,7 +935,7 @@ local function rocks()
> local util = require("luarocks.util")
> local command_line = require("luarocks.cmd")
> local options = keyword_arguments
>- local key = nil
>+ local key
> if options["only-server"] ~= nil then
> key = find_arg("only%-server")
> else
>@@ -954,7 +952,7 @@ local function rocks()
> end
>
> -- Tweak help messages
>- util.see_help = function(command, program)
>+ util.see_help = function()
> -- TODO: print extended help message here
> return "See Tarantool documentation for help."
> end
>@@ -1321,7 +1319,7 @@ local function usage_command(name, cmd)
> if type(header) == 'string' then
> header = { header }
> end
>- for no, line in ipairs(header) do
>+ for _, line in ipairs(header) do
> log.error(" " .. line, name)
> end
> end
>--
>2.23.0
>
--
Alexander Tikhonov
[-- Attachment #2: Type: text/html, Size: 6198 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 3/6] Fix luacheck warnings in src/box/lua/
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
0 siblings, 0 replies; 27+ messages in thread
From: Alexander Tikhonov @ 2020-04-09 4:29 UTC (permalink / raw)
To: Sergey Bronnikov; +Cc: o.piskunov, tarantool-patches
[-- Attachment #1: Type: text/plain, Size: 3781 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 >
>
>Closes #4681
>---
> src/box/lua/upgrade.lua | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
>diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua
>index 075cc236e..6b8ece513 100644
>--- a/src/box/lua/upgrade.lua
>+++ b/src/box/lua/upgrade.lua
>@@ -173,7 +173,7 @@ local function initial_1_7_5()
> format[5] = {name='field_count', type='unsigned'}
> format[6] = {name='flags', type='map'}
> format[7] = {name='format', type='array'}
>- local def = _space:insert{_space.id, ADMIN, '_space', 'memtx', 0, MAP, format}
>+ _space:insert{_space.id, ADMIN, '_space', 'memtx', 0, MAP, format}
> -- space name is unique
> log.info("create index primary on _space")
> _index:insert{_space.id, 0, 'primary', 'tree', { unique = true }, {{0, 'unsigned'}}}
>@@ -194,7 +194,7 @@ local function initial_1_7_5()
> format[4] = {name = 'type', type = 'string'}
> format[5] = {name = 'opts', type = 'map'}
> format[6] = {name = 'parts', type = 'array'}
>- def = _space:insert{_index.id, ADMIN, '_index', 'memtx', 0, MAP, format}
>+ _space:insert{_index.id, ADMIN, '_index', 'memtx', 0, MAP, format}
> -- index name is unique within a space
> log.info("create index primary on _index")
> _index:insert{_index.id, 0, 'primary', 'tree', {unique = true}, {{0, 'unsigned'}, {1, 'unsigned'}}}
>@@ -211,7 +211,7 @@ local function initial_1_7_5()
> format[2] = {name='owner', type='unsigned'}
> format[3] = {name='name', type='string'}
> format[4] = {name='setuid', type='unsigned'}
>- def = _space:insert{_func.id, ADMIN, '_func', 'memtx', 0, MAP, format}
>+ _space:insert{_func.id, ADMIN, '_func', 'memtx', 0, MAP, format}
> -- function name and id are unique
> log.info("create index _func:primary")
> _index:insert{_func.id, 0, 'primary', 'tree', {unique = true}, {{0, 'unsigned'}}}
>@@ -231,7 +231,7 @@ local function initial_1_7_5()
> format[3] = {name='name', type='string'}
> format[4] = {name='type', type='string'}
> format[5] = {name='auth', type='map'}
>- def = _space:insert{_user.id, ADMIN, '_user', 'memtx', 0, MAP, format}
>+ _space:insert{_user.id, ADMIN, '_user', 'memtx', 0, MAP, format}
> -- user name and id are unique
> log.info("create index _func:primary")
> _index:insert{_user.id, 0, 'primary', 'tree', {unique = true}, {{0, 'unsigned'}}}
>@@ -251,7 +251,7 @@ local function initial_1_7_5()
> format[3] = {name='object_type', type='string'}
> format[4] = {name='object_id', type='unsigned'}
> format[5] = {name='privilege', type='unsigned'}
>- def = _space:insert{_priv.id, ADMIN, '_priv', 'memtx', 0, MAP, format}
>+ _space:insert{_priv.id, ADMIN, '_priv', 'memtx', 0, MAP, format}
> -- user id, object type and object id are unique
> log.info("create index primary on _priv")
> _index:insert{_priv.id, 0, 'primary', 'tree', {unique = true}, {{1, 'unsigned'}, {2, 'string'}, {3, 'unsigned'}}}
>@@ -580,7 +580,7 @@ local function upgrade_to_2_1_0()
> -- Now, abscent field means NULL, so we can safely set second
> -- field in format, marking it nullable.
> log.info("Add nullable value field to space _schema")
>- local format = {}
>+ format = {}
> format[1] = {type='string', name='key'}
> format[2] = {type='any', name='value', is_nullable=true}
> box.space._schema:format(format)
>--
>2.23.0
>
--
Alexander Tikhonov
[-- Attachment #2: Type: text/html, Size: 5133 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 2/6] Fix luacheck warnings in test/
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-11 16:54 ` Vladislav Shpilevoy
2 siblings, 0 replies; 27+ messages in thread
From: Alexander Tikhonov @ 2020-04-09 4:31 UTC (permalink / raw)
To: Sergey Bronnikov; +Cc: o.piskunov, tarantool-patches
[-- Attachment #1: Type: text/plain, Size: 47787 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 >
>
>Closes #4681
>---
> test/app-tap/console.test.lua | 4 ---
> test/app-tap/csv.test.lua | 28 ++++++++--------
> test/box-py/box.lua | 2 +-
> test/box-tap/gc.test.lua | 4 +--
> test/box/box.lua | 2 +-
> test/box/hash_multipart.result | 2 +-
> test/box/hash_multipart.test.lua | 2 +-
> test/box/iproto_stress.result | 8 ++---
> test/box/iproto_stress.test.lua | 4 +--
> 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/utils.lua | 3 +-
> test/box/on_schema_init.lua | 2 +-
> test/box/proxy.lua | 2 +-
> test/box/tiny.lua | 2 +-
> test/box/tree_pk.result | 6 ++--
> test/box/tree_pk.test.lua | 6 ++--
> test/engine/tree_min_max_count.result | 2 +-
> test/engine/tree_min_max_count.test.lua | 2 +-
> test/replication-py/master.lua | 2 +-
> test/replication-py/panic.lua | 2 +-
> test/replication/master.lua | 2 +-
> test/replication/replicaset_ro_mostly.result | 2 +-
> .../replication/replicaset_ro_mostly.test.lua | 2 +-
> test/sql-tap/analyze3.test.lua | 6 ++--
> test/sql-tap/analyze9.test.lua | 16 ++++-----
> .../gh-4077-iproto-execute-no-bind.test.lua | 7 ++--
> test/sql-tap/index1.test.lua | 1 -
> test/sql-tap/join3.test.lua | 2 +-
> test/sql-tap/select9.test.lua | 10 ++----
> test/sql-tap/tkt-fa7bf5ec.test.lua | 6 ++--
> test/sql-tap/where2.test.lua | 2 +-
> test/sql/lua/sql_tokenizer.lua | 2 +-
> test/sql/savepoints.result | 6 ++--
> test/sql/savepoints.test.lua | 6 ++--
> test/sql/triggers.result | 2 +-
> test/sql/triggers.test.lua | 2 +-
> test/vinyl/large.lua | 4 +--
> test/vinyl/stat.result | 33 ++++++++++++-------
> test/vinyl/stat.test.lua | 22 ++++++-------
> test/vinyl/txn_proxy.lua | 6 ++--
> test/vinyl/vinyl.lua | 2 +-
> test/wal_off/rtree_benchmark.result | 2 +-
> test/wal_off/rtree_benchmark.test.lua | 2 +-
> test/xlog-py/box.lua | 2 +-
> test/xlog/big_tx.result | 2 +-
> test/xlog/big_tx.test.lua | 2 +-
> test/xlog/checkpoint_daemon.result | 4 +--
> test/xlog/checkpoint_daemon.test.lua | 4 +--
> test/xlog/panic.lua | 2 +-
> test/xlog/panic_on_wal_error.result | 2 +-
> test/xlog/panic_on_wal_error.test.lua | 2 +-
> test/xlog/reader.result | 2 +-
> test/xlog/reader.test.lua | 2 +-
> test/xlog/snap_io_rate.test.lua | 2 +-
> test/xlog/transaction.result | 18 +++++-----
> test/xlog/transaction.test.lua | 18 +++++-----
> test/xlog/xlog.lua | 2 +-
> 64 files changed, 157 insertions(+), 155 deletions(-)
>
>diff --git a/test/app-tap/console.test.lua b/test/app-tap/console.test.lua
>index da5c1e71e..737450387 100755
>--- a/test/app-tap/console.test.lua
>+++ b/test/app-tap/console.test.lua
>@@ -5,7 +5,6 @@ local console = require('console')
> local socket = require('socket')
> local yaml = require('yaml')
> local fiber = require('fiber')
>-local ffi = require('ffi')
> local log = require('log')
> local fio = require('fio')
>
>@@ -59,12 +58,9 @@ test:is(#client:read(EOL) > 0, true, "_G")
> client:write("require('fiber').id()\n")
> local fid1 = yaml.decode(client:read(EOL))[1]
> local state = fiber.find(fid1).storage.console
>-local server_info = state.client:peer()
> local client_info = state.client:name()
> test:is(client_info.host, client_info.host, "state.socker:peer().host")
> test:is(client_info.port, client_info.port, "state.socker:peer().port")
>-server_info = nil
>-client_info = nil
>
> -- Check console.delimiter()
> client:write("require('console').delimiter(';')\n")
>diff --git a/test/app-tap/csv.test.lua b/test/app-tap/csv.test.lua
>index a7f17b1ea..689db7997 100755
>--- a/test/app-tap/csv.test.lua
>+++ b/test/app-tap/csv.test.lua
>@@ -2,9 +2,9 @@
>
> local function table2str(t)
> local res = ""
>- for k, line in pairs(t) do
>+ for _, line in pairs(t) do
> local s = ""
>- for k2, field in pairs(line) do
>+ for _, field in pairs(line) do
> s = s .. '|' .. field .. '|\t'
> end
> res = res .. s .. '\n'
>@@ -12,9 +12,9 @@ local function table2str(t)
> return res
> end
>
>-local function myread(self, bytes)
>+local function myread(self, bytes)
> self.i = self.i + bytes
>- return self.v:sub(self.i - bytes + 1, self.i)
>+ return self.v:sub(self.i - bytes + 1, self.i)
> end
> local csv = require('csv')
> local fio = require('fio')
>@@ -27,10 +27,10 @@ local test4_ans = '|123|\t|5|\t|92|\t|0|\t|0|\t\n|1|\t|12 34|\t|56|\t' ..
> local test5_ans = "|1|\t\n|23|\t|456|\t|abcac|\t|'multiword field 4'|\t\n" ..
> "|none|\t|none|\t|0|\t\n||\t||\t||\t\n|aba|\t|adda|\t|f" ..
> "3|\t|0|\t\n|local res = internal.pwrite(self.fh|\t|dat" ..
>- "a|\t|len|\t|offset)|\t\n|iflag = bit.bor(iflag|\t|fio." ..
>+ "a|\t|len|\t|offset)|\t\n|iflag = bit.bor(iflag|\t|fio." ..
> "c.flag[ flag ])|\t\n||\t||\t||\t\n"
> local test6_ans = "|23|\t|456|\t|abcac|\t|'multiword field 4'|\t\n|none|" ..
>- "\t|none|\t|0|\t\n||\t||\t||\t\n|aba|\t|adda|\t|f3|\t|" ..
>+ "\t|none|\t|0|\t\n||\t||\t||\t\n|aba|\t|adda|\t|f3|\t|" ..
> "0|\t\n|local res = internal.pwrite(self.fh|\t|data|\t" ..
> "|len|\t|offset)|\t\n|iflag = bit.bor(iflag|\t|fio.c.f" ..
> "lag[ flag ])|\t\n||\t||\t||\t\n"
>@@ -62,7 +62,7 @@ local f = fio.open(file1, { 'O_WRONLY', 'O_TRUNC', 'O_CREAT' }, tonumber('0777',
> f:write("123 , 5 , 92 , 0, 0\n" ..
> "1, 12 34, 56, \"quote , \", 66\nok")
> f:close()
>-f = fio.open(file1, {'O_RDONLY'})
>+f = fio.open(file1, {'O_RDONLY'})
> test:is(table2str(csv.load(f, {chunk_size = 10})), test4_ans, "fio test1")
> f:close()
>
>@@ -77,20 +77,20 @@ f:write("1\n23,456,abcac,\'multiword field 4\'\n" ..
> ",,"
> )
> f:close()
>-f = fio.open(file2, {'O_RDONLY'})
>+f = fio.open(file2, {'O_RDONLY'})
> --symbol by symbol reading
>-test:is(table2str(csv.load(f, {chunk_size = 1})), test5_ans, "fio test2")
>+test:is(table2str(csv.load(f, {chunk_size = 1})), test5_ans, "fio test2")
> f:close()
>
>-f = fio.open(file2, {'O_RDONLY'})
>+f = fio.open(file2, {'O_RDONLY'})
> opts = {chunk_size = 7, skip_head_lines = 1}
> --7 symbols per chunk
>-test:is(table2str(csv.load(f, opts)), test6_ans, "fio test3")
>+test:is(table2str(csv.load(f, opts)), test6_ans, "fio test3")
> f:close()
>
> t = {
>- {'quote" d', ',and, comma', 'both " of " t,h,e,m'},
>- {'"""', ',","'},
>+ {'quote" d', ',and, comma', 'both " of " t,h,e,m'},
>+ {'"""', ',","'},
> {'mul\nti\nli\r\nne\n\n', 'field'},
> {""},
> {'"'},
>@@ -100,7 +100,7 @@ t = {
> f = require("fio").open(file3, { "O_WRONLY", "O_TRUNC" , "O_CREAT"}, 0x1FF)
> csv.dump(t, {}, f)
> f:close()
>-f = fio.open(file3, {'O_RDONLY'})
>+f = fio.open(file3, {'O_RDONLY'})
> t2 = csv.load(f, {chunk_size = 5})
> f:close()
>
>diff --git a/test/box-py/box.lua b/test/box-py/box.lua
>index e9403774c..35a087de9 100644
>--- a/test/box-py/box.lua
>+++ b/test/box-py/box.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-tap/gc.test.lua b/test/box-tap/gc.test.lua
>index f88752e71..f0155779c 100755
>--- a/test/box-tap/gc.test.lua
>+++ b/test/box-tap/gc.test.lua
>@@ -4,7 +4,7 @@ local fiber = require('fiber')
>
> box.cfg{}
>
>-local debug = type(box.error.injection) == "table"
>+local debug = type(box.error.injection) == "table"
>
> -- check box.info.gc() is false if snapshot is not in progress
> local test = tap.test('box.info.gc')
>@@ -19,7 +19,7 @@ test:is(gc.checkpoint_is_in_progress, false, "checkpoint is not in progress")
> if debug then
> box.error.injection.set("ERRINJ_SNAP_COMMIT_DELAY", true)
> local snapshot_f = function()
>- box.snapshot()
>+ box.snapshot()
> end
> fiber.create(snapshot_f)
> local gc = box.info.gc()
>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/iproto_stress.result b/test/box/iproto_stress.result
>index 7149d6c52..3b5b0a031 100644
>--- a/test/box/iproto_stress.result
>+++ b/test/box/iproto_stress.result
>@@ -76,13 +76,13 @@ test_run:wait_cond(function() return n_workers == 0 end, 60)
> ---
> - true
> ...
>-n_workers -- 0
>+assert(n_workers == 0)
> ---
>-- 0
>+- true
> ...
>-n_errors -- 0
>+assert(n_errors == 0)
> ---
>-- 0
>+- true
> ...
> box.schema.user.revoke('guest', 'read,write,execute', 'universe')
> ---
>diff --git a/test/box/iproto_stress.test.lua b/test/box/iproto_stress.test.lua
>index 1e1a6578b..68d1f56fd 100644
>--- a/test/box/iproto_stress.test.lua
>+++ b/test/box/iproto_stress.test.lua
>@@ -42,8 +42,8 @@ fiber.sleep(0.1)
> box.error.injection.set("ERRINJ_WAL_DELAY", false)
>
> test_run:wait_cond(function() return n_workers == 0 end, 60)
>-n_workers -- 0
>-n_errors -- 0
>+assert(n_workers == 0)
>+assert(n_errors == 0)
>
> box.schema.user.revoke('guest', 'read,write,execute', 'universe')
> s:drop()
>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/utils.lua b/test/box/lua/utils.lua
>index 5f859fd19..058c4a471 100644
>--- a/test/box/lua/utils.lua
>+++ b/test/box/lua/utils.lua
>@@ -212,10 +212,9 @@ function create_iterator(obj, key, opts)
> 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..4489d8cd9 100644
>--- a/test/box/tree_pk.result
>+++ b/test/box/tree_pk.result
>@@ -27,7 +27,7 @@ box.snapshot()
> ---
> - ok
> ...
>-i0:bsize() > bsize
>+assert(i0:bsize() > bsize)
> ---
> - true
> ...
>@@ -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..bc3784a98 100644
>--- a/test/box/tree_pk.test.lua
>+++ b/test/box/tree_pk.test.lua
>@@ -11,7 +11,7 @@ box.snapshot()
> s0:insert{2, 'tuple 2'}
> box.snapshot()
>
>-i0:bsize() > bsize
>+assert(i0:bsize() > bsize)
>
> s0:insert{3, 'tuple 3'}
> s0.index['primary']:get{1}
>@@ -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
>diff --git a/test/engine/tree_min_max_count.result b/test/engine/tree_min_max_count.result
>index f55732aa6..9f1595a20 100644
>--- a/test/engine/tree_min_max_count.result
>+++ b/test/engine/tree_min_max_count.result
>@@ -1189,7 +1189,7 @@ space6:drop()
> ---
> ...
> -- min max count after many inserts
>-string = require('string')
>+local string = require('string')
> ---
> ...
> space7 = box.schema.space.create('space7', { engine = engine })
>diff --git a/test/engine/tree_min_max_count.test.lua b/test/engine/tree_min_max_count.test.lua
>index 0633c56b3..19b5fe92d 100644
>--- a/test/engine/tree_min_max_count.test.lua
>+++ b/test/engine/tree_min_max_count.test.lua
>@@ -337,7 +337,7 @@ space6:drop()
>
> -- min max count after many inserts
>
>-string = require('string')
>+local string = require('string')
>
> space7 = box.schema.space.create('space7', { engine = engine })
> index7 = space7:create_index('primary', { type = 'tree', parts = {1, 'scalar'} })
>diff --git a/test/replication-py/master.lua b/test/replication-py/master.lua
>index e924b5495..b43bafd54 100644
>--- a/test/replication-py/master.lua
>+++ b/test/replication-py/master.lua
>@@ -1,5 +1,5 @@
> #!/usr/bin/env tarantool
>-os = require('os')
>+local os = require('os')
> box.cfg({
> listen = os.getenv("LISTEN"),
> memtx_memory = 107374182,
>diff --git a/test/replication-py/panic.lua b/test/replication-py/panic.lua
>index 75a738cbb..e72d11419 100644
>--- a/test/replication-py/panic.lua
>+++ b/test/replication-py/panic.lua
>@@ -1,5 +1,5 @@
> #!/usr/bin/env tarantool
>-os = require('os')
>+local os = require('os')
> box.cfg({
> listen = os.getenv("LISTEN"),
> memtx_memory = 107374182,
>diff --git a/test/replication/master.lua b/test/replication/master.lua
>index e924b5495..b43bafd54 100644
>--- a/test/replication/master.lua
>+++ b/test/replication/master.lua
>@@ -1,5 +1,5 @@
> #!/usr/bin/env tarantool
>-os = require('os')
>+local os = require('os')
> box.cfg({
> listen = os.getenv("LISTEN"),
> memtx_memory = 107374182,
>diff --git a/test/replication/replicaset_ro_mostly.result b/test/replication/replicaset_ro_mostly.result
>index a471779d3..e509e0da0 100644
>--- a/test/replication/replicaset_ro_mostly.result
>+++ b/test/replication/replicaset_ro_mostly.result
>@@ -35,7 +35,7 @@ test_run:cmd("setopt delimiter ';'")
> - true
> ...
> function create_cluster_uuid(servers, uuids)
>- for i, name in ipairs(servers) do
>+ for _, name in ipairs(servers) do
> test_run:cmd(create_cluster_cmd1:format(name, name))
> end
> for i, name in ipairs(servers) do
>diff --git a/test/replication/replicaset_ro_mostly.test.lua b/test/replication/replicaset_ro_mostly.test.lua
>index 19cd1fe4a..e06e29c8e 100644
>--- a/test/replication/replicaset_ro_mostly.test.lua
>+++ b/test/replication/replicaset_ro_mostly.test.lua
>@@ -16,7 +16,7 @@ create_cluster_cmd2 = 'start server %s with args="%s", wait_load=False, wait=Fal
>
> test_run:cmd("setopt delimiter ';'")
> function create_cluster_uuid(servers, uuids)
>- for i, name in ipairs(servers) do
>+ for _, name in ipairs(servers) do
> test_run:cmd(create_cluster_cmd1:format(name, name))
> end
> for i, name in ipairs(servers) do
>diff --git a/test/sql-tap/analyze3.test.lua b/test/sql-tap/analyze3.test.lua
>index dcbea1da5..5c9c28601 100755
>--- a/test/sql-tap/analyze3.test.lua
>+++ b/test/sql-tap/analyze3.test.lua
>@@ -23,15 +23,15 @@ testprefix = "analyze3"
> ------------------------------------------------------------------------
> -- Test Organization:
> --
>--- analyze3-1.*: Test that the values of bound parameters are considered
>+-- analyze3-1.*: Test that the values of bound parameters are considered
> -- in the same way as constants when planning queries that
> -- use range constraints.
> --
>--- analyze3-2.*: Test that the values of bound parameters are considered
>+-- analyze3-2.*: Test that the values of bound parameters are considered
> -- in the same way as constants when planning queries that
> -- use LIKE expressions in the WHERE clause.
> --
>--- analyze3-3.*: Test that binding to a variable does not invalidate the
>+-- analyze3-3.*: Test that binding to a variable does not invalidate the
> -- query plan when there is no way in which replanning the
> -- query may produce a superior outcome.
> --
>diff --git a/test/sql-tap/analyze9.test.lua b/test/sql-tap/analyze9.test.lua
>index 02eb49f69..7412ba5fe 100755
>--- a/test/sql-tap/analyze9.test.lua
>+++ b/test/sql-tap/analyze9.test.lua
>@@ -609,7 +609,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
>@@ -657,7 +657,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
>@@ -711,7 +711,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\""
>@@ -762,7 +762,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\""
>@@ -823,7 +823,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\""
>@@ -874,7 +874,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\""
>@@ -931,7 +931,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\""
>@@ -1161,7 +1161,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/gh-4077-iproto-execute-no-bind.test.lua b/test/sql-tap/gh-4077-iproto-execute-no-bind.test.lua
>index d4b597e35..2f71a68ea 100755
>--- a/test/sql-tap/gh-4077-iproto-execute-no-bind.test.lua
>+++ b/test/sql-tap/gh-4077-iproto-execute-no-bind.test.lua
>@@ -41,10 +41,11 @@ local size = msgpack.encode(header:len() + body:len())
> sock:write(size .. header .. body)
>
> -- Read response.
>-local size = msgpack.decode(sock:read(5))
>+size = msgpack.decode(sock:read(5))
> local header_body = sock:read(size)
>-local header, header_len = msgpack.decode(header_body)
>-local body = msgpack.decode(header_body:sub(header_len))
>+local header_len
>+header, header_len = msgpack.decode(header_body)
>+body = msgpack.decode(header_body:sub(header_len))
> sock:close()
>
> -- Verify response.
>diff --git a/test/sql-tap/index1.test.lua b/test/sql-tap/index1.test.lua
>index e173e685c..4c4a37ca7 100755
>--- a/test/sql-tap/index1.test.lua
>+++ b/test/sql-tap/index1.test.lua
>@@ -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)
>diff --git a/test/sql-tap/join3.test.lua b/test/sql-tap/join3.test.lua
>index 876b3121a..030fbaba3 100755
>--- a/test/sql-tap/join3.test.lua
>+++ b/test/sql-tap/join3.test.lua
>@@ -49,7 +49,7 @@ for N=1, bitmask_size do
> end
> -- Joins with a comparison
> --
>-local result = {}
>+result = {}
> --for _ in X(0, "X!for", [=[["set N 1","$N<=$bitmask_size","incr N"]]=]) do
> for N=1, bitmask_size do
> table.insert(result,N)
>diff --git a/test/sql-tap/select9.test.lua b/test/sql-tap/select9.test.lua
>index 1ae16a658..bcc270593 100755
>--- a/test/sql-tap/select9.test.lua
>+++ b/test/sql-tap/select9.test.lua
>@@ -60,10 +60,8 @@ function subrange(t, first, last)
> end
>
> local function test_compound_select(testname, sql, result)
>- local nCol = 1
> local A = box.execute(sql) --test.box(sql)
>- nCol = #A.metadata
>- A = A.rows
>+ local nCol = #A.metadata
> local nRow = #result / nCol
> local compound_sql = sql
> test:do_execsql_test(
>@@ -274,10 +272,8 @@ test:do_execsql_test(
> -- </select9-2.0>
> })
>
>-local t1_space_id = ""
>-local t2_space_id = ""
>-t1_space_id = test:execsql([[SELECT * from "_space" where "name"='T1']])["id"]
>-t2_space_id = test:execsql([[SELECT * from "_space" where "name"='T2']])["id"]
>+local t1_space_id = test:execsql([[SELECT * from "_space" where "name"='T1']])["id"]
>+local t2_space_id = test:execsql([[SELECT * from "_space" where "name"='T2']])["id"]
> --X(276, "X!cmd", [=[["db","eval","SELECT * from _space where name='t2'","data","\n set t2_space_id $data(id)\n"]]=])
> --local function reverse(lhs, rhs)
> -- return X(283, "X!cmd", [=[["string","compare",["rhs"],["lhs"]]]=])
>diff --git a/test/sql-tap/tkt-fa7bf5ec.test.lua b/test/sql-tap/tkt-fa7bf5ec.test.lua
>index 7152e028c..25d44c9d3 100755
>--- a/test/sql-tap/tkt-fa7bf5ec.test.lua
>+++ b/test/sql-tap/tkt-fa7bf5ec.test.lua
>@@ -20,9 +20,9 @@ test:plan(1)
> -- The problem described by this ticket was that the sqlExprCompare()
> -- function was saying that expressions (x='a') and (x='A') were identical
> -- because it was using sqlStrICmp() instead of strcmp() to compare string
>--- literals. That was causing the query optimizer for aggregate queries to
>--- believe that both count() operations were identical, and thus only
>--- computing the first count() and making a copy of the result for the
>+-- literals. That was causing the query optimizer for aggregate queries to
>+-- believe that both count() operations were identical, and thus only
>+-- computing the first count() and making a copy of the result for the
> -- second count().
> --
> -- ["set","testdir",[["file","dirname",["argv0"]]]]
>diff --git a/test/sql-tap/where2.test.lua b/test/sql-tap/where2.test.lua
>index f267be8e6..f2db6fcee 100755
>--- a/test/sql-tap/where2.test.lua
>+++ b/test/sql-tap/where2.test.lua
>@@ -115,7 +115,7 @@ local function queryplan(sql)
> table.insert(data, tab)
> table.insert(data, idx)
> else
>- as, tab = string.match(v, "TABLE (%w+ AS) (%w+)")
>+ _, tab = string.match(v, "TABLE (%w+ AS) (%w+)")
> if tab == nil then
> tab = string.match(v, "TABLE (%w+)")
> end
>diff --git a/test/sql/lua/sql_tokenizer.lua b/test/sql/lua/sql_tokenizer.lua
>index 9922d792d..ffe4fb4e8 100644
>--- a/test/sql/lua/sql_tokenizer.lua
>+++ b/test/sql/lua/sql_tokenizer.lua
>@@ -134,7 +134,7 @@ end
> -- @retval Token type. If the rest of the SQL request consists of
> -- spaces and comments, then return TK_EMPTY.
> local function get_next_token(context)
>- local c = ''
>+ local c
> repeat
> local i = context.offset
> c = context.sql:sub(i, i)
>diff --git a/test/sql/savepoints.result b/test/sql/savepoints.result
>index 509c33e59..b0915f398 100644
>--- a/test/sql/savepoints.result
>+++ b/test/sql/savepoints.result
>@@ -102,12 +102,12 @@ collision_sv_2 = function()
> box.begin()
> box.execute('SAVEPOINT t1;')
> box.execute('SAVEPOINT t2;')
>- local _,err = box.execute('SAVEPOINT t1;')
>+ local _, err = box.execute('SAVEPOINT t1;')
> assert(err == nil)
> box.execute('RELEASE SAVEPOINT t1;')
>- local _,err = box.execute('RELEASE SAVEPOINT t1;')
>+ _, err = box.execute('RELEASE SAVEPOINT t1;')
> assert(err ~= nil)
>- local _, err = box.execute('ROLLBACK TO t2;')
>+ _, err = box.execute('ROLLBACK TO t2;')
> assert(err == nil)
> end;
> ---
>diff --git a/test/sql/savepoints.test.lua b/test/sql/savepoints.test.lua
>index f1b15c748..eb7bea37d 100644
>--- a/test/sql/savepoints.test.lua
>+++ b/test/sql/savepoints.test.lua
>@@ -65,12 +65,12 @@ collision_sv_2 = function()
> box.begin()
> box.execute('SAVEPOINT t1;')
> box.execute('SAVEPOINT t2;')
>- local _,err = box.execute('SAVEPOINT t1;')
>+ local _, err = box.execute('SAVEPOINT t1;')
> assert(err == nil)
> box.execute('RELEASE SAVEPOINT t1;')
>- local _,err = box.execute('RELEASE SAVEPOINT t1;')
>+ _, err = box.execute('RELEASE SAVEPOINT t1;')
> assert(err ~= nil)
>- local _, err = box.execute('ROLLBACK TO t2;')
>+ _, err = box.execute('ROLLBACK TO t2;')
> assert(err == nil)
> end;
> collision_sv_2();
>diff --git a/test/sql/triggers.result b/test/sql/triggers.result
>index ceecb8ef2..e70d72947 100644
>--- a/test/sql/triggers.result
>+++ b/test/sql/triggers.result
>@@ -11,7 +11,7 @@ _ = box.space._session_settings:update('sql_default_engine', {{'=', 2, engine}})
> ---
> ...
> -- Get invariant part of the tuple; name and opts don't change.
>- function immutable_part(data) local r = {} for i, l in pairs(data) do table.insert(r, {l.name, l.opts}) end return r end
>+ function immutable_part(data) local r = {} for _, l in pairs(data) do table.insert(r, {l.name, l.opts}) end return r end
> ---
> ...
> --
>diff --git a/test/sql/triggers.test.lua b/test/sql/triggers.test.lua
>index f5c8a3961..bc694ebc4 100644
>--- a/test/sql/triggers.test.lua
>+++ b/test/sql/triggers.test.lua
>@@ -4,7 +4,7 @@ engine = test_run:get_cfg('engine')
> _ = box.space._session_settings:update('sql_default_engine', {{'=', 2, engine}})
>
> -- Get invariant part of the tuple; name and opts don't change.
>- function immutable_part(data) local r = {} for i, l in pairs(data) do table.insert(r, {l.name, l.opts}) end return r end
>+ function immutable_part(data) local r = {} for _, l in pairs(data) do table.insert(r, {l.name, l.opts}) end return r end
>
> --
> -- gh-3273: Move Triggers to server
>diff --git a/test/vinyl/large.lua b/test/vinyl/large.lua
>index e10e94c1a..a11642ff0 100644
>--- a/test/vinyl/large.lua
>+++ b/test/vinyl/large.lua
>@@ -1,5 +1,5 @@
>-fiber = require('fiber')
>-digest = require('digest')
>+local fiber = require('fiber')
>+local digest = require('digest')
>
> local PAGE_SIZE = 1024
> local RANGE_SIZE = 64 * PAGE_SIZE
>diff --git a/test/vinyl/stat.result b/test/vinyl/stat.result
>index d35def13d..914c2ede4 100644
>--- a/test/vinyl/stat.result
>+++ b/test/vinyl/stat.result
>@@ -1792,13 +1792,15 @@ dump(1, 100) -- split + compaction
> wait_compaction(3)
> ---
> ...
>-i:stat().range_count -- 2
>+assert(i:stat().range_count, 2)
> ---
> - 2
>+- 2
> ...
>-i:stat().dumps_per_compaction -- 1
>+assert(i:stat().dumps_per_compaction, 1)
> ---
> - 1
>+- 1
> ...
> dump(1, 10)
> ---
>@@ -1809,9 +1811,10 @@ dump(1, 40) -- compaction in range 1
> wait_compaction(4)
> ---
> ...
>-i:stat().dumps_per_compaction -- 1
>+assert(i:stat().dumps_per_compaction, 1)
> ---
> - 1
>+- 1
> ...
> dump(90, 100)
> ---
>@@ -1822,9 +1825,10 @@ dump(60, 100) -- compaction in range 2
> wait_compaction(5)
> ---
> ...
>-i:stat().dumps_per_compaction -- 2
>+assert(i:stat().dumps_per_compaction, 2)
> ---
> - 2
>+- 2
> ...
> -- Forcing compaction manually doesn't affect dumps_per_compaction.
> dump(40, 60)
>@@ -1836,9 +1840,10 @@ i:compact()
> wait_compaction(7)
> ---
> ...
>-i:stat().dumps_per_compaction -- 2
>+assert(i:stat().dumps_per_compaction, 2)
> ---
> - 2
>+- 2
> ...
> test_run:cmd('restart server test')
> fiber = require('fiber')
>@@ -1853,9 +1858,10 @@ s = box.space.test
> i = s.index.primary
> ---
> ...
>-i:stat().dumps_per_compaction -- 2
>+assert(i:stat().dumps_per_compaction, 2)
> ---
> - 2
>+- 2
> ...
> for i = 1, 100 do s:replace{i, digest.urandom(100)} end
> ---
>@@ -1868,9 +1874,10 @@ test_run:wait_cond(function() return i:stat().disk.compaction.count == 2 end, 10
> ---
> - true
> ...
>-i:stat().dumps_per_compaction -- 1
>+assert(i:stat().dumps_per_compaction, 1)
> ---
> - 1
>+- 1
> ...
> s:drop()
> ---
>@@ -1892,9 +1899,10 @@ s:insert{1}
> ---
> - [1]
> ...
>-i:stat().txw.rows -- 1
>+assert(i:stat().txw.rows, 1)
> ---
> - 1
>+- 1
> ...
> sv = box.savepoint()
> ---
>@@ -1903,23 +1911,26 @@ s:insert{2}
> ---
> - [2]
> ...
>-i:stat().txw.rows -- 2
>+assert(i:stat().txw.rows, 2)
> ---
> - 2
>+- 2
> ...
> box.rollback_to_savepoint(sv)
> ---
> ...
>-i:stat().txw.rows -- 1
>+assert(i:stat().txw.rows, 1)
> ---
> - 1
>+- 1
> ...
> box.commit()
> ---
> ...
>-i:stat().txw.rows -- 0
>+assert(i:stat().txw.rows, 0)
> ---
> - 0
>+- 0
> ...
> s:drop()
> ---
>diff --git a/test/vinyl/stat.test.lua b/test/vinyl/stat.test.lua
>index a8657ccf4..7ff2d95f3 100644
>--- a/test/vinyl/stat.test.lua
>+++ b/test/vinyl/stat.test.lua
>@@ -555,24 +555,24 @@ i:stat().dumps_per_compaction -- 1
> dump(1, 100) -- compaction
> dump(1, 100) -- split + compaction
> wait_compaction(3)
>-i:stat().range_count -- 2
>-i:stat().dumps_per_compaction -- 1
>+assert(i:stat().range_count, 2)
>+assert(i:stat().dumps_per_compaction, 1)
>
> dump(1, 10)
> dump(1, 40) -- compaction in range 1
> wait_compaction(4)
>-i:stat().dumps_per_compaction -- 1
>+assert(i:stat().dumps_per_compaction, 1)
>
> dump(90, 100)
> dump(60, 100) -- compaction in range 2
> wait_compaction(5)
>-i:stat().dumps_per_compaction -- 2
>+assert(i:stat().dumps_per_compaction, 2)
>
> -- Forcing compaction manually doesn't affect dumps_per_compaction.
> dump(40, 60)
> i:compact()
> wait_compaction(7)
>-i:stat().dumps_per_compaction -- 2
>+assert(i:stat().dumps_per_compaction, 2)
>
> test_run:cmd('restart server test')
>
>@@ -582,12 +582,12 @@ digest = require('digest')
> s = box.space.test
> i = s.index.primary
>
>-i:stat().dumps_per_compaction -- 2
>+assert(i:stat().dumps_per_compaction, 2)
> for i = 1, 100 do s:replace{i, digest.urandom(100)} end
> box.snapshot()
> test_run:wait_cond(function() return i:stat().disk.compaction.count == 2 end, 10)
>
>-i:stat().dumps_per_compaction -- 1
>+assert(i:stat().dumps_per_compaction, 1)
>
> s:drop()
>
>@@ -599,14 +599,14 @@ s = box.schema.space.create('test', {engine = 'vinyl'})
> i = s:create_index('pk')
> box.begin()
> s:insert{1}
>-i:stat().txw.rows -- 1
>+assert(i:stat().txw.rows, 1)
> sv = box.savepoint()
> s:insert{2}
>-i:stat().txw.rows -- 2
>+assert(i:stat().txw.rows, 2)
> box.rollback_to_savepoint(sv)
>-i:stat().txw.rows -- 1
>+assert(i:stat().txw.rows, 1)
> box.commit()
>-i:stat().txw.rows -- 0
>+assert(i:stat().txw.rows, 0)
> s:drop()
>
> test_run:cmd('switch default')
>diff --git a/test/vinyl/txn_proxy.lua b/test/vinyl/txn_proxy.lua
>index 7a4d0b865..15b0e4add 100644
>--- a/test/vinyl/txn_proxy.lua
>+++ b/test/vinyl/txn_proxy.lua
>@@ -1,11 +1,11 @@
>--- A fiber can't use multiple transactions simultaneously;
>+-- A fiber can't use multiple transactions simultaneously;
> -- i.e. [fiber] --? [transaction] in UML parlor.
> --
> -- This module provides a simple transaction proxy facility
>--- to control multiple transactions at once. A proxy executes
>+-- to control multiple transactions at once. A proxy executes
> -- statements in a worker fiber in order to overcome
> -- "one transaction per fiber" limitation.
>---
>+--
> -- Ex:
> -- proxy = require('txn_proxy').new()
> -- proxy:begin()
>diff --git a/test/vinyl/vinyl.lua b/test/vinyl/vinyl.lua
>index 31307f4bc..02b5c010b 100644
>--- a/test/vinyl/vinyl.lua
>+++ b/test/vinyl/vinyl.lua
>@@ -15,7 +15,7 @@ box.cfg {
> vinyl_max_tuple_size = 1024 * 1024 * 6,
> }
>
>-function box_info_sort(data)
>+local function box_info_sort(data)
> if type(data)~='table' then
> return data
> end
>diff --git a/test/wal_off/rtree_benchmark.result b/test/wal_off/rtree_benchmark.result
>index 8e01c9f2a..8deefca82 100644
>--- a/test/wal_off/rtree_benchmark.result
>+++ b/test/wal_off/rtree_benchmark.result
>@@ -163,7 +163,7 @@ for i = 1, 0 do
> for j = 1, dimension do
> table.insert(rect, 180*math.random())
> end
>- for k,v in pairs(s.index.spatial:select(rect, {limit = n_neighbors, iterator = 'NEIGHBOR'})) do
>+ for _,_ in pairs(s.index.spatial:select(rect, {limit = n_neighbors, iterator = 'NEIGHBOR'})) do
> n = n + 1
> end
> end;
>diff --git a/test/wal_off/rtree_benchmark.test.lua b/test/wal_off/rtree_benchmark.test.lua
>index 6fae977c9..6bdc0a758 100644
>--- a/test/wal_off/rtree_benchmark.test.lua
>+++ b/test/wal_off/rtree_benchmark.test.lua
>@@ -96,7 +96,7 @@ for i = 1, 0 do
> for j = 1, dimension do
> table.insert(rect, 180*math.random())
> end
>- for k,v in pairs(s.index.spatial:select(rect, {limit = n_neighbors, iterator = 'NEIGHBOR'})) do
>+ for _,_ in pairs(s.index.spatial:select(rect, {limit = n_neighbors, iterator = 'NEIGHBOR'})) do
> n = n + 1
> end
> end;
>diff --git a/test/xlog-py/box.lua b/test/xlog-py/box.lua
>index c87f7b94b..8b9e9434f 100644
>--- a/test/xlog-py/box.lua
>+++ b/test/xlog-py/box.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/xlog/big_tx.result b/test/xlog/big_tx.result
>index 48085031b..837a4b478 100644
>--- a/test/xlog/big_tx.result
>+++ b/test/xlog/big_tx.result
>@@ -11,7 +11,7 @@ t = box.space.big_tx:insert({1, digest.urandom(512 * 1024)})
> ---
> ...
> env:cmd('restart server default')
>-#box.space.big_tx:select()
>+assert(#box.space.big_tx:select())
> ---
> - 1
> ...
>diff --git a/test/xlog/big_tx.test.lua b/test/xlog/big_tx.test.lua
>index b90a14a82..09624ed53 100644
>--- a/test/xlog/big_tx.test.lua
>+++ b/test/xlog/big_tx.test.lua
>@@ -5,7 +5,7 @@ _ = box.schema.space.create('big_tx'):create_index('pk')
> t = box.space.big_tx:insert({1, digest.urandom(512 * 1024)})
> env:cmd('restart server default')
>
>-#box.space.big_tx:select()
>+assert(#box.space.big_tx:select())
>
> box.space.big_tx:drop()
>
>diff --git a/test/xlog/checkpoint_daemon.result b/test/xlog/checkpoint_daemon.result
>index 5be7124fe..dc806ea1d 100644
>--- a/test/xlog/checkpoint_daemon.result
>+++ b/test/xlog/checkpoint_daemon.result
>@@ -118,11 +118,11 @@ wait_snapshot_gc(WAIT_COND_TIMEOUT)
> ---
> - true
> ...
>-#snaps == 2 or snaps
>+assert(#snaps == 2 or snaps)
> ---
> - true
> ...
>-#xlogs > 0
>+assert(#xlogs > 0)
> ---
> - true
> ...
>diff --git a/test/xlog/checkpoint_daemon.test.lua b/test/xlog/checkpoint_daemon.test.lua
>index d3138f356..0ef3d89da 100644
>--- a/test/xlog/checkpoint_daemon.test.lua
>+++ b/test/xlog/checkpoint_daemon.test.lua
>@@ -70,8 +70,8 @@ for i = 1, row_count_per_wal + 10 do space:insert { no } no = no + 1 end
> wait_snapshot(WAIT_COND_TIMEOUT)
> wait_snapshot_gc(WAIT_COND_TIMEOUT)
>
>-#snaps == 2 or snaps
>-#xlogs > 0
>+assert(#snaps == 2 or snaps)
>+assert(#xlogs > 0)
>
> -- gh-2780: check that a last snapshot mtime will be changed at
> -- least two times.
>diff --git a/test/xlog/panic.lua b/test/xlog/panic.lua
>index 2d4eb8d2e..0fa855421 100644
>--- a/test/xlog/panic.lua
>+++ b/test/xlog/panic.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/xlog/panic_on_wal_error.result b/test/xlog/panic_on_wal_error.result
>index 22f14f912..7bdd5119a 100644
>--- a/test/xlog/panic_on_wal_error.result
>+++ b/test/xlog/panic_on_wal_error.result
>@@ -19,7 +19,7 @@ _ = box.space.test:create_index('pk')
> -- reopen xlog
> --
> test_run:cmd("restart server default")
>-box.space.test ~= nil
>+assert(box.space.test ~= nil)
> ---
> - true
> ...
>diff --git a/test/xlog/panic_on_wal_error.test.lua b/test/xlog/panic_on_wal_error.test.lua
>index 2e95431c6..0a72bf44b 100644
>--- a/test/xlog/panic_on_wal_error.test.lua
>+++ b/test/xlog/panic_on_wal_error.test.lua
>@@ -10,7 +10,7 @@ _ = box.space.test:create_index('pk')
> -- reopen xlog
> --
> test_run:cmd("restart server default")
>-box.space.test ~= nil
>+assert(box.space.test ~= nil)
> -- insert some stuff
> --
> box.space.test:auto_increment{'before snapshot'}
>diff --git a/test/xlog/reader.result b/test/xlog/reader.result
>index 9985aa2ac..74ac3579e 100644
>--- a/test/xlog/reader.result
>+++ b/test/xlog/reader.result
>@@ -40,7 +40,7 @@ trun:cmd("setopt delimiter ';'")
> ...
> function collect_results(file)
> local val = {}
>- for k, v in xlog(file) do
>+ for _, v in xlog(file) do
> table.insert(val, setmetatable(v, { __serialize = "map"}))
> end
> return val
>diff --git a/test/xlog/reader.test.lua b/test/xlog/reader.test.lua
>index 327af54dd..707ba394b 100644
>--- a/test/xlog/reader.test.lua
>+++ b/test/xlog/reader.test.lua
>@@ -21,7 +21,7 @@ pattern_ok_v13 = fio.pathjoin(pattern_prefix, "v13/")
> trun:cmd("setopt delimiter ';'")
> function collect_results(file)
> local val = {}
>- for k, v in xlog(file) do
>+ for _, v in xlog(file) do
> table.insert(val, setmetatable(v, { __serialize = "map"}))
> end
> return val
>diff --git a/test/xlog/snap_io_rate.test.lua b/test/xlog/snap_io_rate.test.lua
>index f71296269..5626ea1f4 100644
>--- a/test/xlog/snap_io_rate.test.lua
>+++ b/test/xlog/snap_io_rate.test.lua
>@@ -9,6 +9,6 @@ for i = 0, 127 do box.space.snap:replace({i, digest.urandom(512 * 1024)}) end
> t1 = fiber.time()
> box.snapshot()
> t2 = fiber.time()
>-t2 - t1 > 64 / box.cfg.snap_io_rate_limit * 0.95
>+assert(t2 - t1 > 64 / box.cfg.snap_io_rate_limit * 0.95)
>
> box.space.snap:drop()
>diff --git a/test/xlog/transaction.result b/test/xlog/transaction.result
>index 63adb0f25..376fea486 100644
>--- a/test/xlog/transaction.result
>+++ b/test/xlog/transaction.result
>@@ -16,7 +16,7 @@ test_run:cmd("setopt delimiter ';'")
> ...
> function read_xlog(file)
> local val = {}
>- for k, v in xlog(file) do
>+ for _, v in xlog(file) do
> table.insert(val, setmetatable(v, { __serialize = "map"}))
> end
> return val
>@@ -69,37 +69,37 @@ data = read_xlog(fio.pathjoin(box.cfg.wal_dir, string.rep('0', 20 - #lsn_str) ..
> ---
> ...
> -- check nothing changed for single row transactions
>-data[1].HEADER.tsn == nil and data[1].HEADER.commit == nil
>+assert(data[1].HEADER.tsn == nil and data[1].HEADER.commit == nil)
> ---
> - true
> ...
>-data[2].HEADER.tsn == nil and data[2].HEADER.commit == nil
>+assert(data[2].HEADER.tsn == nil and data[2].HEADER.commit == nil)
> ---
> - true
> ...
> -- check two row transaction
>-data[3].HEADER.tsn == data[3].HEADER.lsn and data[3].HEADER.commit == nil
>+assert(data[3].HEADER.tsn == data[3].HEADER.lsn and data[3].HEADER.commit == nil)
> ---
> - true
> ...
>-data[4].HEADER.tsn == data[3].HEADER.tsn and data[4].HEADER.commit == true
>+assert(data[4].HEADER.tsn == data[3].HEADER.tsn and data[4].HEADER.commit == true)
> ---
> - true
> ...
> -- check four row transaction
>-data[5].HEADER.tsn == data[5].HEADER.lsn and data[5].HEADER.commit == nil
>+assert(data[5].HEADER.tsn == data[5].HEADER.lsn and data[5].HEADER.commit == nil)
> ---
> - true
> ...
>-data[6].HEADER.tsn == data[5].HEADER.tsn and data[6].HEADER.commit == nil
>+assert(data[6].HEADER.tsn == data[5].HEADER.tsn and data[6].HEADER.commit == nil)
> ---
> - true
> ...
>-data[7].HEADER.tsn == data[5].HEADER.tsn and data[7].HEADER.commit == nil
>+assert(data[7].HEADER.tsn == data[5].HEADER.tsn and data[7].HEADER.commit == nil)
> ---
> - true
> ...
>-data[8].HEADER.tsn == data[5].HEADER.tsn and data[8].HEADER.commit == true
>+assert(data[8].HEADER.tsn == data[5].HEADER.tsn and data[8].HEADER.commit == true)
> ---
> - true
> ...
>diff --git a/test/xlog/transaction.test.lua b/test/xlog/transaction.test.lua
>index 2d8090b4c..c196064ef 100644
>--- a/test/xlog/transaction.test.lua
>+++ b/test/xlog/transaction.test.lua
>@@ -6,7 +6,7 @@ test_run = env.new()
> test_run:cmd("setopt delimiter ';'")
> function read_xlog(file)
> local val = {}
>- for k, v in xlog(file) do
>+ for _, v in xlog(file) do
> table.insert(val, setmetatable(v, { __serialize = "map"}))
> end
> return val
>@@ -33,14 +33,14 @@ box.snapshot()
> lsn_str = tostring(lsn)
> data = read_xlog(fio.pathjoin(box.cfg.wal_dir, string.rep('0', 20 - #lsn_str) .. tostring(lsn_str) .. '.xlog'))
> -- check nothing changed for single row transactions
>-data[1].HEADER.tsn == nil and data[1].HEADER.commit == nil
>-data[2].HEADER.tsn == nil and data[2].HEADER.commit == nil
>+assert(data[1].HEADER.tsn == nil and data[1].HEADER.commit == nil)
>+assert(data[2].HEADER.tsn == nil and data[2].HEADER.commit == nil)
> -- check two row transaction
>-data[3].HEADER.tsn == data[3].HEADER.lsn and data[3].HEADER.commit == nil
>-data[4].HEADER.tsn == data[3].HEADER.tsn and data[4].HEADER.commit == true
>+assert(data[3].HEADER.tsn == data[3].HEADER.lsn and data[3].HEADER.commit == nil)
>+assert(data[4].HEADER.tsn == data[3].HEADER.tsn and data[4].HEADER.commit == true)
> -- check four row transaction
>-data[5].HEADER.tsn == data[5].HEADER.lsn and data[5].HEADER.commit == nil
>-data[6].HEADER.tsn == data[5].HEADER.tsn and data[6].HEADER.commit == nil
>-data[7].HEADER.tsn == data[5].HEADER.tsn and data[7].HEADER.commit == nil
>-data[8].HEADER.tsn == data[5].HEADER.tsn and data[8].HEADER.commit == true
>+assert(data[5].HEADER.tsn == data[5].HEADER.lsn and data[5].HEADER.commit == nil)
>+assert(data[6].HEADER.tsn == data[5].HEADER.tsn and data[6].HEADER.commit == nil)
>+assert(data[7].HEADER.tsn == data[5].HEADER.tsn and data[7].HEADER.commit == nil)
>+assert(data[8].HEADER.tsn == data[5].HEADER.tsn and data[8].HEADER.commit == true)
> box.space.test:drop()
>diff --git a/test/xlog/xlog.lua b/test/xlog/xlog.lua
>index 004096d2d..aaf1a0ae6 100644
>--- a/test/xlog/xlog.lua
>+++ b/test/xlog/xlog.lua
>@@ -1,5 +1,5 @@
> #!/usr/bin/env tarantool
>-os = require('os')
>+local os = require('os')
>
> box.cfg{
> listen = os.getenv("LISTEN"),
>--
>2.23.0
>
--
Alexander Tikhonov
[-- Attachment #2: Type: text/html, Size: 59016 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 1/6] Fix luacheck warnings in src/lua/
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
2020-04-11 16:54 ` Vladislav Shpilevoy
1 sibling, 0 replies; 27+ messages in thread
From: Alexander Tikhonov @ 2020-04-09 4:31 UTC (permalink / raw)
To: Sergey Bronnikov; +Cc: o.piskunov, tarantool-patches
[-- 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 --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 4/6] Fix luacheck warnings in extra/dist/tarantoolctl.in
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
2 siblings, 1 reply; 27+ messages in thread
From: Oleg Babin @ 2020-04-09 7:30 UTC (permalink / raw)
To: Sergey Bronnikov, tarantool-patches; +Cc: o.piskunov
Hi! Thanks for your patch! See my comment below.
On 08/04/2020 18:43, Sergey Bronnikov wrote:
> From: Sergey Bronnikov <sergeyb@tarantool.org>
>
> @@ -420,7 +419,7 @@ local cat_formats = setmetatable({
> json = cat_json_cb,
> lua = cat_lua_cb,
> }, {
> - __index = function(self, cmd)
> + __index = function(cmd)
> error(("Unknown formatter '%s'"):format(cmd))
> end
> })
You can't simply drop "self" argument. See [1]. I assume that a change
that doesn't break behaviour is "function(_, cmd)".
[1] https://www.lua.org/pil/13.4.1.html
---
Oleg Babin
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 4/6] Fix luacheck warnings in extra/dist/tarantoolctl.in
2020-04-09 7:30 ` Oleg Babin
@ 2020-04-10 14:05 ` Sergey Bronnikov
0 siblings, 0 replies; 27+ messages in thread
From: Sergey Bronnikov @ 2020-04-10 14:05 UTC (permalink / raw)
To: Oleg Babin; +Cc: o.piskunov, Sergey Bronnikov, tarantool-patches
Oleg, thanks. Updated in the branch.
On 10:30 Thu 09 Apr , Oleg Babin wrote:
> Hi! Thanks for your patch! See my comment below.
>
> On 08/04/2020 18:43, Sergey Bronnikov wrote:
> > From: Sergey Bronnikov <sergeyb@tarantool.org>
> >
> > @@ -420,7 +419,7 @@ local cat_formats = setmetatable({
> > json = cat_json_cb,
> > lua = cat_lua_cb,
> > }, {
> > - __index = function(self, cmd)
> > + __index = function(cmd)
> > error(("Unknown formatter '%s'"):format(cmd))
> > end
> > })
>
> You can't simply drop "self" argument. See [1]. I assume that a change that
> doesn't break behaviour is "function(_, cmd)".
>
>
> [1] https://www.lua.org/pil/13.4.1.html
>
> ---
> Oleg Babin
--
sergeyb@
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 6/6] gitlab-ci: enable static analysis with luacheck
2020-04-09 4:20 ` Alexander Tikhonov
@ 2020-04-10 14:53 ` Sergey Bronnikov
2020-04-22 8:45 ` Alexander Tikhonov
0 siblings, 1 reply; 27+ messages in thread
From: Sergey Bronnikov @ 2020-04-10 14:53 UTC (permalink / raw)
To: Alexander Tikhonov; +Cc: o.piskunov, Sergey Bronnikov, tarantool-patches
Hello,
thanks for review. Please see my answers inline.
On 07:20 Thu 09 Apr , Alexander Tikhonov wrote:
>
> Hi Sergey, thank you for the patch, please check my comments below.
>
>
> >Среда, 8 апреля 2020, 18:43 +03:00 от Sergey Bronnikov <estetus@gmail.com>:
> >
> >From: Sergey Bronnikov < sergeyb@tarantool.org >
> >
> >Closes #4681
> >---
> Please add in the review letter the link to the branch here, also the issue link.
Will do next time.
> > .gitlab-ci.yml | 9 +++++++++
> > .travis.mk | 12 +++++++++++-
> > 2 files changed, 20 insertions(+), 1 deletion(-)
> >
> >diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> >index cd710027f..adbd892c8 100644
> >--- a/.gitlab-ci.yml
> >+++ b/.gitlab-ci.yml
> >@@ -1,4 +1,5 @@
> > stages:
> >+ - static_analysis
> Do we really need the separate stage for this job ? As we agreed with
> A. Turenko before, we create stages only for jobs that needs additional
> steps w/o next steps wont work and which can be used in the next stage
> for more than single job.
I think the answer is "yes". The arguments are:
- it is a best practice in industry to split CI/CD pipeline for several
stages. In canonical example they are: build, test, deploy.
- build, static analysis, unit testing, module testing are successive
steps in finding bugs. Each step requires different amount of efforts to
debug in case of failure. No reasons to perform unit testing when compiler
warns about non-initialized variables and no reasons to perform complex
functional testing when unit tests failed.
We have future plans to add clang-analyzer and more strict warnings in
compilers and 'static_analysis' stage will be a good place for these
tasks on pipeline.
> Anyway separate stage will add depends for the rest of the jobs, which
> can be blocked because of any issue with luacheck, like it can be
> luacheck cloning either its depends installations:
<snipped>
> >index f709a18b6..32222621b 100644
> >--- a/.travis.mk
> >+++ b/.travis.mk
> >@@ -77,8 +77,9 @@ deps_buster_clang_8: deps_debian
> > # Release
> >
> > build_debian:
> >- cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_WERROR=ON ${CMAKE_EXTRA_PARAMS}
> >+ cmake . -DENABLE_DIST=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_WERROR=ON ${CMAKE_EXTRA_PARAMS}
> This target is common wide along all the jobs and if ENABLE_DIST
> define is not adding changes for them may be just need add the comment
> the purpose on its adding.
Well, I'll describe this in a commit message.
> > make -j
> >+ sudo make install
> This target is common wide along all the jobs and may be it better to
> move the installation to the target ‘luacheck’ which only needs it.
Well, I'll move 'make install' to a separate target.
<snipped>
S.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 2/6] Fix luacheck warnings in test/
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
2 siblings, 1 reply; 27+ messages in thread
From: Vladislav Shpilevoy @ 2020-04-11 16:54 UTC (permalink / raw)
To: Sergey Bronnikov, tarantool-patches; +Cc: o.piskunov
Hi! Thanks for the patch!
> diff --git a/test/box/iproto_stress.result b/test/box/iproto_stress.result
> index 7149d6c52..3b5b0a031 100644
> --- a/test/box/iproto_stress.result
> +++ b/test/box/iproto_stress.result
> @@ -76,13 +76,13 @@ test_run:wait_cond(function() return n_workers == 0 end, 60)
> ---
> - true
> ...
> -n_workers -- 0
> +assert(n_workers == 0)
These changes should not be done, IMO. Most of our
tests are diff based, and therefore it is ok to write
a statement just to print it. It is not only simpler, but
also allows to print the actual value, if it didn't match
the expected value.
For example, if n_workers becomes not 0, we would see its
actual value in the diff. When we use assert(), we won't
see anything except an error message 'assertion failed'.
I propose to allow writing non-functional statements in
test/ dir.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 2/6] Fix luacheck warnings in test/
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-11 16:54 ` Vladislav Shpilevoy
2 siblings, 0 replies; 27+ messages in thread
From: Vladislav Shpilevoy @ 2020-04-11 16:54 UTC (permalink / raw)
To: Sergey Bronnikov, tarantool-patches; +Cc: o.piskunov
Thanks for the patch!
Consider one minor fix below and on the branch in a separate
commit.
====================
diff --git a/test/vinyl/large.lua b/test/vinyl/large.lua
index a11642ff0..a997aec7e 100644
--- a/test/vinyl/large.lua
+++ b/test/vinyl/large.lua
@@ -1,4 +1,3 @@
-local fiber = require('fiber')
local digest = require('digest')
local PAGE_SIZE = 1024
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 1/6] Fix luacheck warnings in src/lua/
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
@ 2020-04-11 16:54 ` Vladislav Shpilevoy
1 sibling, 0 replies; 27+ messages in thread
From: Vladislav Shpilevoy @ 2020-04-11 16:54 UTC (permalink / raw)
To: Sergey Bronnikov, tarantool-patches; +Cc: o.piskunov
Thanks for the patch!
> 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
> @@ -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.
luacheck reported shadowing of 's' in the cycle below, so it is
enough to fix the cycle.
I fixed that in a separate commit. Squash it if you agree.
> -- @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
See diff below and in a separate commit on the branch.
====================
diff --git a/src/lua/swim.lua b/src/lua/swim.lua
index 466e77ce4..8e3b0ab13 100644
--- a/src/lua/swim.lua
+++ b/src/lua/swim.lua
@@ -782,20 +782,20 @@ local swim_member_event_mt = {
--
-- Create a closure function for preprocessing raw SWIM member
-- event trigger parameters.
--- @param instance SWIM instance.
+-- @param s 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(instance, callback, ctx)
+local function swim_on_member_event_new(s, 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.
- instance = setmetatable({instance}, {__mode = 'v'})
+ s = setmetatable({s}, {__mode = 'v'})
return function(member_ptr, event_mask)
- local i = instance[1]
- if i then
- local m = swim_wrap_member(i, member_ptr)
+ local si = s[1]
+ if si then
+ local m = swim_wrap_member(si, 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 04497386e..094eb883f 100644
--- a/src/lua/tap.lua
+++ b/src/lua/tap.lua
@@ -53,7 +53,6 @@ local function ok(test, cond, message, extra)
io.write(string.format("not ok - %s\n", message))
extra = extra or {}
if test.trace then
- debug.getinfo(3, "Sl")
extra.trace = traceback()
extra.filename = extra.trace[#extra.trace].filename
extra.line = extra.trace[#extra.trace].line
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 5/6] Add luacheck config
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
1 sibling, 1 reply; 27+ messages in thread
From: Vladislav Shpilevoy @ 2020-04-11 16:54 UTC (permalink / raw)
To: Sergey Bronnikov, tarantool-patches; +Cc: o.piskunov
Thanks for the patch!
See 5 comments below.
On 08/04/2020 17:43, Sergey Bronnikov wrote:
> From: Sergey Bronnikov <sergeyb@tarantool.org>
>
> From the beginning we haven't use static analysis for Lua source code and
> therefore now we have about 32k warnings and errors produced by luacheck. Sure
> these issues are not real bugs but fixing them will make source code better and
> clear. Aim to fix all of them at once looks insane and perhaps it is not worth
> it.
>
> Summary of static analysis:
>
> There were no errors found by luacheck in production source code (src/),
> many warnings were fixed in previous commits and non-interested warnings were
> supressed using luacheck config.
>
> Lua source code in test/ directory contains both errors and warnings and there
> are a lot of them. Some of these warnings were fixed by previous commits and
> most part of warnings and errors supressed in luacheck config. Regarding
> errors: all found errors belongs to a single error class - "Syntax error"
> (E011). All of them have a single root cause - at the of testscases we write
> conditions without assignments and it is confuses luacheck. Usually such
> conditions used together with asserts, but in our tests we uses reference outputs
> instead of asserts.
1. So you disabled that warning for tests, right? Then why still many
statements in the test/ dir are replaced with assertions in one of the
previous commits?
> How-to check:
>
> $ tarantoolctl rocks install luacheck
> $ .rocks/bin/luacheck --codes --config .luacheckrc .
>
> Closes #4681
> ---
> .luacheckrc | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 162 insertions(+)
> create mode 100644 .luacheckrc
>
> diff --git a/.luacheckrc b/.luacheckrc
> new file mode 100644
> index 000000000..2550f9f1a
> --- /dev/null
> +++ b/.luacheckrc
> @@ -0,0 +1,162 @@
> +include_files = {
> + "**/*.lua",
> + "extra/dist/tarantoolctl.in",
> +}
> +
> +exclude_files = {
> + "third_party/**/*.lua",
> + "test-run/**/*.lua",
> + "test/wal_off/*.lua", -- E011
> + "test/xlog/*.lua", -- E011
> + "test/vinyl/*.lua", -- E011
> + "test/sql/*.lua", -- E011
> + "test/replication/*.lua", -- E011
> + "test/engine/*.lua", -- E011
> + "test/swim/*.lua", -- E011
> + "test/box/*.lua", -- E011
> + "test/app/*.lua", -- E011
> + "test/app-tap/*.lua", -- E011
2. In tap tests there is no print of every line's statement.
So if there is a warning about an unused statement in a tap
test, it should be ok to remove/fix it.
> + "test/app-tap/lua/serializer_test.lua", -- E011
> + "build/**/*.lua",
> + ".rocks/**/*.lua",
> + ".git/**/*.lua",
> +}
3. Please, add test/var too. When tests are run, they leave lots
of lua files in there, which are copied from ignored folders, but
they become not ignored in test/var.
> +
> +files["**/*.lua"] = {ignore = {"212", "122"}}
4. Shouldn't that disable 212 and 122 for all lua files? If so,
then why still 122 is mentioned in the lists below? (Not counting
tarantoolctl.in, it does not have .lua suffix).
> +files["extra/dist/tarantoolctl.in"] = {ignore = {"431", "411", "122", "542"}}
> +files["src/lua/help.lua"] = {globals = {"help", "tutorial"}, ignore = {"113", "211"}}
> +files["src/lua/swim.lua"] = {ignore = {"431"}}
> +files["src/lua/fio.lua"] = {ignore = {"231"}}
> +files["src/lua/init.lua"] = {ignore = {"122", "121"}}
> +files["src/lua/fiber.lua"] = {ignore = {"331", "311"}}
> +files["src/box/lua/serpent.lua"] = {globals = {"_ENV"}, ignore = {"431", "421", "631", "432", "542", "412", "422"}}
> +files["src/box/lua/load_cfg.lua"] = {ignore = {"431", "143", "311", "542"}}
> +files["src/box/lua/net_box.lua"] = {ignore = {"431", "211", "421", "432", "311", "231", "411", "412"}}
> +files["src/box/lua/schema.lua"] = {globals = {"update_format", "iid", "role_check_grant_revoke_of_sys_priv"}, ignore = {"431", "122", "211", "421", "213", "432", "311", "542", "412"}}
> +files["src/box/lua/key_def.lua"] = {ignore = {"431"}}
> +files["src/box/lua/feedback_daemon.lua"] = {ignore = {"122", "211"}}
> +files["src/box/lua/tuple.lua"] = {ignore = {"122", "211", "421", "412"}}
> +files["src/box/lua/upgrade.lua"] = {ignore = {"122", "211", "421", "213"}}
> +files["src/box/lua/console.lua"] = {globals = {"help"}, ignore = {"211", "143"}}
> +files["test/**/*.lua"] = {ignore = {"631", "611", "614", "613", "612", "621", "112", "211", "432"}}
> +files["test/app/*.lua"] = {ignore = {"111", "113"}}
> +files["test/app/lua/fiber.lua"] = {ignore = {"111"}}
> +files["test/app-tap/*.lua"] = {ignore = {"111", "113"}}
> +files["test/app-tap/tarantoolctl.test.lua"] = {ignore = {"511"}}
> +files["test/app-tap/lua/require_mod.lua"] = {ignore = {"113", "111"}}
> +files["test/box/admin.test.lua"] = {ignore = {"213"}}
> +files["test/box/lua/*.lua"] = {ignore = {"111"}}
> +files["test/box/*.lua"] = {ignore = {"111", "113"}}
> +files["test/box/lua/utils.lua"] = {ignore = {"421", "113", "213", "412"}}
> +files["test/box/lua/bitset.lua"] = {ignore = {"113", "213"}}
> +files["test/box/lua/fifo.lua"] = {ignore = {"113", "213"}}
> +files["test/box/lua/identifier.lua"] = {ignore = {"113"}}
> +files["test/box/lua/require_mod.lua"] = {ignore = {"113"}}
> +files["test/box/lua/require_init.lua"] = {ignore = {"412", "143"}}
> +files["test/box/lua/test_init.lua"] = {ignore = {"113", "412", "143"}}
> +files["test/box/lua/index_random_test.lua"] = {ignore = {"213"}}
> +files["test/box-tap/*.lua"] = {ignore = {"111"}}
> +files["test/box-tap/auth.test.lua"] = {ignore = {"311", "411", "113"}}
> +files["test/box-tap/cfg.test.lua"] = {ignore = {"311", "411", "113"}}
> +files["test/box-tap/cfgup.test.lua"] = {ignore = {"113"}}
> +files["test/box-tap/feedback_daemon.test.lua"] = {ignore = {"411"}}
> +files["test/box-tap/gc.test.lua"] = {ignore = {"421"}}
> +files["test/box-tap/on_schema_init.test.lua"] = {ignore = {"113"}}
> +files["test/box-tap/schema_mt.test.lua"] = {ignore = {"113", "122"}}
> +files["test/box-tap/key_def.test.lua"] = {ignore = {"411", "431"}}
> +files["test/box-tap/merger.test.lua"] = {ignore = {"411", "431", "412", "213"}}
> +files["test/box-tap/session.storage.test.lua"] = {ignore = {"113"}}
> +files["test/box-tap/session.test.lua"] = {ignore = {"411", "113", "412", "143"}}
> +files["test/box-tap/trigger_atexit.test.lua"] = {ignore = {"113"}}
> +files["test/box-tap/trigger_yield.test.lua"] = {ignore = {"213", "113"}}
> +files["test/luajit-tap/fix_string_find_recording.test.lua"] = {ignore = {"111", "113", "231"}}
> +files["test/luajit-tap/gh-4476-fix-string-find-recording.test.lua"] = {ignore = {"231"}}
> +files["test/luajit-tap/fold_bug_LuaJIT_505.test.lua"] = {ignore = {"111", "113"}}
> +files["test/luajit-tap/gh.test.lua"] = {ignore = {"111", "113"}}
> +files["test/luajit-tap/table_chain_bug_LuaJIT_494.test.lua"] = {ignore = {"111", "113"}}
> +files["test/luajit-tap/unsink_64_kptr.test.lua"] = {ignore = {"111", "113", "551", "542"}}
> +files["test/luajit-tap/or-232-unsink-64-kptr.test.lua"] = {ignore = {"542"}}
> +files["test/luajit-tap/lj-494-table-chain-infinite-loop.test.lua"] = {ignore = {"111", "113", "213"}}
> +files["test/engine/*.lua"] = {ignore = {"111", "113"}}
> +files["test/engine_long/suite.lua"] = {ignore = {"421", "111", "213"}}
> +files["test/engine_long/delete_replace_update.test.lua"] = {ignore = {"113", "111"}}
> +files["test/engine_long/delete_insert.test.lua"] = {ignore = {"113", "111"}}
> +files["test/long_run-py/suite.lua"] = {ignore = {"421", "111", "113", "213"}}
> +files["test/long_run-py/lua/finalizers.lua"] = {ignore = {"241", "511", "111", "113"}}
> +files["test/replication/*.lua"] = {ignore = {"113", "111"}}
> +files["test/replication/lua/fast_replica.lua"] = {ignore = {"113", "213"}}
> +files["test/replication/lua/rlimit.lua"] = {ignore = {"113"}}
> +files["test/replication-py/replica.lua"] = {ignore = {"111"}}
> +files["test/replication/lua/fast_replica.lua"] = {ignore = {"113", "111", "213"}}
> +files["test/replication/lua/rlimit.lua"] = {ignore = {"113", "111"}}
> +files["test/sql/*.lua"] = {ignore = {"113", "111"}}
> +files["test/sql/triggers.test.lua"] = {ignore = {"631", "113", "111"}}
> +files["test/sql/tokenizer.test.lua"] = {ignore = {"113", "111"}}
> +files["test/sql/transitive-transactions.test.lua"] = {ignore = {"113", "111"}}
> +files["test/sql/savepoints.test.lua"] = {ignore = {"113", "111"}}
> +files["test/sql/persistency.test.lua"] = {ignore = {"113", "111"}}
5. I see that you added some folders to 'exclude_files'. Why is it still
needed to add files from these folders here?
> +files["test/sql-tap/*.lua"] = {ignore = {"113", "111"}}
> +files["test/sql-tap/lua_sql.test.lua"] = {ignore = {"412"}}
> +files["test/sql-tap/subquery.test.lua"] = {ignore = {"412", "143"}}
> +files["test/sql-tap/alias.test.lua"] = {ignore = {"412", "143"}}
> +files["test/sql-tap/analyze9.test.lua"] = {ignore = {"213", "411"}}
> +files["test/sql-tap/between.test.lua"] = {ignore = {"421", "213"}}
> +files["test/sql-tap/check.test.lua"] = {ignore = {"412", "143"}}
> +files["test/sql-tap/date.test.lua"] = {ignore = {"511"}}
> +files["test/sql-tap/e_expr.test.lua"] = {ignore = {"512", "431", "213", "411"}}
> +files["test/sql-tap/func.test.lua"] = {ignore = {"412", "143"}}
> +files["test/sql-tap/func5.test.lua"] = {ignore = {"412", "143"}}
> +files["test/sql-tap/misc1.test.lua"] = {ignore = {"411"}}
> +files["test/sql-tap/select1.test.lua"] = {ignore = {"511", "213"}}
> +files["test/sql-tap/select2.test.lua"] = {ignore = {"421"}}
> +files["test/sql-tap/select4.test.lua"] = {ignore = {"421"}}
> +files["test/sql-tap/select5.test.lua"] = {ignore = {"421"}}
> +files["test/sql-tap/selectA.test.lua"] = {ignore = {"542"}}
> +files["test/sql-tap/selectB.test.lua"] = {ignore = {"213", "542"}}
> +files["test/sql-tap/selectG.test.lua"] = {ignore = {"421"}}
> +files["test/sql-tap/table.test.lua"] = {ignore = {"511"}}
> +files["test/sql-tap/tkt-bd484a090c.test.lua"] = {ignore = {"511"}}
> +files["test/sql-tap/tkt-38cb5df375.test.lua"] = {ignore = {"421"}}
> +files["test/sql-tap/tkt-91e2e8ba6f.test.lua"] = {ignore = {"542"}}
> +files["test/sql-tap/tkt-9a8b09f8e6.test.lua"] = {ignore = {"542"}}
> +files["test/sql-tap/tkt2192.test.lua"] = {ignore = {"511"}}
> +files["test/sql-tap/tkt3493.test.lua"] = {ignore = {"542"}}
> +files["test/sql-tap/triggerA.test.lua"] = {ignore = {"311"}}
> +files["test/sql-tap/trigger2.test.lua"] = {ignore = {"213"}}
> +files["test/sql-tap/trigger9.test.lua"] = {ignore = {"143", "412"}}
> +files["test/sql-tap/update.test.lua"] = {ignore = {"611"}}
> +files["test/sql-tap/whereB.test.lua"] = {ignore = {"611"}}
> +files["test/sql-tap/with1.test.lua"] = {ignore = {"542"}}
> +files["test/sql-tap/with2.test.lua"] = {ignore = {"213", "412"}}
> +files["test/sql-tap/lua_sql.test.lua"] = {ignore = {"143"}}
> +files["test/sql-tap/lua/sqltester.lua"] = {ignore = {"111", "113", "431", "213"}}
> +files["test/sql-tap/gh-2723-concurrency.test.lua"] = {ignore = {"213"}}
> +files["test/sql-tap/gh-3307-xfer-optimization-issue.test.lua"] = {ignore = {"412", "213"}}
> +files["test/sql-tap/gh-3083-ephemeral-unref-tuples.test.lua"] = {ignore = {"213"}}
> +files["test/sql-tap/gh-3332-tuple-format-leak.test.lua"] = {ignore = {"213"}}
> +files["test/sql-tap/gh2127-indentifier-max-length.test.lua"] = {ignore = {"213"}}
> +files["test/sql-tap/misc5.test.lua"] = {ignore = {"213"}}
> +files["test/wal_off/rtree_benchmark.test.lua"] = {ignore = {"213", "113", "111"}}
> +files["test/wal_off/func_max.test.lua"] = {ignore = {"511", "113", "111"}}
> +files["test/vinyl/upgrade/fill.lua"] = {ignore = {"111", "113"}}
> +files["test/vinyl/write_iterator_rand.test.lua"] = {ignore = {"113", "111"}}
> +files["test/vinyl/savepoint.test.lua"] = {ignore = {"113", "111"}}
> +files["test/vinyl/replica_quota.test.lua"] = {ignore = {"113", "111", "213"}}
> +files["test/vinyl/stress.test.lua"] = {ignore = {"431", "213"}}
> +files["test/vinyl/hermitage.test.lua"] = {ignore = {"113", "111"}}
> +files["test/vinyl/dump_stress.test.lua"] = {ignore = {"113", "111"}}
> +files["test/vinyl/constraint.test.lua"] = {ignore = {"113", "111"}}
> +files["test/vinyl/large.test.lua"] = {ignore = {"113", "111"}}
> +files["test/vinyl/options.test.lua"] = {ignore = {"113", "111"}}
> +files["test/xlog/upgrade/2.1.3/gh-4771-upgrade-sequence/fill.lua"] = {ignore = {"111", "113"}}
> +files["test/xlog/transaction.test.lua"] = {ignore = {"113", "111"}}
> +files["test/xlog/snap_io_rate.test.lua"] = {ignore = {"113", "111"}}
> +files["test/xlog/reader.test.lua"] = {ignore = {"113", "111"}}
> +files["test/xlog/panic_on_broken_lsn.test.lua"] = {ignore = {"113", "111"}}
> +files["test/xlog/gh1433.test.lua"] = {ignore = {"113", "111"}}
> +files["test/xlog/header.test.lua"] = {ignore = {"113", "111"}}
> +files["test/xlog/errinj.test.lua"] = {ignore = {"113", "111"}}
> +files["test/xlog/force_recovery.test.lua"] = {ignore = {"113", "111"}}
> +files["test/xlog/big_tx.test.lua"] = {ignore = {"113", "111"}}
> +files["test/xlog/checkpoint_threshold.test.lua"] = {ignore = {"113", "111", "213"}}
> +files["test/swim/box.lua"] = {ignore = {"113", "111"}}
>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 5/6] Add luacheck config
2020-04-11 16:54 ` Vladislav Shpilevoy
@ 2020-04-13 15:16 ` Sergey Bronnikov
2020-04-14 23:29 ` Vladislav Shpilevoy
0 siblings, 1 reply; 27+ messages in thread
From: Sergey Bronnikov @ 2020-04-13 15:16 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: o.piskunov, Sergey Bronnikov, tarantool-patches
Vlad, thanks for review. See comments inline.
On 18:54 Sat 11 Apr , Vladislav Shpilevoy wrote:
> Thanks for the patch!
>
> See 5 comments below.
>
> On 08/04/2020 17:43, Sergey Bronnikov wrote:
> > From: Sergey Bronnikov <sergeyb@tarantool.org>
> >
> > From the beginning we haven't use static analysis for Lua source code and
> > therefore now we have about 32k warnings and errors produced by luacheck. Sure
> > these issues are not real bugs but fixing them will make source code better and
> > clear. Aim to fix all of them at once looks insane and perhaps it is not worth
> > it.
> >
> > Summary of static analysis:
> >
> > There were no errors found by luacheck in production source code (src/),
> > many warnings were fixed in previous commits and non-interested warnings were
> > supressed using luacheck config.
> >
> > Lua source code in test/ directory contains both errors and warnings and there
> > are a lot of them. Some of these warnings were fixed by previous commits and
> > most part of warnings and errors supressed in luacheck config. Regarding
> > errors: all found errors belongs to a single error class - "Syntax error"
> > (E011). All of them have a single root cause - at the of testscases we write
> > conditions without assignments and it is confuses luacheck. Usually such
> > conditions used together with asserts, but in our tests we uses reference outputs
> > instead of asserts.
>
> 1. So you disabled that warning for tests, right? Then why still many
> statements in the test/ dir are replaced with assertions in one of the
> previous commits?
My original goal was following: fix dangerous warnings and supress other
of them per file. I followed this strategy and then discovered that E011
cannot be supressed. In case of errors you should fix them or disable
checking at all for highlighted files/directories. So this is a reason
why some exclusions contains single file and some of them contains file
mask. I decided to keep it as is because more specific supressions are
more convenient to fix when.
> > How-to check:
> >
> > $ tarantoolctl rocks install luacheck
> > $ .rocks/bin/luacheck --codes --config .luacheckrc .
> >
> > Closes #4681
> > ---
> > .luacheckrc | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 162 insertions(+)
> > create mode 100644 .luacheckrc
> >
> > diff --git a/.luacheckrc b/.luacheckrc
> > new file mode 100644
> > index 000000000..2550f9f1a
> > --- /dev/null
> > +++ b/.luacheckrc
> > @@ -0,0 +1,162 @@
> > +include_files = {
> > + "**/*.lua",
> > + "extra/dist/tarantoolctl.in",
> > +}
> > +
> > +exclude_files = {
> > + "third_party/**/*.lua",
> > + "test-run/**/*.lua",
> > + "test/wal_off/*.lua", -- E011
> > + "test/xlog/*.lua", -- E011
> > + "test/vinyl/*.lua", -- E011
> > + "test/sql/*.lua", -- E011
> > + "test/replication/*.lua", -- E011
> > + "test/engine/*.lua", -- E011
> > + "test/swim/*.lua", -- E011
> > + "test/box/*.lua", -- E011
> > + "test/app/*.lua", -- E011
> > + "test/app-tap/*.lua", -- E011
>
> 2. In tap tests there is no print of every line's statement.
> So if there is a warning about an unused statement in a tap
> test, it should be ok to remove/fix it.
Enabled app-tap directory back and keep only test/app-tap/lua/serializer_test.lua
due to error E011: test/app-tap/lua/serializer_test.lua:254:18: (E011) expected expression near 'М'
No idea how to fix it.
> > + "test/app-tap/lua/serializer_test.lua", -- E011
> > + "build/**/*.lua",
> > + ".rocks/**/*.lua",
> > + ".git/**/*.lua",
> > +}
>
> 3. Please, add test/var too. When tests are run, they leave lots
> of lua files in there, which are copied from ignored folders, but
> they become not ignored in test/var.
Added.
> > +
> > +files["**/*.lua"] = {ignore = {"212", "122"}}
>
> 4. Shouldn't that disable 212 and 122 for all lua files? If so,
> then why still 122 is mentioned in the lists below? (Not counting
> tarantoolctl.in, it does not have .lua suffix).
Removed these warnings from warning sets per file.
> > +files["extra/dist/tarantoolctl.in"] = {ignore = {"431", "411", "122", "542"}}
> > +files["src/lua/help.lua"] = {globals = {"help", "tutorial"}, ignore = {"113", "211"}}
> > +files["src/lua/swim.lua"] = {ignore = {"431"}}
> > +files["src/lua/fio.lua"] = {ignore = {"231"}}
> > +files["src/lua/init.lua"] = {ignore = {"122", "121"}}
> > +files["src/lua/fiber.lua"] = {ignore = {"331", "311"}}
> > +files["src/box/lua/serpent.lua"] = {globals = {"_ENV"}, ignore = {"431", "421", "631", "432", "542", "412", "422"}}
> > +files["src/box/lua/load_cfg.lua"] = {ignore = {"431", "143", "311", "542"}}
> > +files["src/box/lua/net_box.lua"] = {ignore = {"431", "211", "421", "432", "311", "231", "411", "412"}}
> > +files["src/box/lua/schema.lua"] = {globals = {"update_format", "iid", "role_check_grant_revoke_of_sys_priv"}, ignore = {"431", "122", "211", "421", "213", "432", "311", "542", "412"}}
> > +files["src/box/lua/key_def.lua"] = {ignore = {"431"}}
> > +files["src/box/lua/feedback_daemon.lua"] = {ignore = {"122", "211"}}
> > +files["src/box/lua/tuple.lua"] = {ignore = {"122", "211", "421", "412"}}
> > +files["src/box/lua/upgrade.lua"] = {ignore = {"122", "211", "421", "213"}}
> > +files["src/box/lua/console.lua"] = {globals = {"help"}, ignore = {"211", "143"}}
> > +files["test/**/*.lua"] = {ignore = {"631", "611", "614", "613", "612", "621", "112", "211", "432"}}
> > +files["test/app/*.lua"] = {ignore = {"111", "113"}}
> > +files["test/app/lua/fiber.lua"] = {ignore = {"111"}}
> > +files["test/app-tap/*.lua"] = {ignore = {"111", "113"}}
> > +files["test/app-tap/tarantoolctl.test.lua"] = {ignore = {"511"}}
> > +files["test/app-tap/lua/require_mod.lua"] = {ignore = {"113", "111"}}
> > +files["test/box/admin.test.lua"] = {ignore = {"213"}}
> > +files["test/box/lua/*.lua"] = {ignore = {"111"}}
> > +files["test/box/*.lua"] = {ignore = {"111", "113"}}
> > +files["test/box/lua/utils.lua"] = {ignore = {"421", "113", "213", "412"}}
> > +files["test/box/lua/bitset.lua"] = {ignore = {"113", "213"}}
> > +files["test/box/lua/fifo.lua"] = {ignore = {"113", "213"}}
> > +files["test/box/lua/identifier.lua"] = {ignore = {"113"}}
> > +files["test/box/lua/require_mod.lua"] = {ignore = {"113"}}
> > +files["test/box/lua/require_init.lua"] = {ignore = {"412", "143"}}
> > +files["test/box/lua/test_init.lua"] = {ignore = {"113", "412", "143"}}
> > +files["test/box/lua/index_random_test.lua"] = {ignore = {"213"}}
> > +files["test/box-tap/*.lua"] = {ignore = {"111"}}
> > +files["test/box-tap/auth.test.lua"] = {ignore = {"311", "411", "113"}}
> > +files["test/box-tap/cfg.test.lua"] = {ignore = {"311", "411", "113"}}
> > +files["test/box-tap/cfgup.test.lua"] = {ignore = {"113"}}
> > +files["test/box-tap/feedback_daemon.test.lua"] = {ignore = {"411"}}
> > +files["test/box-tap/gc.test.lua"] = {ignore = {"421"}}
> > +files["test/box-tap/on_schema_init.test.lua"] = {ignore = {"113"}}
> > +files["test/box-tap/schema_mt.test.lua"] = {ignore = {"113", "122"}}
> > +files["test/box-tap/key_def.test.lua"] = {ignore = {"411", "431"}}
> > +files["test/box-tap/merger.test.lua"] = {ignore = {"411", "431", "412", "213"}}
> > +files["test/box-tap/session.storage.test.lua"] = {ignore = {"113"}}
> > +files["test/box-tap/session.test.lua"] = {ignore = {"411", "113", "412", "143"}}
> > +files["test/box-tap/trigger_atexit.test.lua"] = {ignore = {"113"}}
> > +files["test/box-tap/trigger_yield.test.lua"] = {ignore = {"213", "113"}}
> > +files["test/luajit-tap/fix_string_find_recording.test.lua"] = {ignore = {"111", "113", "231"}}
> > +files["test/luajit-tap/gh-4476-fix-string-find-recording.test.lua"] = {ignore = {"231"}}
> > +files["test/luajit-tap/fold_bug_LuaJIT_505.test.lua"] = {ignore = {"111", "113"}}
> > +files["test/luajit-tap/gh.test.lua"] = {ignore = {"111", "113"}}
> > +files["test/luajit-tap/table_chain_bug_LuaJIT_494.test.lua"] = {ignore = {"111", "113"}}
> > +files["test/luajit-tap/unsink_64_kptr.test.lua"] = {ignore = {"111", "113", "551", "542"}}
> > +files["test/luajit-tap/or-232-unsink-64-kptr.test.lua"] = {ignore = {"542"}}
> > +files["test/luajit-tap/lj-494-table-chain-infinite-loop.test.lua"] = {ignore = {"111", "113", "213"}}
> > +files["test/engine/*.lua"] = {ignore = {"111", "113"}}
> > +files["test/engine_long/suite.lua"] = {ignore = {"421", "111", "213"}}
> > +files["test/engine_long/delete_replace_update.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/engine_long/delete_insert.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/long_run-py/suite.lua"] = {ignore = {"421", "111", "113", "213"}}
> > +files["test/long_run-py/lua/finalizers.lua"] = {ignore = {"241", "511", "111", "113"}}
> > +files["test/replication/*.lua"] = {ignore = {"113", "111"}}
> > +files["test/replication/lua/fast_replica.lua"] = {ignore = {"113", "213"}}
> > +files["test/replication/lua/rlimit.lua"] = {ignore = {"113"}}
> > +files["test/replication-py/replica.lua"] = {ignore = {"111"}}
> > +files["test/replication/lua/fast_replica.lua"] = {ignore = {"113", "111", "213"}}
> > +files["test/replication/lua/rlimit.lua"] = {ignore = {"113", "111"}}
> > +files["test/sql/*.lua"] = {ignore = {"113", "111"}}
> > +files["test/sql/triggers.test.lua"] = {ignore = {"631", "113", "111"}}
> > +files["test/sql/tokenizer.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/sql/transitive-transactions.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/sql/savepoints.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/sql/persistency.test.lua"] = {ignore = {"113", "111"}}
>
> 5. I see that you added some folders to 'exclude_files'. Why is it still
> needed to add files from these folders here?
Explained in answer to the first comment.
> > +files["test/sql-tap/*.lua"] = {ignore = {"113", "111"}}
> > +files["test/sql-tap/lua_sql.test.lua"] = {ignore = {"412"}}
> > +files["test/sql-tap/subquery.test.lua"] = {ignore = {"412", "143"}}
> > +files["test/sql-tap/alias.test.lua"] = {ignore = {"412", "143"}}
> > +files["test/sql-tap/analyze9.test.lua"] = {ignore = {"213", "411"}}
> > +files["test/sql-tap/between.test.lua"] = {ignore = {"421", "213"}}
> > +files["test/sql-tap/check.test.lua"] = {ignore = {"412", "143"}}
> > +files["test/sql-tap/date.test.lua"] = {ignore = {"511"}}
> > +files["test/sql-tap/e_expr.test.lua"] = {ignore = {"512", "431", "213", "411"}}
> > +files["test/sql-tap/func.test.lua"] = {ignore = {"412", "143"}}
> > +files["test/sql-tap/func5.test.lua"] = {ignore = {"412", "143"}}
> > +files["test/sql-tap/misc1.test.lua"] = {ignore = {"411"}}
> > +files["test/sql-tap/select1.test.lua"] = {ignore = {"511", "213"}}
> > +files["test/sql-tap/select2.test.lua"] = {ignore = {"421"}}
> > +files["test/sql-tap/select4.test.lua"] = {ignore = {"421"}}
> > +files["test/sql-tap/select5.test.lua"] = {ignore = {"421"}}
> > +files["test/sql-tap/selectA.test.lua"] = {ignore = {"542"}}
> > +files["test/sql-tap/selectB.test.lua"] = {ignore = {"213", "542"}}
> > +files["test/sql-tap/selectG.test.lua"] = {ignore = {"421"}}
> > +files["test/sql-tap/table.test.lua"] = {ignore = {"511"}}
> > +files["test/sql-tap/tkt-bd484a090c.test.lua"] = {ignore = {"511"}}
> > +files["test/sql-tap/tkt-38cb5df375.test.lua"] = {ignore = {"421"}}
> > +files["test/sql-tap/tkt-91e2e8ba6f.test.lua"] = {ignore = {"542"}}
> > +files["test/sql-tap/tkt-9a8b09f8e6.test.lua"] = {ignore = {"542"}}
> > +files["test/sql-tap/tkt2192.test.lua"] = {ignore = {"511"}}
> > +files["test/sql-tap/tkt3493.test.lua"] = {ignore = {"542"}}
> > +files["test/sql-tap/triggerA.test.lua"] = {ignore = {"311"}}
> > +files["test/sql-tap/trigger2.test.lua"] = {ignore = {"213"}}
> > +files["test/sql-tap/trigger9.test.lua"] = {ignore = {"143", "412"}}
> > +files["test/sql-tap/update.test.lua"] = {ignore = {"611"}}
> > +files["test/sql-tap/whereB.test.lua"] = {ignore = {"611"}}
> > +files["test/sql-tap/with1.test.lua"] = {ignore = {"542"}}
> > +files["test/sql-tap/with2.test.lua"] = {ignore = {"213", "412"}}
> > +files["test/sql-tap/lua_sql.test.lua"] = {ignore = {"143"}}
> > +files["test/sql-tap/lua/sqltester.lua"] = {ignore = {"111", "113", "431", "213"}}
> > +files["test/sql-tap/gh-2723-concurrency.test.lua"] = {ignore = {"213"}}
> > +files["test/sql-tap/gh-3307-xfer-optimization-issue.test.lua"] = {ignore = {"412", "213"}}
> > +files["test/sql-tap/gh-3083-ephemeral-unref-tuples.test.lua"] = {ignore = {"213"}}
> > +files["test/sql-tap/gh-3332-tuple-format-leak.test.lua"] = {ignore = {"213"}}
> > +files["test/sql-tap/gh2127-indentifier-max-length.test.lua"] = {ignore = {"213"}}
> > +files["test/sql-tap/misc5.test.lua"] = {ignore = {"213"}}
> > +files["test/wal_off/rtree_benchmark.test.lua"] = {ignore = {"213", "113", "111"}}
> > +files["test/wal_off/func_max.test.lua"] = {ignore = {"511", "113", "111"}}
> > +files["test/vinyl/upgrade/fill.lua"] = {ignore = {"111", "113"}}
> > +files["test/vinyl/write_iterator_rand.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/vinyl/savepoint.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/vinyl/replica_quota.test.lua"] = {ignore = {"113", "111", "213"}}
> > +files["test/vinyl/stress.test.lua"] = {ignore = {"431", "213"}}
> > +files["test/vinyl/hermitage.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/vinyl/dump_stress.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/vinyl/constraint.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/vinyl/large.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/vinyl/options.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/xlog/upgrade/2.1.3/gh-4771-upgrade-sequence/fill.lua"] = {ignore = {"111", "113"}}
> > +files["test/xlog/transaction.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/xlog/snap_io_rate.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/xlog/reader.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/xlog/panic_on_broken_lsn.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/xlog/gh1433.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/xlog/header.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/xlog/errinj.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/xlog/force_recovery.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/xlog/big_tx.test.lua"] = {ignore = {"113", "111"}}
> > +files["test/xlog/checkpoint_threshold.test.lua"] = {ignore = {"113", "111", "213"}}
> > +files["test/swim/box.lua"] = {ignore = {"113", "111"}}
> >
--
sergeyb@
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 2/6] Fix luacheck warnings in test/
2020-04-11 16:54 ` Vladislav Shpilevoy
@ 2020-04-14 7:49 ` Sergey Bronnikov
0 siblings, 0 replies; 27+ messages in thread
From: Sergey Bronnikov @ 2020-04-14 7:49 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: o.piskunov, Sergey Bronnikov, tarantool-patches
On 18:54 Sat 11 Apr , Vladislav Shpilevoy wrote:
> Hi! Thanks for the patch!
>
> > diff --git a/test/box/iproto_stress.result b/test/box/iproto_stress.result
> > index 7149d6c52..3b5b0a031 100644
> > --- a/test/box/iproto_stress.result
> > +++ b/test/box/iproto_stress.result
> > @@ -76,13 +76,13 @@ test_run:wait_cond(function() return n_workers == 0 end, 60)
> > ---
> > - true
> > ...
> > -n_workers -- 0
> > +assert(n_workers == 0)
>
> These changes should not be done, IMO. Most of our
> tests are diff based, and therefore it is ok to write
> a statement just to print it. It is not only simpler, but
> also allows to print the actual value, if it didn't match
> the expected value.
> For example, if n_workers becomes not 0, we would see its
> actual value in the diff. When we use assert(), we won't
> see anything except an error message 'assertion failed'.
I'm used to the language that has "smart" assertions that show
content compared by asserts. Like pytest -
https://docs.pytest.org/en/3.0.1/assert.html
Example:
def test_function():
> assert f() == 4
E assert 3 == 4
E + where 3 = f()
> I propose to allow writing non-functional statements in
> test/ dir.
removed previously added asserts
--
sergeyb@
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 5/6] Add luacheck config
2020-04-13 15:16 ` Sergey Bronnikov
@ 2020-04-14 23:29 ` Vladislav Shpilevoy
2020-04-15 8:30 ` Sergey Bronnikov
0 siblings, 1 reply; 27+ messages in thread
From: Vladislav Shpilevoy @ 2020-04-14 23:29 UTC (permalink / raw)
To: Sergey Bronnikov; +Cc: o.piskunov, Sergey Bronnikov, tarantool-patches
Hi! Thanks for the answer!
>>> Lua source code in test/ directory contains both errors and warnings and there
>>> are a lot of them. Some of these warnings were fixed by previous commits and
>>> most part of warnings and errors supressed in luacheck config. Regarding
>>> errors: all found errors belongs to a single error class - "Syntax error"
>>> (E011). All of them have a single root cause - at the of testscases we write
>>> conditions without assignments and it is confuses luacheck. Usually such
>>> conditions used together with asserts, but in our tests we uses reference outputs
>>> instead of asserts.
>>
>> 1. So you disabled that warning for tests, right? Then why still many
>> statements in the test/ dir are replaced with assertions in one of the
>> previous commits?
>
> My original goal was following: fix dangerous warnings and supress other
> of them per file. I followed this strategy and then discovered that E011
> cannot be supressed. In case of errors you should fix them or disable
> checking at all for highlighted files/directories. So this is a reason
> why some exclusions contains single file and some of them contains file
> mask. I decided to keep it as is because more specific supressions are
> more convenient to fix when.
I still think, that if a whole folder was ignored in exclude_files, then
it does not make sense to add individual files from this folder again.
Anyway we won't be able to maintain warning ignorance for these files,
because they are just invisible for luacheck.
But I will leave it to a second reviewer. Igor wanted to take a look too.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 5/6] Add luacheck config
2020-04-14 23:29 ` Vladislav Shpilevoy
@ 2020-04-15 8:30 ` Sergey Bronnikov
0 siblings, 0 replies; 27+ messages in thread
From: Sergey Bronnikov @ 2020-04-15 8:30 UTC (permalink / raw)
To: Vladislav Shpilevoy; +Cc: o.piskunov, Sergey Bronnikov, tarantool-patches
Hi,
Vladislav, see comments inline.
On 01:29 Wed 15 Apr , Vladislav Shpilevoy wrote:
> Hi! Thanks for the answer!
>
> >>> Lua source code in test/ directory contains both errors and warnings and there
> >>> are a lot of them. Some of these warnings were fixed by previous commits and
> >>> most part of warnings and errors supressed in luacheck config. Regarding
> >>> errors: all found errors belongs to a single error class - "Syntax error"
> >>> (E011). All of them have a single root cause - at the of testscases we write
> >>> conditions without assignments and it is confuses luacheck. Usually such
> >>> conditions used together with asserts, but in our tests we uses reference outputs
> >>> instead of asserts.
> >>
> >> 1. So you disabled that warning for tests, right? Then why still many
> >> statements in the test/ dir are replaced with assertions in one of the
> >> previous commits?
> >
> > My original goal was following: fix dangerous warnings and supress other
> > of them per file. I followed this strategy and then discovered that E011
> > cannot be supressed. In case of errors you should fix them or disable
> > checking at all for highlighted files/directories. So this is a reason
> > why some exclusions contains single file and some of them contains file
> > mask. I decided to keep it as is because more specific supressions are
> > more convenient to fix when.
>
> I still think, that if a whole folder was ignored in exclude_files, then
> it does not make sense to add individual files from this folder again.
> Anyway we won't be able to maintain warning ignorance for these files,
> because they are just invisible for luacheck.
Got it.
> But I will leave it to a second reviewer. Igor wanted to take a look too.
Well, I'll wait Igor and then update patchset accordingly.
S.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 4/6] Fix luacheck warnings in extra/dist/tarantoolctl.in
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-15 15:14 ` Igor Munkin
2020-04-15 15:37 ` Igor Munkin
2 siblings, 1 reply; 27+ messages in thread
From: Igor Munkin @ 2020-04-15 15:14 UTC (permalink / raw)
To: Sergey Bronnikov; +Cc: o.piskunov, tarantool-patches
Sergey,
Thanks for the patch! I started with this one, since it's simple and I
can point the general issues related to the fix.
I see the following approach to fix the errors and warning found by
luacheck in *Lua sources*:
* If the fix is obvious and simple -- please do it.
* If the warning/erro fix leads to code complication or reduce
readability (e.g. empty if branch) -- let's add an inline ignore
comment, since it unlikely to be fixed and just burdens .luacheckrc.
* If none of the above -- add the corresponding rule to .luacheckrc.
I left inline comments for your patch and added the fix I made for
tarantoolctl at the end. Please consider them.
On 08.04.20, Sergey Bronnikov wrote:
> From: Sergey Bronnikov <sergeyb@tarantool.org>
>
> Closes #4681
> ---
> extra/dist/tarantoolctl.in | 20 +++++++++-----------
> 1 file changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in
> index f5a912ccd..3bcbe5b79 100755
> --- a/extra/dist/tarantoolctl.in
> +++ b/extra/dist/tarantoolctl.in
<snipped>
> @@ -64,7 +63,7 @@ end
>
> local function check_user_level()
> local uid = os.getenv('UID')
> - local udir = nil
> + local udir
Minor: I looked at the code nearby and it looks like this initialization
can be moved below, since udir is unused prior it (consider the changes
below).
> if uid == 0 or os.getenv("NOTIFY_SOCKET") then
> return nil
> end
> @@ -420,7 +419,7 @@ local cat_formats = setmetatable({
> json = cat_json_cb,
> lua = cat_lua_cb,
> }, {
> - __index = function(self, cmd)
> + __index = function(cmd)
Side-note: I see you reverted this change, but the fix proposed by Oleg
is a good one. I guess we can apply it here.
> error(("Unknown formatter '%s'"):format(cmd))
> end
> })
<snipped>
> --
> 2.23.0
>
I tried to fix the issues by myself and dumped my step-by-step activity
below. At first let's see what luacheck reports for tarantoolctl source:
| $ luacheck --codes extra/dist/tarantoolctl.in | tail -1
| Total: 35 warnings / 0 errors in 1 file
| $ luacheck --codes extra/dist/tarantoolctl.in | \
| grep -vP '^(Total:|Checking|$)' | cut -f 6 -d ' ' | sort | uniq -c
| 1 (W112)
| 5 (W113)
| 1 (W122)
| 2 (W211)
| 3 (W212)
| 4 (W213)
| 3 (W311)
| 2 (W411)
| 13 (W431)
| 1 (W542)
According to the list of warnings[1] W113 is reported when accessing an
undefined global variable is detected. At the same time W112 is reported
when mutating an undefined global variable is detected. Considering
output these are well known Tarantool globals: box and _TARANTOOL. Let's
suppress them (now with CLI option and globally in .luacheckrc further):
| $ luacheck --codes extra/dist/tarantoolctl.in --globals box --globals _TARANTOOL | \
| grep -vP '^(Total:|Checking|$)' | cut -f 6 -d ' ' | sort | uniq -c
| 1 (W122)
| 2 (W211)
| 3 (W212)
| 4 (W213)
| 3 (W311)
| 2 (W411)
| 13 (W431)
| 1 (W542)
Well, 6 false-positive warnings are suppressed, 29 others left. Let's
see the remaining ones:
| $ luacheck --codes extra/dist/tarantoolctl.in --globals box --globals _TARANTOOL
| Checking extra/dist/tarantoolctl.in 29 warnings
|
| extra/dist/tarantoolctl.in:49:7: (W211) unused variable 'lua_arguments'
| extra/dist/tarantoolctl.in:67:11: (W311) value assigned to variable 'udir' is unused
| extra/dist/tarantoolctl.in:127:34: (W431) shadowing upvalue 'default_file' on line 38
| extra/dist/tarantoolctl.in:136:22: (W411) variable 'msg' was previously defined on line 130
| extra/dist/tarantoolctl.in:217:5: (W122) setting read-only field '?' of global 'arg'
| extra/dist/tarantoolctl.in:423:24: (W212) unused argument 'self'
| extra/dist/tarantoolctl.in:440:15: (W431) shadowing upvalue 'console_sock' on line 42
| extra/dist/tarantoolctl.in:573:11: (W431) shadowing upvalue 'console_sock' on line 42
| extra/dist/tarantoolctl.in:634:11: (W431) shadowing upvalue 'console_sock' on line 42
| extra/dist/tarantoolctl.in:695:31: (W431) shadowing upvalue 'uri' on line 9
| extra/dist/tarantoolctl.in:759:11: (W431) shadowing upvalue 'console_sock' on line 42
| extra/dist/tarantoolctl.in:793:11: (W311) value assigned to variable 'code' is unused
| extra/dist/tarantoolctl.in:819:11: (W431) shadowing upvalue 'status' on line 750
| extra/dist/tarantoolctl.in:851:11: (W211) unused variable 'spaces'
| extra/dist/tarantoolctl.in:852:21: (W411) variable 'spaces' was previously defined on line 851
| extra/dist/tarantoolctl.in:865:59: (W542) empty if branch
| extra/dist/tarantoolctl.in:878:9: (W213) unused loop variable 'id'
| extra/dist/tarantoolctl.in:895:11: (W431) shadowing upvalue 'uri' on line 9
| extra/dist/tarantoolctl.in:904:9: (W213) unused loop variable 'id'
| extra/dist/tarantoolctl.in:926:9: (W213) unused loop variable 'i'
| extra/dist/tarantoolctl.in:940:11: (W311) value assigned to variable 'key' is unused
| extra/dist/tarantoolctl.in:957:30: (W212) unused argument 'command'
| extra/dist/tarantoolctl.in:957:39: (W212) unused argument 'program'
| extra/dist/tarantoolctl.in:1324:9: (W213) unused loop variable 'no'
| extra/dist/tarantoolctl.in:1333:31: (W431) shadowing upvalue 'commands' on line 1019
| extra/dist/tarantoolctl.in:1335:18: (W431) shadowing upvalue 'self_name' on line 30
| extra/dist/tarantoolctl.in:1387:15: (W431) shadowing upvalue 'command_name' on line 32
| extra/dist/tarantoolctl.in:1388:15: (W431) shadowing upvalue 'positional_arguments' on line 47
| extra/dist/tarantoolctl.in:1388:37: (W431) shadowing upvalue 'keyword_arguments' on line 48
|
| Total: 29 warnings / 0 errors in 1 file
Considering your patch you've already fixed all W211[unused local
variable], W212[unused argument] (considering the fix proposed by Oleg)
and W213[unused loop variable] warnings. The fixes are obvious and
good. Furthermore, you've successfully fixed all W311[value assigned to
a local variable is unused] warnings (but I fixed one of them in a
slightly different way below).
If I didn't miss anything, only the following warnings are left:
| $ luacheck --codes extra/dist/tarantoolctl.in --globals box --globals _TARANTOOL | \
| grep -vP '^(Total:|Checking|$)' | cut -f 6 -d ' ' | sort | uniq -c
| 1 (W122)
| 1 (W411)
| 13 (W431)
| 1 (W542)
* extra/dist/tarantoolctl.in:136:22: (W411) variable 'msg' was previously defined on line 130
Both msg values are well-localized, so I guess we can simply rename
both occurences (consider the changes below).
* extra/dist/tarantoolctl.in:865:59: (W542) empty if branch
This warning is also false-positive, since the way the branches are
organized makes code clearer. Thereby this warning looks unlikely to
be fixed, so I added an inline suppression.
The remaining errors (read-only arg table modification and upvalue
shadowing) can be placed to .luacheckrc to be fixed in future, since
fixes seem to be non-trivial and some of them introduce changes to
function contracts/behaviour.
Omitting few lines to be added to .luacheckrc, here are my changes:
================================================================================
diff --git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in
index f5a912ccd..a80ecc057 100755
--- a/extra/dist/tarantoolctl.in
+++ b/extra/dist/tarantoolctl.in
@@ -46,7 +46,6 @@ local instance_dir
local default_cfg
local positional_arguments
local keyword_arguments
-local lua_arguments = arg
local language
-- function for printing usage reference
@@ -64,13 +63,12 @@ end
local function check_user_level()
local uid = os.getenv('UID')
- local udir = nil
if uid == 0 or os.getenv("NOTIFY_SOCKET") then
return nil
end
-- local dir configuration
local pwd = os.getenv('PWD')
- udir = pwd and pwd .. '/.tarantoolctl'
+ local udir = pwd and pwd .. '/.tarantoolctl' or nil
udir = udir and fio.stat(udir) and udir or nil
-- or home dir configuration
local homedir = os.getenv('HOME')
@@ -127,15 +125,15 @@ end
local function load_default_file(default_file)
if default_file then
local env = setmetatable({}, { __index = _G })
- local ufunc, msg = loadfile(default_file)
+ local ufunc, loaderr = loadfile(default_file)
-- if load fails - show the last 10 lines of the log file
if not ufunc then
- log.error("Failed to load defaults file: %s", msg)
+ log.error("Failed to load defaults file: %s", loaderr)
end
debug.setfenv(ufunc, env)
- local state, msg = pcall(ufunc)
+ local state, err = pcall(ufunc)
if not state then
- log.error('Failed to execute defaults file: %s', msg)
+ log.error('Failed to execute defaults file: %s', err)
end
default_cfg = env.default_cfg
instance_dir = env.instance_dir
@@ -420,7 +418,7 @@ local cat_formats = setmetatable({
json = cat_json_cb,
lua = cat_lua_cb,
}, {
- __index = function(self, cmd)
+ __index = function(_, cmd)
error(("Unknown formatter '%s'"):format(cmd))
end
})
@@ -790,7 +788,7 @@ end
local function eval()
local console_sock_path = uri.parse(console_sock).service
local filename = arg[3]
- local code = nil
+ local code
if filename == nil then
if stdin_isatty() then
log.error("Usage:")
@@ -848,7 +846,6 @@ end
-- xlog / snap file, so even when it stops on LSN >= @a opts.to on
-- a current file a next file will be processed.
local function filter_xlog(gen, param, state, opts, cb)
- local spaces = opts.spaces
local from, to, spaces = opts.from, opts.to, opts.space
local show_system, replicas = opts['show-system'], opts.replica
@@ -862,7 +859,7 @@ local function filter_xlog(gen, param, state, opts, cb)
elseif (lsn < from) or (lsn >= to) or
(not spaces and sid and sid < 512 and not show_system) or
(spaces and (sid == nil or not find_in_list(sid, spaces))) or
- (replicas and not find_in_list(rid, replicas)) then
+ (replicas and not find_in_list(rid, replicas)) then -- luacheck: ignore
-- pass this tuple
else
cb(record)
@@ -875,7 +872,7 @@ local function cat()
local cat_format = opts.format
local format_cb = cat_formats[cat_format]
local is_printed = false
- for id, file in ipairs(positional_arguments) do
+ for _, file in ipairs(positional_arguments) do
log.error("Processing file '%s'", file)
local gen, param, state = xlog.pairs(file)
filter_xlog(gen, param, state, opts, function(record)
@@ -901,7 +898,7 @@ local function play()
if not remote:wait_connected() then
error(("Error while connecting to host '%s'"):format(uri))
end
- for id, file in ipairs(positional_arguments) do
+ for _, file in ipairs(positional_arguments) do
log.info(("Processing file '%s'"):format(file))
local gen, param, state = xlog.pairs(file)
filter_xlog(gen, param, state, opts, function(record)
@@ -923,7 +920,7 @@ local function play()
end
local function find_arg(name_arg)
- for i, key in ipairs(arg) do
+ for _, key in ipairs(arg) do
if key:find(name_arg) ~= nil then
return key
end
@@ -937,7 +934,7 @@ local function rocks()
local util = require("luarocks.util")
local command_line = require("luarocks.cmd")
local options = keyword_arguments
- local key = nil
+ local key
if options["only-server"] ~= nil then
key = find_arg("only%-server")
else
@@ -954,7 +951,7 @@ local function rocks()
end
-- Tweak help messages
- util.see_help = function(command, program)
+ util.see_help = function()
-- TODO: print extended help message here
return "See Tarantool documentation for help."
end
@@ -1321,7 +1318,7 @@ local function usage_command(name, cmd)
if type(header) == 'string' then
header = { header }
end
- for no, line in ipairs(header) do
+ for _, line in ipairs(header) do
log.error(" " .. line, name)
end
end
================================================================================
[1]: https://luacheck.readthedocs.io/en/stable/warnings.html
--
Best regards,
IM
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 4/6] Fix luacheck warnings in extra/dist/tarantoolctl.in
2020-04-15 15:14 ` Igor Munkin
@ 2020-04-15 15:37 ` Igor Munkin
0 siblings, 0 replies; 27+ messages in thread
From: Igor Munkin @ 2020-04-15 15:37 UTC (permalink / raw)
To: Sergey Bronnikov; +Cc: o.piskunov, tarantool-patches
Sergey,
Sorry, I chose wrong series, please disregard this message. I sent it to
the current patchset.
--
Best regards,
IM
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Tarantool-patches] [PATCH v2 6/6] gitlab-ci: enable static analysis with luacheck
2020-04-10 14:53 ` Sergey Bronnikov
@ 2020-04-22 8:45 ` Alexander Tikhonov
0 siblings, 0 replies; 27+ messages in thread
From: Alexander Tikhonov @ 2020-04-22 8:45 UTC (permalink / raw)
To: Sergey Bronnikov; +Cc: o.piskunov, Sergey Bronnikov, tarantool-patches
[-- Attachment #1: Type: text/plain, Size: 3840 bytes --]
Hi Sergey, please check my comments below.
>Пятница, 10 апреля 2020, 17:53 +03:00 от Sergey Bronnikov <sergeyb@tarantool.org>:
>
>Hello,
>
>thanks for review. Please see my answers inline.
>
>On 07:20 Thu 09 Apr , Alexander Tikhonov wrote:
>>
>> Hi Sergey, thank you for the patch, please check my comments below.
>>
>>
>> >Среда, 8 апреля 2020, 18:43 +03:00 от Sergey Bronnikov < estetus@gmail.com >:
>> >
>> >From: Sergey Bronnikov < sergeyb@tarantool.org >
>> >
>> >Closes #4681
>> >---
>> Please add in the review letter the link to the branch here, also the issue link.
>
>Will do next time.
>
>> > .gitlab-ci.yml | 9 +++++++++
>> > .travis.mk | 12 +++++++++++-
>> > 2 files changed, 20 insertions(+), 1 deletion(-)
>> >
>> >diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
>> >index cd710027f..adbd892c8 100644
>> >--- a/.gitlab-ci.yml
>> >+++ b/.gitlab-ci.yml
>> >@@ -1,4 +1,5 @@
>> > stages:
>> >+ - static_analysis
>> Do we really need the separate stage for this job ? As we agreed with
>> A. Turenko before, we create stages only for jobs that needs additional
>> steps w/o next steps wont work and which can be used in the next stage
>> for more than single job.
>
>I think the answer is "yes". The arguments are:
>- it is a best practice in industry to split CI/CD pipeline for several
>stages. In canonical example they are: build, test, deploy.
Actually right that canonical way is good, but do we really need it. Is
it actually better than have the faster way to find the issues? I mean
that out gitlab-ci is using for now not for the automate production, but
for the fast developers testing — it means that they use it not to check
the final code, but to develop it and run it a lot of times during it. I can
absolutely agree that we need CI/CD process and we can start create
it here, but it should be the other separate pipeline from branches
testings. So my suggestion is to left the branch testing flat to be fast,
and add your change just for releases branches testings. By the way
gitlab-ci is too weak for CI/CD processes — much better to use Jenkins
either other CI/CD tools which can use pipelines in parallel instead of
gitlab-ci which can’t do it.
>- build, static analysis, unit testing, module testing are successive
>steps in finding bugs. Each step requires different amount of efforts to
>debug in case of failure. No reasons to perform unit testing when compiler
>warns about non-initialized variables and no reasons to perform complex
>functional testing when unit tests failed.
>
>We have future plans to add clang-analyzer and more strict warnings in
>compilers and 'static_analysis' stage will be a good place for these
>tasks on pipeline.
>
>> Anyway separate stage will add depends for the rest of the jobs, which
>> can be blocked because of any issue with luacheck, like it can be
>> luacheck cloning either its depends installations:
>
><snipped>
>
>> >index f709a18b6..32222621b 100644
>> >--- a/.travis.mk
>> >+++ b/.travis.mk
>> >@@ -77,8 +77,9 @@ deps_buster_clang_8: deps_debian
>> > # Release
>> >
>> > build_debian:
>> >- cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_WERROR=ON ${CMAKE_EXTRA_PARAMS}
>> >+ cmake . -DENABLE_DIST=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_WERROR=ON ${CMAKE_EXTRA_PARAMS}
>> This target is common wide along all the jobs and if ENABLE_DIST
>> define is not adding changes for them may be just need add the comment
>> the purpose on its adding.
>
>Well, I'll describe this in a commit message.
>
>> > make -j
>> >+ sudo make install
>> This target is common wide along all the jobs and may be it better to
>> move the installation to the target ‘luacheck’ which only needs it.
>
>Well, I'll move 'make install' to a separate target.
>
><snipped>
>
>S.
--
Alexander Tikhonov
[-- Attachment #2: Type: text/html, Size: 5112 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2020-04-22 8:45 UTC | newest]
Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox