From 1ecc3a7918024a07c2b9f38d274584683e7c3218 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 4 Mar 2017 17:49:48 +0100 Subject: core: Split some very long lines [luacheck] --- core/configmanager.lua | 3 ++- core/moduleapi.lua | 6 ++++-- core/modulemanager.lua | 3 ++- core/portmanager.lua | 12 ++++++++---- core/s2smanager.lua | 4 +++- core/sessionmanager.lua | 5 ++++- core/stanza_router.lua | 12 ++++++++---- core/storagemanager.lua | 6 ++++-- 8 files changed, 35 insertions(+), 16 deletions(-) (limited to 'core') diff --git a/core/configmanager.lua b/core/configmanager.lua index 16d4b8e2..5a544375 100644 --- a/core/configmanager.lua +++ b/core/configmanager.lua @@ -158,7 +158,8 @@ do function env.Component(name) name = nameprep(name); - if rawget(config_table, name) and rawget(config_table[name], "defined") and not rawget(config_table[name], "component_module") then + if rawget(config_table, name) and rawget(config_table[name], "defined") + and not rawget(config_table[name], "component_module") then error(format("Component %q clashes with previously defined Host %q, for services use a sub-domain like conference.%s", name, name, name), 0); end diff --git a/core/moduleapi.lua b/core/moduleapi.lua index ee1f3e60..34214f26 100644 --- a/core/moduleapi.lua +++ b/core/moduleapi.lua @@ -115,7 +115,8 @@ function api:hook_tag(xmlns, name, handler, priority) self:log("warn", "Error: Insufficient parameters to module:hook_stanza()"); return; end - return self:hook("stanza/"..(xmlns and (xmlns..":") or "")..name, function (data) return handler(data.origin, data.stanza, data); end, priority); + return self:hook("stanza/"..(xmlns and (xmlns..":") or "")..name, + function (data) return handler(data.origin, data.stanza, data); end, priority); end api.hook_stanza = api.hook_tag; -- COMPAT w/pre-0.9 @@ -187,7 +188,8 @@ function api:shared(...) local path = paths[i]; if path:sub(1,1) ~= "/" then -- Prepend default components local n_components = select(2, path:gsub("/", "%1")); - path = (n_components<#default_path_components and "/" or "")..t_concat(default_path_components, "/", 1, #default_path_components-n_components).."/"..path; + path = (n_components<#default_path_components and "/" or "") + ..t_concat(default_path_components, "/", 1, #default_path_components-n_components).."/"..path; end local shared = shared_data[path]; if not shared then diff --git a/core/modulemanager.lua b/core/modulemanager.lua index 7bed1795..771f6fb1 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -39,7 +39,8 @@ local _G = _G; local _ENV = nil; -local load_modules_for_host, load, unload, reload, get_module, get_items, get_modules, is_loaded, module_has_method, call_module_method; +local load_modules_for_host, load, unload, reload, get_module, get_items; +local get_modules, is_loaded, module_has_method, call_module_method; -- [host] = { [module] = module_env } local modulemap = { ["*"] = {} }; diff --git a/core/portmanager.lua b/core/portmanager.lua index ad1a0be3..5b6476f3 100644 --- a/core/portmanager.lua +++ b/core/portmanager.lua @@ -103,7 +103,8 @@ local function activate(service_name) if not port_number then log("error", "Invalid port number specified for service '%s': %s", service_info.name, tostring(port)); elseif #active_services:search(nil, interface, port_number) > 0 then - log("error", "Multiple services configured to listen on the same port ([%s]:%d): %s, %s", interface, port, active_services:search(nil, interface, port)[1][1].service.name or "", service_name or ""); + log("error", "Multiple services configured to listen on the same port ([%s]:%d): %s, %s", interface, port, + active_services:search(nil, interface, port)[1][1].service.name or "", service_name or ""); else local err; -- Create SSL context for this service/port @@ -118,14 +119,16 @@ local function activate(service_name) global_ssl_config[interface], global_ssl_config[port]); if not ssl then - log("error", "Error binding encrypted port for %s: %s", service_info.name, error_to_friendly_message(service_name, port_number, err) or "unknown error"); + log("error", "Error binding encrypted port for %s: %s", service_info.name, + error_to_friendly_message(service_name, port_number, err) or "unknown error"); end end if not err then -- Start listening on interface+port local handler, err = server.addserver(interface, port_number, listener, mode, ssl); if not handler then - log("error", "Failed to open server port %d on %s, %s", port_number, interface, error_to_friendly_message(service_name, port_number, err)); + log("error", "Failed to open server port %d on %s, %s", port_number, interface, + error_to_friendly_message(service_name, port_number, err)); else table.insert(hooked_ports, "["..interface.."]:"..port_number); log("debug", "Added listening service %s to [%s]:%d", service_name, interface, port_number); @@ -138,7 +141,8 @@ local function activate(service_name) end end end - log("info", "Activated service '%s' on %s", service_name, #hooked_ports == 0 and "no ports" or table.concat(hooked_ports, ", ")); + log("info", "Activated service '%s' on %s", service_name, + #hooked_ports == 0 and "no ports" or table.concat(hooked_ports, ", ")); return true; end diff --git a/core/s2smanager.lua b/core/s2smanager.lua index a8d399d2..d84572f3 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -70,7 +70,9 @@ end local function destroy_session(session, reason) if session.destroyed then return; end - (session.log or log)("debug", "Destroying "..tostring(session.direction).." session "..tostring(session.from_host).."->"..tostring(session.to_host)..(reason and (": "..reason) or "")); + (session.log or log)("debug", "Destroying "..tostring(session.direction) + .." session "..tostring(session.from_host).."->"..tostring(session.to_host) + ..(reason and (": "..reason) or "")); if session.direction == "outgoing" then hosts[session.from_host].s2sout[session.to_host] = nil; diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index 75e54b4f..c5b08098 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -76,7 +76,10 @@ local function retire_session(session) end local function destroy_session(session, err) - (session.log or log)("debug", "Destroying session for %s (%s@%s)%s", session.full_jid or "(unknown)", session.username or "(unknown)", session.host or "(unknown)", err and (": "..err) or ""); + (session.log or log)("debug", "Destroying session for %s (%s@%s)%s", + session.full_jid or "(unknown)", session.username or "(unknown)", + session.host or "(unknown)", err and (": "..err) or ""); + if session.destroyed then return; end -- Remove session/resource from user's session list diff --git a/core/stanza_router.lua b/core/stanza_router.lua index 228fed80..2312614c 100644 --- a/core/stanza_router.lua +++ b/core/stanza_router.lua @@ -38,7 +38,8 @@ local function handle_unhandled_stanza(host, origin, stanza) --luacheck: ignore if st_type == "error" or (name == "iq" and st_type == "result") then if st_type == "error" then local err_type, err_condition, err_message = stanza:get_error(); - log("debug", "Discarding unhandled error %s (%s, %s) from %s: %s", name, err_type, err_condition or "unknown condition", origin_type, stanza:top_tag()); + log("debug", "Discarding unhandled error %s (%s, %s) from %s: %s", + name, err_type, err_condition or "unknown condition", origin_type, stanza:top_tag()); else log("debug", "Discarding %s from %s of type: %s", name, origin_type, st_type or ''); end @@ -52,7 +53,8 @@ local function handle_unhandled_stanza(host, origin, stanza) --luacheck: ignore origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); end else - log("warn", "Unhandled %s stream element or stanza: %s; xmlns=%s: %s", origin_type, name, xmlns, tostring(stanza)); -- we didn't handle it + log("warn", "Unhandled %s stream element or stanza: %s; xmlns=%s: %s", + origin_type, name, xmlns, tostring(stanza)); -- we didn't handle it origin:close("unsupported-stanza-type"); end end @@ -211,12 +213,14 @@ function core_route_stanza(origin, stanza) else local xmlns = stanza.attr.xmlns; stanza.attr.xmlns = nil; - local routed = host_session.events.fire_event("route/remote", { origin = origin, stanza = stanza, from_host = from_host, to_host = host }); + local routed = host_session.events.fire_event("route/remote", { + origin = origin, stanza = stanza, from_host = from_host, to_host = host }); stanza.attr.xmlns = xmlns; -- reset if not routed then log("debug", "... no, just kidding."); if stanza.attr.type == "error" or (stanza.name == "iq" and stanza.attr.type == "result") then return; end - core_route_stanza(host_session, st.error_reply(stanza, "cancel", "not-allowed", "Communication with remote domains is not enabled")); + core_route_stanza(host_session, st.error_reply(stanza, "cancel", "not-allowed", + "Communication with remote domains is not enabled")); end end end diff --git a/core/storagemanager.lua b/core/storagemanager.lua index 319046b9..75cb8d0f 100644 --- a/core/storagemanager.lua +++ b/core/storagemanager.lua @@ -72,7 +72,8 @@ local function get_storage_config(host) end end if found_sql2 then - log("error", "The temporary 'sql2' storage module has now been renamed to 'sql', please update your config file: https://prosody.im/doc/modules/mod_storage_sql2"); + log("error", "The temporary 'sql2' storage module has now been renamed to 'sql', " + .."please update your config file: https://prosody.im/doc/modules/mod_storage_sql2"); end return storage_config; end @@ -180,7 +181,8 @@ local function purge(user, host) if driver.purge then purged[driver_name] = driver:purge(user); else - log("warn", "Storage driver %s does not support removing all user data, you may need to delete it manually", driver_name); + log("warn", "Storage driver %s does not support removing all user data, " + .."you may need to delete it manually", driver_name); end end end -- cgit v1.2.3 From e45c5961ac42007aa6c9282afddff91cd1e27124 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 4 Mar 2017 20:09:28 +0100 Subject: core: Allow select core modules to mutate some globals (needs luacheck 1.19) --- core/loggingmanager.lua | 2 +- core/rostermanager.lua | 2 +- core/sessionmanager.lua | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/loggingmanager.lua b/core/loggingmanager.lua index e3a83817..14305588 100644 --- a/core/loggingmanager.lua +++ b/core/loggingmanager.lua @@ -5,7 +5,7 @@ -- This project is MIT/X11 licensed. Please see the -- COPYING file in the source package for more information. -- - +-- luacheck: globals log prosody.log local format = string.format; local setmetatable, rawset, pairs, ipairs, type = diff --git a/core/rostermanager.lua b/core/rostermanager.lua index 88bd1e66..dc60ccdf 100644 --- a/core/rostermanager.lua +++ b/core/rostermanager.lua @@ -5,7 +5,7 @@ -- This project is MIT/X11 licensed. Please see the -- COPYING file in the source package for more information. -- - +-- luacheck: globals prosody.bare_sessions.?.roster diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index c5b08098..f7f36ae3 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -5,6 +5,7 @@ -- This project is MIT/X11 licensed. Please see the -- COPYING file in the source package for more information. -- +-- luacheck: globals prosody.full_sessions prosody.bare_sessions local tostring, setmetatable = tostring, setmetatable; local pairs, next= pairs, next; -- cgit v1.2.3