Tarantool development patches archive
 help / color / mirror / Atom feed
From: Igor Munkin <imun@tarantool.org>
To: sergeyb@tarantool.org
Cc: o.piskunov@tarantool.org, tarantool-patches@dev.tarantool.org,
	v.shpilevoy@tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v4 4/10] Fix luacheck warnings in src/lua/
Date: Thu, 23 Apr 2020 17:13:26 +0300	[thread overview]
Message-ID: <20200423141326.GB11314@tarantool.org> (raw)
In-Reply-To: <89f3b427d1ccf4a85fab38c30d5ea23497f3a709.1587476678.git.sergeyb@tarantool.org>

Sergey,

Thanks for the patch! I left several comments below, please consider
them.

On 21.04.20, sergeyb@tarantool.org wrote:
> From: Sergey Bronnikov <sergeyb@tarantool.org>
> 
> Closes #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            |  3 ++
>  src/lua/argparse.lua   |  6 ++--
>  src/lua/buffer.lua     |  4 +--
>  src/lua/clock.lua      |  2 +-
>  src/lua/crypto.lua     |  4 +--
>  src/lua/csv.lua        |  5 ++-
>  src/lua/digest.lua     |  2 +-
>  src/lua/env.lua        |  2 +-
>  src/lua/fiber.lua      |  4 +--
>  src/lua/fio.lua        | 25 +++++++-------
>  src/lua/help.lua       |  7 ++--
>  src/lua/httpc.lua      |  3 --
>  src/lua/init.lua       |  7 ++--
>  src/lua/msgpackffi.lua | 22 +++++--------
>  src/lua/socket.lua     | 65 ++++++++++++++++++-------------------
>  src/lua/string.lua     |  1 -
>  src/lua/swim.lua       | 10 +++---
>  src/lua/tap.lua        | 74 ++++++++++++++++++++----------------------
>  src/lua/trigger.lua    |  3 --
>  19 files changed, 117 insertions(+), 132 deletions(-)
> 
> diff --git a/.luacheckrc b/.luacheckrc
> index 0b7dc2dfe..60aedc842 100644
> --- a/.luacheckrc
> +++ b/.luacheckrc
> @@ -26,3 +26,6 @@ exclude_files = {
>  }
>  
>  files["extra/dist/tarantoolctl.in"] = {ignore = {"212/self", "122", "431"}}
> +files["src/lua/swim.lua"] = {ignore = {"431"}}
> +files["src/lua/fio.lua"] = {ignore = {"231"}}
> +files["src/lua/init.lua"] = {globals = {"dostring"}}

There are several "(W212) unused argument self" warnings for crypto.lua
(and other chunks like digest.lua, errno.lua, etc), but no corresponding
suppression in .luacheckrc like the one you added for tarantoolctl.in in
the previous patch.

Furthermore I see no reason to leave suppressions list unsorted.

> diff --git a/src/lua/argparse.lua b/src/lua/argparse.lua
> index faa0ae130..f58985425 100644
> --- a/src/lua/argparse.lua
> +++ b/src/lua/argparse.lua
> @@ -90,8 +90,8 @@ local function convert_parameter(name, convert_from, convert_to)
>      return convert_from
>  end
>  
> -local function parameters_parse(t_in, options)
> -    local t_out, t_in = {}, t_in or {}
> +local function parameters_parse(t__in, options)
> +    local t_out, t_in = {}, t__in or {}

Moved the related thread from v3 series review[1]:
| > > diff --git a/src/lua/argparse.lua b/src/lua/argparse.lua
| > > index faa0ae130..f58985425 100644
| > > --- a/src/lua/argparse.lua
| > > +++ b/src/lua/argparse.lua
| > > @@ -90,8 +90,8 @@ local function convert_parameter(name, convert_from, convert_to)
| > >      return convert_from
| > >  end
| > >
| > > -local function parameters_parse(t_in, options)
| > > -    local t_out, t_in = {}, t_in or {}
| > > +local function parameters_parse(t__in, options)
| > > +    local t_out, t_in = {}, t__in or {}
| >
| > I guess you can just give t__in a proper name, e.g. args, params, etc.
|
| Agree with you, replaced it with 'param'.
|

I see no corresponding changes in v4.

>  
>      -- Prepare a lookup table for options. An option name -> a
>      -- type name to convert a parameter into or true (which means

<snipped>

> diff --git a/src/lua/fio.lua b/src/lua/fio.lua
> index 83fddaa0a..b2b4b4c77 100644
> --- a/src/lua/fio.lua
> +++ b/src/lua/fio.lua

<snipped>

> @@ -407,20 +407,20 @@ fio.rmtree = function(path)
>      if type(path) ~= 'string' then
>          error("Usage: fio.rmtree(path)")
>      end
> -    local status, err
> +    local status

This was also mentioned in the v3 series review[2]:
| This value is unused (and the corresponding warning is reported).
| Consider the changes below:
|
| ================================================================================
|
| diff --git a/src/lua/fio.lua b/src/lua/fio.lua
| index b2b4b4c77..e271eccf6 100644
| --- a/src/lua/fio.lua
| +++ b/src/lua/fio.lua
| @@ -407,7 +407,6 @@ fio.rmtree = function(path)
|      if type(path) ~= 'string' then
|          error("Usage: fio.rmtree(path)")
|      end
| -    local status
|      path = fio.abspath(path)
|      local ls, err = fio.listdir(path)
|      if err ~= nil then
| @@ -427,7 +426,8 @@ fio.rmtree = function(path)
|              end
|          end
|      end
| -    status, err = fio.rmdir(path)
| +    local _
| +    _, err = fio.rmdir(path)
|      if err ~= nil then
|          return false, string.format("failed to remove %s: %s", path, err)
|      end
|
| ================================================================================

I see no reason to suppress it in the .luacheckrc instead of fixing a
single occurense.

>      path = fio.abspath(path)
>      local ls, err = fio.listdir(path)
>      if err ~= nil then
>          return nil, err
>      end
> -    for i, f in ipairs(ls) do
> +    for _, f in ipairs(ls) do
>          local tmppath = fio.pathjoin(path, f)
>          local st = fio.lstat(tmppath)
>          if st then
>              if st:is_dir() then
> -                st, err = fio.rmtree(tmppath)
> +                _, err = fio.rmtree(tmppath)
>              else
> -                st, err = fio.unlink(tmppath)
> +                _, err = fio.unlink(tmppath)
>              end
>              if err ~= nil  then
>                  return nil, err

<snipped>

> diff --git a/src/lua/help.lua b/src/lua/help.lua
> index 54ff1b5d0..1b822828b 100644
> --- a/src/lua/help.lua
> +++ b/src/lua/help.lua

<snipped>

> @@ -22,7 +19,7 @@ setmetatable(help, { __call = help_call })
>  
>  local screen_id = 1;
>  
> -local function tutorial_call(table, action)
> +local function tutorial_call(action)

This change breaks the behaviour. Consider the following:
| $ ./src/tarantool
| Tarantool 2.4.0-192-g89f3b427d
| type 'help' for interactive help
| tarantool> tutorial('start')
| ---
| - error: 'builtin/help.lua:32: Usage: tutorial("start" | "next" | "prev" | 1 .. 20)'
| ...
|
| tarantool> getmetatable(tutorial).__call('start')
| ---
| - |
|   Tutorial -- Screen #1 -- Hello, Moon
|   ====================================
|
|   Welcome to the Tarantool tutorial.
|   It will introduce you to Tarantool’s Lua application server
|   and database server, which is what’s running what you’re seeing.
|   This is INTERACTIVE -- you’re expected to enter requests
|   based on the suggestions or examples in the screen’s text.
|
|   The first request is:
|
|   5.1, "Olá", "Lua"
|   ------------------
|
|   This isn’t your grandfather’s "Hello World" ...
|   the decimal literal 5.1 and the two strings inside
|   single quotes ("Hello Moon" in Portuguese) will just
|   be repeated, without need for a print() statement.
|
|   Take that one-line request and enter it below after the
|   "tarantool>" prompt, then type Enter.
|   You’ll see the response:
|   ---
|   - 5.1
|   - Olá
|   - Lua
|   ...
|   Then you’ll get a chance to repeat -- perhaps entering
|   something else such as "Longer String",-1,-3,0.
|   When you’re ready to go to the next screen, enter <tutorial("next")>.
| ...
|
| tarantool>

Long story short: table arg is similar to self here (see more here[3])
and cannot be simply dropped. Nevertheless it looks more convenient to
replace it with self.

I guess it would be nice to add a test for it (or at least file a
follow-up issue requesting the test).

>      if action == 'start' then
>          screen_id = 1;
>      elseif action == 'next' or action == 'more' then

<snipped>

> -- 
> 2.23.0
> 

[1]: https://lists.tarantool.org/pipermail/tarantool-patches/2020-April/016113.html
[2]: https://lists.tarantool.org/pipermail/tarantool-patches/2020-April/016022.html
[3]: https://www.lua.org/manual/5.1/manual.html#2.8

-- 
Best regards,
IM

  reply	other threads:[~2020-04-23 14:20 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21 14:00 [Tarantool-patches] [PATCH v4 0/10] Add static analysis with luacheck sergeyb
2020-04-21 14:00 ` [Tarantool-patches] [PATCH v4 1/10] Add initial luacheck config sergeyb
2020-04-21 14:00 ` [Tarantool-patches] [PATCH v4 2/10] gitlab-ci: enable static analysis with luacheck sergeyb
2020-04-21 20:04   ` Alexander Tikhonov
2020-04-22  8:09     ` Sergey Bronnikov
2020-04-22  8:11     ` Kirill Yukhin
2020-04-21 14:00 ` [Tarantool-patches] [PATCH v4 3/10] Fix luacheck warnings in extra/dist/tarantoolctl.in sergeyb
2020-04-23 11:40   ` Igor Munkin
2020-04-24  8:02     ` Sergey Bronnikov
2020-04-21 14:00 ` [Tarantool-patches] [PATCH v4 4/10] Fix luacheck warnings in src/lua/ sergeyb
2020-04-23 14:13   ` Igor Munkin [this message]
2020-04-24  9:12     ` Sergey Bronnikov
2020-04-21 14:00 ` [Tarantool-patches] [PATCH v4 5/10] Fix luacheck warnings in src/box/lua/ sergeyb
2020-04-23 22:54   ` Igor Munkin
2020-05-07 10:32     ` Sergey Bronnikov
2020-05-07 14:34       ` Sergey Bronnikov
2020-05-07 10:52     ` Sergey Bronnikov
2020-04-21 14:00 ` [Tarantool-patches] [PATCH v4 6/10] Fix luacheck warnings in test/ sergeyb
2020-04-27 14:38   ` Igor Munkin
2020-05-06 16:16     ` Sergey Bronnikov
2020-04-21 14:00 ` [Tarantool-patches] [PATCH v4 7/10] schema: fix index promotion to functional index sergeyb
2020-04-23 23:24   ` Igor Munkin
2020-04-23 23:29     ` Igor Munkin
2020-04-28 23:19       ` Vladislav Shpilevoy
2020-04-21 14:00 ` [Tarantool-patches] [PATCH v4 8/10] schema: fix internal symbols dangling in _G sergeyb
2020-04-21 14:13   ` Oleg Babin
2020-04-21 14:45     ` Sergey Bronnikov
2020-04-21 19:52   ` Igor Munkin
2020-04-23 23:27     ` Igor Munkin
2020-04-28 23:19       ` Vladislav Shpilevoy
2020-04-21 14:00 ` [Tarantool-patches] [PATCH v4 9/10] Disabled test/luajit-tap in luacheckrc sergeyb
2020-04-24 10:16   ` Igor Munkin
2020-04-29 14:25     ` Sergey Bronnikov
2020-04-21 14:00 ` [Tarantool-patches] [PATCH v4 10/10] luajit: Fix warnings spotted by luacheck sergeyb
2020-04-21 19:33   ` Igor Munkin
2020-04-22 10:14     ` Sergey Bronnikov
2020-04-23  6:24   ` Sergey Bronnikov
2020-04-23 10:03     ` Igor Munkin
2020-04-23 10:30       ` Sergey Bronnikov

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=20200423141326.GB11314@tarantool.org \
    --to=imun@tarantool.org \
    --cc=o.piskunov@tarantool.org \
    --cc=sergeyb@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v4 4/10] Fix luacheck warnings in src/lua/' \
    /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