From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 87AD74C885; Tue, 12 Jan 2021 18:21:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 87AD74C885 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1610464915; bh=vCL/5LM8ZWuOwH+q9gGXPv3v4qilHdnP0cuQkGSP178=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=g/nN+kjk+x/tiHk+ml2urkSJvBXmHPJcD8+X2hcLAf8mMpGG/k4ObYfVEITH8xnsb Zv+ZYyxpYz8v+2oOIlGQXzgw5u6iI3rUdZYMiEwV1tdApVDHbrvkK/m5G86WpfRXSt Ir5h2w8THymQDgbn6n4GyfjKpk4qfE7W3bcQpi9A= Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id CCAC64C885 for ; Tue, 12 Jan 2021 18:21:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CCAC64C885 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1kzLUX-00079Y-U1; Tue, 12 Jan 2021 18:21:54 +0300 To: Vladislav Shpilevoy , tarantool-patches@dev.tarantool.org, lvasiliev@tarantool.org References: <4f8d3525-ad8d-5c2a-429d-b87dc8ceb443@tarantool.org> <7fd3e42f-047b-e404-f481-689eb73acb8b@tarantool.org> Message-ID: <30f3c9eb-7eab-0a15-c8e4-bdfe27d5434e@tarantool.org> Date: Tue, 12 Jan 2021 18:21:53 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9D0E79FBC973162CD3008320BFA2F4C653BABCE9B72A1DEA600894C459B0CD1B9F7DC9E18BEA7CF019122441CC94DC4FD18E069D5E61AA5324C00A71A96C76CBF X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE78AC0750F3304E924EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006370BEBC60587DC626C8638F802B75D45FF5571747095F342E8C7A0BC55FA0FE5FCE681CCE15D286DCB7E55C9A6E807FB4FA203B379F9EFF02B389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C0998E19D2343267C68941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6D082881546D93491CC7F00164DA146DA6F5DAA56C3B73B23C77107234E2CFBA567F23339F89546C55F5C1EE8F4F765FC36BDB105DB14A96875ECD9A6C639B01BBD4B6F7A4D31EC0BC0CAF46E325F83A522CA9DD8327EE4930A3850AC1BE2E7353946EFC6A664F553C4224003CC836476C0CAF46E325F83A50BF2EBBBDD9D6B0F5D41B9178041F3E72623479134186CDE6BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A52F9B50E4129968FAD8088F6B0CB6F4AAFFF2713DDA0AE6CED59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75448CF9D3A7B2C848410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34EA882B598A2098114EB3E6938DE3B3D94813881669BA508269B9A3FD48753C2C91A3962E6E439FEF1D7E09C32AA3244CDB9B87DF5CDAC3DF3722DE9B340F587733C9DC155518937FFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojKc4NKhtl7uEtGgD/MWgKzQ== X-Mailru-Sender: 689FA8AB762F73937240DDB2502DDB70AEE65F7D8D2E7C09E259202BEB7CD17EDD788429FD8613638ED9BB8B05EE7B3AFB559BB5D741EB96D19CD4E7312BAA970A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v7 3/3] luacheck: fix warnings in test/box-tap X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On 12.01.2021 17:52, Vladislav Shpilevoy wrote: > On 12.01.2021 14:59, Sergey Bronnikov wrote: >> Thanks for review! >> >> On 11.01.2021 20:52, Vladislav Shpilevoy wrote: >>> Thanks for the patch! >>> >>>> diff --git a/.luacheckrc b/.luacheckrc >>>> index 52625bb35..b7f9abb45 100644 >>>> --- a/.luacheckrc >>>> +++ b/.luacheckrc >>>> @@ -157,3 +156,23 @@ files["test/box/lua/fifo.lua"] = { >>>>   files["test/box/lua/identifier.lua"] = { >>>>        globals = {"run_test"} >>>>   } >>>> +files["test/box-tap/session.test.lua"] = { >>>> +    globals = { >>>> +        "active_connections", >>> This can be declared 'local'. >> and with removed a single suppression in .luacheckrc we have got another warnings, >> >> that should be suppressed too (inline or in luacheckrc): >> >> Checking test/box-tap/session.test.lua            4 warnings >> >>     test/box-tap/session.test.lua:73:22: setting non-standard global variable active_connections >>     test/box-tap/session.test.lua:73:43: accessing undefined variable active_connections >>     test/box-tap/session.test.lua:74:22: setting non-standard global variable active_connections >>     test/box-tap/session.test.lua:74:43: accessing undefined variable active_connections >> >> I think it is better to keep it as is. > It seems you didn't bother with applying my diff from the previous > email, did you? I kept it below: You are right, missed that active_connections must be moved above. Now luacheck is green. > >>> ==================== >>> @@ -70,6 +70,7 @@ session.on_disconnect(nil, fail) >>>     -- check how connect/disconnect triggers work >>>   local peer_name = "peer_name" >>> +local active_connections = 0 >>>   local function inc() active_connections = active_connections + 1 end >>>   local function dec() active_connections = active_connections - 1 end >>>   local function peer() peer_name = box.session.peer() end >>> @@ -77,7 +78,6 @@ local net = { box = require('net.box') } >>>   test:is(type(session.on_connect(inc)), "function", "type of trigger inc on_connect") >>>   test:is(type(session.on_disconnect(dec)), "function", "type of trigger dec on_disconnect") >>>   test:is(type(session.on_disconnect(peer)), "function", "type of trigger peer on_disconnect") >>> -active_connections = 0 >>>   local c = net.box.connect(HOST, PORT) >>> ==================== > I will paste here the full diff now, with the line removed from > .luacheck: > > ==================== > diff --git a/.luacheckrc b/.luacheckrc > index b7f9abb45..6043722f4 100644 > --- a/.luacheckrc > +++ b/.luacheckrc > @@ -158,7 +158,6 @@ files["test/box/lua/identifier.lua"] = { > } > files["test/box-tap/session.test.lua"] = { > globals = { > - "active_connections", > "session", > "space", > "f1", > diff --git a/test/box-tap/session.test.lua b/test/box-tap/session.test.lua > index 160f047bc..3dd159ebb 100755 > --- a/test/box-tap/session.test.lua > +++ b/test/box-tap/session.test.lua > @@ -70,6 +70,7 @@ session.on_disconnect(nil, fail) > > -- check how connect/disconnect triggers work > local peer_name = "peer_name" > +local active_connections = 0 > local function inc() active_connections = active_connections + 1 end > local function dec() active_connections = active_connections - 1 end > local function peer() peer_name = box.session.peer() end > @@ -77,7 +78,6 @@ local net = { box = require('net.box') } > test:is(type(session.on_connect(inc)), "function", "type of trigger inc on_connect") > test:is(type(session.on_disconnect(dec)), "function", "type of trigger dec on_disconnect") > test:is(type(session.on_disconnect(peer)), "function", "type of trigger peer on_disconnect") > -active_connections = 0 > local c = net.box.connect(HOST, PORT) > ==================== > > You can copy-paste it into a file and use `git apply` to repeat > it exactly. From the errors you have shown above it looks like > you didn't move the declaration above its usages (I tried it and > got the same errors, of course). You just added 'local', and didn't > try to move it. > > With this diff I run luacheck command and get 0 errors/warnings. > > ==================== > $ ./.rocks/bin/luacheck --codes --config .luacheckrc test/box-tap/session.test.lua > Checking test/box-tap/session.test.lua OK > > Total: 0 warnings / 0 errors in 1 file > ====================