]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Fix issues found by the new luacheck version
authorVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 14 Apr 2022 19:50:12 +0000 (20:50 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 14 Apr 2022 19:50:12 +0000 (20:50 +0100)
lualib/lua_util.lua
lualib/plugins/neural.lua
lualib/rspamadm/fuzzy_stat.lua
lualib/rspamadm/statistics_dump.lua

index 6b28bbe1b5033f29aa28e0fafd6084a7336c23bb..6ade90e4b251e9bd6ae5f576bc99c56ab3760b98 100644 (file)
@@ -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
index 56c723ea550ef4eae0eeed3d77da1dec106d8ada..d2db2f519e2ee13a64ae82f94953d97afa352716 100644 (file)
@@ -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)
index 6417430b84c668d956756ed7f7d3059e6d60e088..38202be20798bdd3390a258104ae937a6330ccf0 100644 (file)
@@ -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
index 68b425aa850c3955075029827463b82c1d3b2e53..0ed921f6a739c752f8e8a15c6a533c0c57b96ffc 100644 (file)
@@ -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)