From: Igor Munkin <imun@tarantool.org> To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Cc: tarantool-patches@dev.tarantool.org, alexander.turenko@tarantool.org Subject: Re: [Tarantool-patches] [PATCH 5/6] Fix luacheck warnings in src/lua/ Date: Thu, 11 Jun 2020 20:22:39 +0300 [thread overview] Message-ID: <20200611172239.GT5745@tarantool.org> (raw) In-Reply-To: <1d6128a1-127e-8f27-b937-c88219b3f53f@tarantool.org> Vlad, Thanks for your review! On 06.06.20, Vladislav Shpilevoy wrote: > Thanks for the patch! > <snipped> > > diff --git a/.luacheckrc b/.luacheckrc > > index b917eb927..fb8b9dfb3 100644 > > --- a/.luacheckrc > > +++ b/.luacheckrc > > @@ -1,9 +1,14 @@ > > std = "luajit" > > globals = {"box", "_TARANTOOL"} > > ignore = { > > - "212/self", -- Unused argument <self>. > > - "411", -- Redefining a local variable. > > - "431", -- Shadowing an upvalue. > > + "143/debug", -- Accessing an undefined field of a global variable <debug>. > > 1. Why are global variables ignored sometimes using '143/<name>', sometimes > via adding to the global 'globals', sometimes via the per-file 'globals'? > 'debug', 'string', and 'table' are globals, available in all the sources, > just like 'box'. Historically, someone desided to spoil default Lua namespaces with user-defined functions and auxiliary extensions. Thereby luacheck reports about non-standart key lookups in these namespaces. There is nothing bad in using these namespaces, so only this type of warnings is suppressed for them. On the other hand, such globals ad <box>, <_TARANTOOL>, and <tonumber64> are Tarantool specific ones and it was decided to suppress them globally since their usage is OK as well as <string>, <_VERSION> and <tonumber> names provided by Lua. > <snipped> > > > +}> +files["src/lua/init.lua"] = { > > + globals = {"dostring"}, -- miscellaneous global function definition. > > + ignore = { > > + "122/os", -- set tarantool specific behaviour for os.exit. > > + "142/package", -- add custom functions into Lua package namespace. > > 4. os and package changes can be done using rawset() function. It does not > produce a warning, and behaves in the above cases the same. However this > should be consulted with other reviewers. > > Another option - add 'os' and 'package' to the list of globals. It also fixes > the warnings. The issue is similar to the '143/string' suppression: several default Lua namespaces need to be (re)defined and it's a single "violation" reported by luacheck. So we can either fix it the way you proposed above (but it look less readable for me), or just suppress it for this file. Suppressing it globally relaxes the already not strict checks. > <snipped> > > > + }, > > +} > > +files["src/lua/swim.lua"] = { > > + ignore = { > > + "212/m", -- respect swim module code style. > > 5. Once again I wonder why do we ignore unused arguments sometimes globaly in > 'ignore = {...}', sometimes per-file like here, sometimes using inlined luacheck > comments. > > In this particular case there is even a fourth option - rename 'm' to 'self' in > the single problematic line. Like you did for many similar places. I just wanted to save the code style for the whole swim source file and totally OK with such renaming if it doesn't bothers you. > <snipped> > > @@ -1319,7 +1319,7 @@ local function lsocket_tcp_getpeername(self) > > return peer.host, tostring(peer.port), peer.family:match("AF_(.*)"):lower() > > end > > > > -local function lsocket_tcp_settimeout(self, value, mode) > > +local function lsocket_tcp_settimeout(self, value, mode) -- luacheck: no unused args > > 10. Mode is really ignored, and this is not some kind of built-in > function with 'fixed' signature. And it is not used 'virtually', > when there is a variable keeping pointer at one function among > many having the same signature. So what is a purpose of keeping it? This *is* a function with the fixed signature[1], since this method emulates LuaSocket API. This is the reason why the mode argument is left. > <snipped> [1]: http://w3.impa.br/~diego/software/luasocket/tcp.html#settimeout -- Best regards, IM
next prev parent reply other threads:[~2020-06-11 17:31 UTC|newest] Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-04 8:39 [Tarantool-patches] [PATCH 0/6] Add static analysis of Lua code in src/ and extra/ with luacheck sergeyb 2020-06-04 8:39 ` [Tarantool-patches] [PATCH 1/6] Add initial luacheck config sergeyb 2020-06-06 18:02 ` Vladislav Shpilevoy 2020-06-09 16:16 ` Sergey Bronnikov 2020-06-04 8:39 ` [Tarantool-patches] [PATCH 2/6] build: enable 'make luacheck' target sergeyb 2020-06-04 8:39 ` [Tarantool-patches] [PATCH 3/6] gitlab-ci: enable static analysis with luacheck sergeyb 2020-06-04 8:39 ` [Tarantool-patches] [PATCH 4/6] Fix luacheck warnings in extra/dist/ sergeyb 2020-06-06 18:02 ` Vladislav Shpilevoy 2020-06-09 16:17 ` Sergey Bronnikov 2020-06-19 23:15 ` Vladislav Shpilevoy 2020-07-05 16:28 ` Vladislav Shpilevoy 2020-07-12 15:37 ` Vladislav Shpilevoy 2020-07-13 10:01 ` Sergey Bronnikov 2020-06-04 8:39 ` [Tarantool-patches] [PATCH 5/6] Fix luacheck warnings in src/lua/ sergeyb 2020-06-06 18:03 ` Vladislav Shpilevoy 2020-06-11 12:00 ` Sergey Bronnikov 2020-06-11 19:52 ` Vladislav Shpilevoy 2020-06-18 9:32 ` Sergey Bronnikov 2020-06-18 9:35 ` Sergey Bronnikov 2020-06-11 17:22 ` Igor Munkin [this message] 2020-07-05 16:28 ` Vladislav Shpilevoy 2020-07-10 16:55 ` Sergey Bronnikov 2020-07-12 15:37 ` Vladislav Shpilevoy 2020-07-13 9:51 ` Sergey Bronnikov 2020-07-13 22:59 ` Vladislav Shpilevoy 2020-06-04 8:39 ` [Tarantool-patches] [PATCH 6/6] Fix luacheck warnings in src/box/lua/ sergeyb 2020-06-06 18:03 ` Vladislav Shpilevoy 2020-06-11 12:01 ` Sergey Bronnikov 2020-06-18 9:37 ` Sergey Bronnikov 2020-06-19 23:15 ` Vladislav Shpilevoy 2020-07-01 14:02 ` Sergey Bronnikov 2020-07-13 22:59 ` Vladislav Shpilevoy 2020-07-14 10:54 ` Sergey Bronnikov 2020-07-14 11:24 ` Sergey Bronnikov 2020-06-04 8:43 ` [Tarantool-patches] [PATCH 0/6] Add static analysis of Lua code in src/ and extra/ with luacheck Sergey Bronnikov 2020-06-19 23:15 ` Vladislav Shpilevoy 2020-07-13 9:53 ` Sergey Bronnikov 2020-06-04 9:04 ` Igor Munkin 2020-06-04 11:17 ` Sergey Bronnikov 2020-07-14 22:49 ` Vladislav Shpilevoy 2020-07-15 9:51 ` Kirill Yukhin
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=20200611172239.GT5745@tarantool.org \ --to=imun@tarantool.org \ --cc=alexander.turenko@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 5/6] 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