From 7a87176df82a4744559b4a13071a1d2813eb5a86 Mon Sep 17 00:00:00 2001 From: Anton Shestakov Date: Sat, 9 Jul 2016 00:37:34 +0800 Subject: net.server_select: remove unused one-letter loop variables [luacheck] --- net/server_select.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/server_select.lua b/net/server_select.lua index 3503c30d..85730e73 100644 --- a/net/server_select.lua +++ b/net/server_select.lua @@ -864,7 +864,7 @@ loop = function(once) -- this is the main loop of the program local next_timer_time = math_huge; repeat local read, write, err = socket_select( _readlist, _sendlist, math_min(_selecttimeout, next_timer_time) ) - for i, socket in ipairs( write ) do -- send data waiting in writequeues + for _, socket in ipairs( write ) do -- send data waiting in writequeues local handler = _socketlist[ socket ] if handler then handler.sendbuffer( ) @@ -873,7 +873,7 @@ loop = function(once) -- this is the main loop of the program out_put "server.lua: found no handler and closed socket (writelist)" -- this should not happen end end - for i, socket in ipairs( read ) do -- receive data + for _, socket in ipairs( read ) do -- receive data local handler = _socketlist[ socket ] if handler then handler.readbuffer( ) -- cgit v1.2.3 From 4da595c2cfef06f0f2860cf8e6bdb864eed3b1fd Mon Sep 17 00:00:00 2001 From: Anton Shestakov Date: Sat, 9 Jul 2016 00:45:59 +0800 Subject: net.dns: remove unused one-letter loop variables [luacheck] --- net/dns.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/dns.lua b/net/dns.lua index 689020a4..4a35fc1b 100644 --- a/net/dns.lua +++ b/net/dns.lua @@ -190,7 +190,7 @@ end local rrs_metatable = {}; -- - - - - - - - - - - - - - - - - - rrs_metatable function rrs_metatable.__tostring(rrs) local t = {}; - for i,rr in ipairs(rrs) do + for _, rr in ipairs(rrs) do append(t, tostring(rr)..'\n'); end return table.concat(t); @@ -841,7 +841,7 @@ function resolver:receive(rset) -- - - - - - - - - - - - - - - - - receive rset = rset or self.socket; local response; - for i,sock in pairs(rset) do + for _, sock in pairs(rset) do if self.socketset[sock] then local packet = sock:receive(); @@ -852,7 +852,7 @@ function resolver:receive(rset) -- - - - - - - - - - - - - - - - - receive --print('received response'); --self.print(response); - for j,rr in pairs(response.answer) do + for _, rr in pairs(response.answer) do if rr.name:sub(-#response.question[1].name, -1) == response.question[1].name then self:remember(rr, response.question[1].type) end @@ -894,7 +894,7 @@ function resolver:feed(sock, packet, force) --print('received response'); --self.print(response); - for j,rr in pairs(response.answer) do + for _, rr in pairs(response.answer) do self:remember(rr, response.question[1].type); end -- cgit v1.2.3 From 0ce8de81abe844339492f079adf08e9092eb7b61 Mon Sep 17 00:00:00 2001 From: Anton Shestakov Date: Sat, 9 Jul 2016 00:46:28 +0800 Subject: mod_presence: remove unused one-letter loop variable [luacheck] --- plugins/mod_presence.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mod_presence.lua b/plugins/mod_presence.lua index cf762edc..e4a317bc 100644 --- a/plugins/mod_presence.lua +++ b/plugins/mod_presence.lua @@ -130,7 +130,7 @@ function send_presence_of_available_resources(user, host, jid, recipient_session if h and h.type == "local" then local u = h.sessions[user]; if u then - for k, session in pairs(u.sessions) do + for _, session in pairs(u.sessions) do local pres = session.presence; if pres then if stanza then pres = stanza; pres.attr.from = session.full_jid; end -- cgit v1.2.3 From 885648c042398d76f44683d1462084cbfca63940 Mon Sep 17 00:00:00 2001 From: Anton Shestakov Date: Sat, 9 Jul 2016 00:47:55 +0800 Subject: mod_admin_telnet: rename variable to make it defined (room -> room_name) --- plugins/mod_admin_telnet.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua index 9dfbbc7a..b2a01324 100644 --- a/plugins/mod_admin_telnet.lua +++ b/plugins/mod_admin_telnet.lua @@ -957,11 +957,11 @@ local function check_muc(jid) end function def_env.muc:create(room_jid) - local room, host = check_muc(room_jid); + local room_name, host = check_muc(room_jid); if not room_name then return room_name, host; end - if not room then return nil, host end + if not room_name then return nil, host end if hosts[host].modules.muc.rooms[room_jid] then return nil, "Room exists already" end return hosts[host].modules.muc.create_room(room_jid); end -- cgit v1.2.3 From 1507e8b4983b9c698cfa67131005a5a9d9c533f6 Mon Sep 17 00:00:00 2001 From: Anton Shestakov Date: Sat, 9 Jul 2016 00:53:46 +0800 Subject: test_util_multitable: make mt variable local [luacheck] --- tests/test_util_multitable.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_util_multitable.lua b/tests/test_util_multitable.lua index 71a83450..4a8dd14c 100644 --- a/tests/test_util_multitable.lua +++ b/tests/test_util_multitable.lua @@ -8,7 +8,7 @@ function new(new, multitable) - mt = new(); + local mt = new(); assert_table(mt, "Multitable is a table"); assert_function(mt.add, "Multitable has method add"); assert_function(mt.get, "Multitable has method get"); @@ -40,7 +40,7 @@ function get(get, multitable) return assert_equal(select(2, has_items(list, ...)), "has-all", message or "List has all expected items, and no more", 2); end - mt = multitable.new(); + local mt = multitable.new(); local trigger1, trigger2, trigger3 = {}, {}, {}; local item1, item2, item3 = {}, {}, {}; -- cgit v1.2.3 From f6a1c987cebc02bff835b471054b8065fa0c9ab0 Mon Sep 17 00:00:00 2001 From: Anton Shestakov Date: Sat, 9 Jul 2016 00:56:32 +0800 Subject: test_util_jid: make function test() local [luacheck] --- tests/test_util_jid.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_util_jid.lua b/tests/test_util_jid.lua index c697e63f..0ac5827e 100644 --- a/tests/test_util_jid.lua +++ b/tests/test_util_jid.lua @@ -19,7 +19,7 @@ end function split(split) - function test(input_jid, expected_node, expected_server, expected_resource) + local function test(input_jid, expected_node, expected_server, expected_resource) local rnode, rserver, rresource = split(input_jid); assert_equal(expected_node, rnode, "split("..tostring(input_jid)..") failed"); assert_equal(expected_server, rserver, "split("..tostring(input_jid)..") failed"); -- cgit v1.2.3 From 2a2ade5de5dcdce49541f759088bac76e5972af3 Mon Sep 17 00:00:00 2001 From: Anton Shestakov Date: Sat, 9 Jul 2016 00:57:17 +0800 Subject: mod_admin_telnet: remove unused import (util.serialization) [luacheck] --- plugins/mod_admin_telnet.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua index b2a01324..088e09dd 100644 --- a/plugins/mod_admin_telnet.lua +++ b/plugins/mod_admin_telnet.lua @@ -732,7 +732,6 @@ local function print_errors(print, errors) end function def_env.s2s:showcert(domain) - local ser = require "util.serialization".serialize; local print = self.session.print; local s2s_sessions = module:shared"/*/s2s/sessions"; local domain_sessions = set.new(array.collect(values(s2s_sessions))) -- cgit v1.2.3 From 45af943ce3ac3fac7d9f8f8e68b0f0f28b31f6bd Mon Sep 17 00:00:00 2001 From: Anton Shestakov Date: Sat, 9 Jul 2016 00:58:16 +0800 Subject: net.adns: remove unused local variables t_insert and t_remove [luacheck] --- net/adns.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/net/adns.lua b/net/adns.lua index d3da2065..0b7247ed 100644 --- a/net/adns.lua +++ b/net/adns.lua @@ -11,7 +11,6 @@ local dns = require "net.dns"; local log = require "util.logger".init("adns"); -local t_insert, t_remove = table.insert, table.remove; local coroutine, tostring, pcall = coroutine, tostring, pcall; local function dummy_send(sock, data, i, j) return (j-i)+1; end -- cgit v1.2.3 From 9741bdfb3887695e7021d793ce6a96eaf595ed2b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 8 Jul 2016 19:20:49 +0200 Subject: luacheckrc: Ignore assert helper functions used in tests/* --- .luacheckrc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.luacheckrc b/.luacheckrc index 590f9c37..2fc05e75 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -10,3 +10,14 @@ ignore = { "411/err", "421/err", "411/ok", "421/ok", "211/_ENV" } files["plugins/"] = { ignore = { "122/module" }; } +files["tests/"] = { + ignore = { + "113/assert_equal", + "113/assert_table", + "113/assert_function", + "113/assert_string", + "113/assert_boolean", + "113/assert_is", + "113/assert_is_not", + }; +} -- cgit v1.2.3