From: Vsevolod Stakhov Date: Thu, 14 Apr 2022 19:50:12 +0000 (+0100) Subject: [Minor] Fix issues found by the new luacheck version X-Git-Tag: 3.3~313 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=00c3dded42409c81ea6d8d3cda5804e949913f45;p=thirdparty%2Frspamd.git [Minor] Fix issues found by the new luacheck version --- diff --git a/lualib/lua_util.lua b/lualib/lua_util.lua index 6b28bbe1b5..6ade90e4b2 100644 --- a/lualib/lua_util.lua +++ b/lualib/lua_util.lua @@ -1378,7 +1378,7 @@ exports.toboolean = function(v) return false, string.format( 'cannot convert %q to boolean', v); end elseif type(v) == 'number' then - return (not (v == 0)) + return v ~= 0 else return false, string.format( 'cannot convert %q to boolean', v); end diff --git a/lualib/plugins/neural.lua b/lualib/plugins/neural.lua index 56c723ea55..d2db2f519e 100644 --- a/lualib/plugins/neural.lua +++ b/lualib/plugins/neural.lua @@ -368,10 +368,10 @@ end local function register_lock_extender(rule, set, ev_base, ann_key) rspamd_config:add_periodic(ev_base, 30.0, function() - local function redis_lock_extend_cb(_err, _) - if _err then + local function redis_lock_extend_cb(err, _) + if err then rspamd_logger.errx(rspamd_config, 'cannot lock ANN %s from redis: %s', - ann_key, _err) + ann_key, err) else rspamd_logger.infox(rspamd_config, 'extend lock for ANN %s for 30 seconds', ann_key) diff --git a/lualib/rspamadm/fuzzy_stat.lua b/lualib/rspamadm/fuzzy_stat.lua index 6417430b84..38202be207 100644 --- a/lualib/rspamadm/fuzzy_stat.lua +++ b/lualib/rspamadm/fuzzy_stat.lua @@ -69,7 +69,7 @@ local function print_stat(st, tabs) end -- Sort by checked -local function sort_ips(tbl, _opts) +local function sort_ips(tbl, sort_opts) local res = {} for k,v in pairs(tbl) do table.insert(res, {ip = k, data = v}) @@ -79,12 +79,12 @@ local function sort_ips(tbl, _opts) local key = 'checked' local _res = 0 - if _opts['sort'] then - if _opts['sort'] == 'matched' then + if sort_opts['sort'] then + if sort_opts['sort'] == 'matched' then key = 'matched' - elseif _opts['sort'] == 'errors' then + elseif sort_opts['sort'] == 'errors' then key = 'errors' - elseif _opts['sort'] == 'ip' then + elseif sort_opts['sort'] == 'ip' then return elt['ip'] end end diff --git a/lualib/rspamadm/statistics_dump.lua b/lualib/rspamadm/statistics_dump.lua index 68b425aa85..0ed921f6a7 100644 --- a/lualib/rspamadm/statistics_dump.lua +++ b/lualib/rspamadm/statistics_dump.lua @@ -285,7 +285,7 @@ local function dump_pattern(conn, pattern, opts, out, key) end -- Do not write the last chunk of out as it will be processed afterwards - if not cursor == 0 then + if cursor ~= 0 then if opts.cdb then dump_out(out, opts, false) clear_fcn(out)