commit 00c3dde: [Minor] Fix issues found by the new luacheck version

Vsevolod Stakhov vsevolod at rspamd.com
Thu Apr 14 20:00:03 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-04-14 20:50:12 +0100
URL: https://github.com/rspamd/rspamd/commit/00c3dded42409c81ea6d8d3cda5804e949913f45

[Minor] Fix issues found by the new luacheck version

---
 lualib/lua_util.lua                 |  2 +-
 lualib/plugins/neural.lua           |  6 +++---
 lualib/rspamadm/fuzzy_stat.lua      | 10 +++++-----
 lualib/rspamadm/statistics_dump.lua |  2 +-
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lualib/lua_util.lua b/lualib/lua_util.lua
index 6b28bbe1b..6ade90e4b 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 56c723ea5..d2db2f519 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 6417430b8..38202be20 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 68b425aa8..0ed921f6a 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)


More information about the Commits mailing list