Tarantool development patches archive
 help / color / mirror / Atom feed
From: sergeyb@tarantool.org
To: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org,
	imun@tarantool.org
Cc: o.piskunov@tarantool.org, alexander.turenko@tarantool.org
Subject: [Tarantool-patches] [PATCH v6 04/25] Fix luacheck warnings in extra/dist/tarantoolctl.in
Date: Fri, 29 May 2020 18:09:00 +0300	[thread overview]
Message-ID: <50e54317a46f453af5ae834e507a3b8fbc02be06.1590764167.git.sergeyb@tarantool.org> (raw)
In-Reply-To: <cover.1590764167.git.sergeyb@tarantool.org>

From: Sergey Bronnikov <sergeyb@tarantool.org>

Part of #4681

Reviewed-by: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Reviewed-by: Igor Munkin <imun@tarantool.org>

Co-authored-by: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Co-authored-by: Igor Munkin <imun@tarantool.org>
---
 .luacheckrc                |  5 +++++
 extra/dist/tarantoolctl.in | 33 +++++++++++----------------------
 2 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/.luacheckrc b/.luacheckrc
index 81596e145..e10d73476 100644
--- a/.luacheckrc
+++ b/.luacheckrc
@@ -23,3 +23,8 @@ exclude_files = {
     ".rocks/**/*.lua",
     ".git/**/*.lua",
 }
+
+files["extra/dist/tarantoolctl.in"] = {
+    globals = {"box", "_TARANTOOL"},
+    ignore = {"212/self", "122", "431"}
+}
diff --git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in
index a98c61b52..1514f0037 100755
--- a/extra/dist/tarantoolctl.in
+++ b/extra/dist/tarantoolctl.in
@@ -63,13 +63,12 @@ end
 
 local function check_user_level()
     local uid = os.getenv('UID')
-    local udir = nil
     if uid == 0 or os.getenv("NOTIFY_SOCKET") then
         return nil
     end
     -- local dir configuration
     local pwd = os.getenv('PWD')
-    udir = pwd and pwd .. '/.tarantoolctl'
+    local udir = pwd and pwd .. '/.tarantoolctl'
     udir = udir and fio.stat(udir) and udir or nil
     -- or home dir configuration
     local homedir = os.getenv('HOME')
@@ -126,15 +125,15 @@ end
 local function load_default_file(default_file)
     if default_file then
         local env = setmetatable({}, { __index = _G })
-        local ufunc, msg = loadfile(default_file)
+        local ufunc, loaderr = loadfile(default_file)
         -- if load fails - show the last 10 lines of the log file
         if not ufunc then
-            log.error("Failed to load defaults file: %s", msg)
+            log.error("Failed to load defaults file: %s", loaderr)
         end
         debug.setfenv(ufunc, env)
-        local state, msg = pcall(ufunc)
+        local state, err = pcall(ufunc)
         if not state then
-            log.error('Failed to execute defaults file: %s', msg)
+            log.error('Failed to execute defaults file: %s', err)
         end
         default_cfg = env.default_cfg
         instance_dir = env.instance_dir
@@ -789,7 +788,7 @@ end
 local function eval()
     local console_sock_path = uri.parse(console_sock).service
     local filename = arg[3]
-    local code = nil
+    local code
     if filename == nil then
         if stdin_isatty() then
             log.error("Usage:")
@@ -847,7 +846,6 @@ end
 -- xlog / snap file, so even when it stops on LSN >= @a opts.to on
 -- a current file a next file will be processed.
 local function filter_xlog(gen, param, state, opts, cb)
-    local spaces = opts.spaces
     local from, to, spaces = opts.from, opts.to, opts.space
     local show_system, replicas = opts['show-system'], opts.replica
 
@@ -861,7 +859,7 @@ local function filter_xlog(gen, param, state, opts, cb)
         elseif (lsn < from) or (lsn >= to) or
            (not spaces and sid and sid < 512 and not show_system) or
            (spaces and (sid == nil or not find_in_list(sid, spaces))) or
-           (replicas and not find_in_list(rid, replicas)) then
+           (replicas and not find_in_list(rid, replicas)) then -- luacheck: ignore
             -- pass this tuple
         else
             cb(record)
@@ -874,7 +872,7 @@ local function cat()
     local cat_format = opts.format
     local format_cb = cat_formats[cat_format]
     local is_printed = false
-    for id, file in ipairs(positional_arguments) do
+    for _, file in ipairs(positional_arguments) do
         log.error("Processing file '%s'", file)
         local gen, param, state = xlog.pairs(file)
         filter_xlog(gen, param, state, opts, function(record)
@@ -900,7 +898,7 @@ local function play()
     if not remote:wait_connected() then
         error(("Error while connecting to host '%s'"):format(uri))
     end
-    for id, file in ipairs(positional_arguments) do
+    for _, file in ipairs(positional_arguments) do
         log.info(("Processing file '%s'"):format(file))
         local gen, param, state = xlog.pairs(file)
         filter_xlog(gen, param, state, opts, function(record)
@@ -921,22 +919,13 @@ local function play()
     remote:close()
 end
 
-local function find_arg(name_arg)
-    for i, key in ipairs(arg) do
-        if key:find(name_arg) ~= nil then
-            return key
-        end
-    end
-    return nil
-end
-
 local function rocks()
     local cfg = require("luarocks.core.cfg")
     cfg.init()
     local util = require("luarocks.util")
     local command_line = require("luarocks.cmd")
     -- Tweak help messages
-    util.see_help = function(command, program)
+    util.see_help = function()
         -- TODO: print extended help message here
         return "See Tarantool documentation for help."
     end
@@ -1215,7 +1204,7 @@ local function usage_command(name, cmd)
     if type(header) == 'string' then
         header = { header }
     end
-    for no, line in ipairs(header) do
+    for _, line in ipairs(header) do
         log.error("    " .. line, name)
     end
 end
-- 
2.23.0

  parent reply	other threads:[~2020-05-29 15:12 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-29 15:08 [Tarantool-patches] [PATCH v6 00/25] Add static analysis with luacheck sergeyb
2020-05-29 15:08 ` [Tarantool-patches] [PATCH v6 01/25] Add initial luacheck config sergeyb
2020-05-29 16:04   ` Igor Munkin
2020-05-29 16:27     ` Igor Munkin
2020-05-30 12:19       ` Sergey Bronnikov
2020-05-30 12:18     ` Sergey Bronnikov
2020-05-29 15:08 ` [Tarantool-patches] [PATCH v6 02/25] build: enable 'make luacheck' target sergeyb
2020-05-29 16:28   ` Igor Munkin
2020-05-29 15:08 ` [Tarantool-patches] [PATCH v6 03/25] gitlab-ci: enable static analysis with luacheck sergeyb
2020-05-29 19:25   ` Igor Munkin
2020-06-01  9:29     ` Sergey Bronnikov
2020-06-01  9:48       ` Igor Munkin
2020-05-29 15:09 ` sergeyb [this message]
2020-05-29 16:35   ` [Tarantool-patches] [PATCH v6 04/25] Fix luacheck warnings in extra/dist/tarantoolctl.in Igor Munkin
2020-06-01 14:10   ` Alexander Turenko
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 05/25] Fix luacheck warnings in src/lua/ sergeyb
2020-05-29 16:51   ` Igor Munkin
2020-05-29 19:13     ` Igor Munkin
2020-05-30 12:15       ` Sergey Bronnikov
2020-06-01  9:43         ` Igor Munkin
2020-06-01 10:36           ` Sergey Bronnikov
2020-06-01  9:38     ` Sergey Bronnikov
2020-06-01 14:47   ` Alexander Turenko
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 06/25] Fix luacheck warnings in src/box/lua/ sergeyb
2020-05-29 19:11   ` Igor Munkin
2020-05-30 12:22     ` Sergey Bronnikov
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 07/25] Supress luacheck warnings in test/app sergeyb
2020-06-01 10:11   ` Igor Munkin
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 08/25] Fix luacheck warnings in test/app-tap sergeyb
2020-06-01 11:41   ` Igor Munkin
2020-07-16 11:44     ` Sergey Bronnikov
2020-07-16 12:42       ` Igor Munkin
2020-07-16 13:25         ` Sergey Bronnikov
2020-06-01 13:37   ` Alexander Turenko
2020-06-01 16:37     ` Igor Munkin
2020-06-01 17:13       ` Alexander Turenko
2020-06-01 17:38         ` Igor Munkin
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 09/25] Fix luacheck warnings in test/box sergeyb
2020-06-01 16:06   ` Igor Munkin
2020-07-16 13:23     ` Sergey Bronnikov
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 10/25] Fix luacheck warnings in test/box-py sergeyb
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 11/25] Fix luacheck warnings in test/box-tap sergeyb
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 12/25] Fix luacheck warnings in test/engine sergeyb
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 13/25] Fix luacheck warnings in test/engine_long sergeyb
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 14/25] Fix luacheck warnings in test/long_run-py sergeyb
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 15/25] Fix luacheck warnings in test/replication sergeyb
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 16/25] Fix luacheck warnings in test/replication-py sergeyb
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 17/25] Fix luacheck warnings in test/sql sergeyb
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 18/25] Fix luacheck warnings in test/sql-tap sergeyb
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 19/25] Fix luacheck warnings in test/swim sergeyb
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 20/25] Fix luacheck warnings in test/vinyl sergeyb
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 21/25] Fix luacheck warnings in test/wal_off sergeyb
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 22/25] Fix luacheck warnings in test/xlog sergeyb
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 23/25] Fix luacheck warnings in test/xlog-py sergeyb
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 24/25] Add luacheck supressions for luajit tests sergeyb
2020-05-29 15:09 ` [Tarantool-patches] [PATCH v6 25/25] luajit: bump new version sergeyb
2020-06-01 17:08 ` [Tarantool-patches] [PATCH v6 00/25] Add static analysis with luacheck Vladislav Shpilevoy
2020-06-01 17:29   ` Alexander Turenko
2020-06-01 18:13     ` Igor Munkin
2020-06-02 14:42 ` Alexander Turenko
2020-06-02 15:58   ` Igor Munkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50e54317a46f453af5ae834e507a3b8fbc02be06.1590764167.git.sergeyb@tarantool.org \
    --to=sergeyb@tarantool.org \
    --cc=alexander.turenko@tarantool.org \
    --cc=imun@tarantool.org \
    --cc=o.piskunov@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v6 04/25] Fix luacheck warnings in extra/dist/tarantoolctl.in' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox