From e5d07c158f99a78a1e69c4ad2ffc297e2c6d4dea Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 10 Mar 2016 17:48:53 +0000 Subject: util.iterators: Don't replace var, as we should preserve var from the original iterator [luacheck] --- util/iterators.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util') diff --git a/util/iterators.lua b/util/iterators.lua index 868ba786..92f75189 100644 --- a/util/iterators.lua +++ b/util/iterators.lua @@ -154,7 +154,7 @@ end -- Convert the values returned by an iterator to an array function it.to_array(f, s, var) - local t, var = {}; + local t = {}; while true do var = f(s, var); if var == nil then break; end -- cgit v1.2.3 From e2f3356e2404641840283b8d439137e58604346b Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 10 Mar 2016 17:49:46 +0000 Subject: util.iterators: Return initial var from upstream iterator [luacheck] --- util/iterators.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util') diff --git a/util/iterators.lua b/util/iterators.lua index 92f75189..99b5f090 100644 --- a/util/iterators.lua +++ b/util/iterators.lua @@ -93,7 +93,7 @@ function it.head(n, f, s, var) end c = c + 1; return f(s, var); - end, s; + end, s, var; end -- Skip the first n items an iterator returns -- cgit v1.2.3 From 8967760df50c3b1c39fec83b0b3f1e75858daca1 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 10 Mar 2016 17:52:03 +0000 Subject: net.websocket.frames, util.datetime, util.json, util.prosodyctl, util.rfc6724: Remove unused variables [luacheck] --- util/datetime.lua | 1 - util/json.lua | 1 - util/prosodyctl.lua | 2 +- util/rfc6724.lua | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) (limited to 'util') diff --git a/util/datetime.lua b/util/datetime.lua index 27f28ace..abb4e867 100644 --- a/util/datetime.lua +++ b/util/datetime.lua @@ -12,7 +12,6 @@ local os_date = os.date; local os_time = os.time; local os_difftime = os.difftime; -local error = error; local tonumber = tonumber; local _ENV = nil; diff --git a/util/json.lua b/util/json.lua index 2c598446..ec6b67de 100644 --- a/util/json.lua +++ b/util/json.lua @@ -12,7 +12,6 @@ local s_char = string.char; local tostring, tonumber = tostring, tonumber; local pairs, ipairs = pairs, ipairs; local next = next; -local error = error; local getmetatable, setmetatable = getmetatable, setmetatable; local print = print; diff --git a/util/prosodyctl.lua b/util/prosodyctl.lua index f8f28644..207b3763 100644 --- a/util/prosodyctl.lua +++ b/util/prosodyctl.lua @@ -22,7 +22,7 @@ local nodeprep, nameprep = stringprep.nodeprep, stringprep.nameprep; local io, os = io, os; local print = print; -local tostring, tonumber = tostring, tonumber; +local tonumber = tonumber; local CFG_SOURCEDIR = _G.CFG_SOURCEDIR; diff --git a/util/rfc6724.lua b/util/rfc6724.lua index c8aec631..81f78d55 100644 --- a/util/rfc6724.lua +++ b/util/rfc6724.lua @@ -10,7 +10,6 @@ -- We can't hand this off to getaddrinfo, since it blocks local ip_commonPrefixLength = require"util.ip".commonPrefixLength -local new_ip = require"util.ip".new_ip; local function commonPrefixLength(ipA, ipB) local len = ip_commonPrefixLength(ipA, ipB); -- cgit v1.2.3 From cae49b6891841ba8458733bc2f364c0fd89e48b7 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 10 Mar 2016 17:52:57 +0000 Subject: util.iterators: Variable renaming to avoid shadowing [luacheck] --- util/iterators.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'util') diff --git a/util/iterators.lua b/util/iterators.lua index 99b5f090..d453a694 100644 --- a/util/iterators.lua +++ b/util/iterators.lua @@ -29,10 +29,10 @@ function it.reverse(f, s, var) -- Then return our reverse one local i,max = 0, #results; - return function (results) + return function (_results) if i= n then return nil; end c = c + 1; - return f(s, var); + return f(_s, _var); end, s, var; end -- Skip the first n items an iterator returns function it.skip(n, f, s, var) - for i=1,n do + for _ = 1, n do var = f(s, var); end return f, s, var; @@ -132,9 +132,9 @@ function it.filter(filter, f, s, var) local filter_value = filter; function filter(x) return x ~= filter_value; end end - return function (s, var) + return function (_s, _var) local ret; - repeat ret = pack(f(s, var)); + repeat ret = pack(f(_s, _var)); var = ret[1]; until var == nil or filter(unpack(ret, 1, ret.n)); return unpack(ret, 1, ret.n); -- cgit v1.2.3 From bd3767353f233524c2df53801155280cacd3b986 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 10 Mar 2016 17:53:17 +0000 Subject: util.json: Variable renaming to avoid shadowing [luacheck] --- util/json.lua | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'util') diff --git a/util/json.lua b/util/json.lua index ec6b67de..cba54e8e 100644 --- a/util/json.lua +++ b/util/json.lua @@ -19,10 +19,10 @@ local has_array, array = pcall(require, "util.array"); local array_mt = has_array and getmetatable(array()) or {}; --module("json") -local json = {}; +local module = {}; local null = setmetatable({}, { __tostring = function() return "null"; end; }); -json.null = null; +module.null = null; local escapes = { ["\""] = "\\\"", ["\\"] = "\\\\", ["\b"] = "\\b", @@ -69,7 +69,7 @@ end function arraysave(o, buffer) t_insert(buffer, "["); if next(o) then - for i,v in ipairs(o) do + for _, v in ipairs(o) do simplesave(v, buffer); t_insert(buffer, ","); end @@ -164,17 +164,17 @@ function simplesave(o, buffer) end end -function json.encode(obj) +function module.encode(obj) local t = {}; simplesave(obj, t); return t_concat(t); end -function json.encode_ordered(obj) +function module.encode_ordered(obj) local t = { ordered = true }; simplesave(obj, t); return t_concat(t); end -function json.encode_array(obj) +function module.encode_array(obj) local t = {}; arraysave(obj, t); return t_concat(t); @@ -190,7 +190,7 @@ local function _fixobject(obj) local __array = obj.__array; if __array then obj.__array = nil; - for i,v in ipairs(__array) do + for _, v in ipairs(__array) do t_insert(obj, v); end end @@ -198,7 +198,7 @@ local function _fixobject(obj) if __hash then obj.__hash = nil; local k; - for i,v in ipairs(__hash) do + for _, v in ipairs(__hash) do if k ~= nil then obj[k] = v; k = nil; else @@ -343,7 +343,7 @@ local first_escape = { ["\\u" ] = "\\u"; }; -function json.decode(json) +function module.decode(json) json = json:gsub("\\.", first_escape) -- get rid of all escapes except \uXXXX, making string parsing much simpler --:gsub("[\r\n]", "\t"); -- \r\n\t are equivalent, we care about none of them, and none of them can be in strings @@ -356,10 +356,10 @@ function json.decode(json) return val; end -function json.test(object) - local encoded = json.encode(object); - local decoded = json.decode(encoded); - local recoded = json.encode(decoded); +function module.test(object) + local encoded = module.encode(object); + local decoded = module.decode(encoded); + local recoded = module.encode(decoded); if encoded ~= recoded then print("FAILED"); print("encoded:", encoded); @@ -370,4 +370,4 @@ function json.test(object) return encoded == recoded; end -return json; +return module; -- cgit v1.2.3 From 0d16907ff389fad3fd9135f1f84c4805b5e19687 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 10 Mar 2016 17:53:36 +0000 Subject: util.prosodyctl: Remove unused variable [luacheck] --- util/prosodyctl.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util') diff --git a/util/prosodyctl.lua b/util/prosodyctl.lua index 207b3763..cde1cdd4 100644 --- a/util/prosodyctl.lua +++ b/util/prosodyctl.lua @@ -149,7 +149,7 @@ local function adduser(params) end local function user_exists(params) - local user, host, password = nodeprep(params.user), nameprep(params.host), params.password; + local user, host = nodeprep(params.user), nameprep(params.host); storagemanager.initialize_host(host); local provider = prosody.hosts[host].users; -- cgit v1.2.3