[Tarantool-patches] [PATCH v8 04/14] test: fix luacheck warnings W211 in test/sql-tap

Sergey Bronnikov sergeyb at tarantool.org
Mon Mar 1 16:46:03 MSK 2021


Hello!

On 28.02.2021 18:30, Vladislav Shpilevoy wrote:
> Thanks for the fixes!
>
>> --- a/test/sql-tap/select9.test.lua
>> +++ b/test/sql-tap/select9.test.lua
>> @@ -274,10 +274,8 @@ test:do_execsql_test(
>>           -- </select9-2.0>
>>       })
>>
>> -local t1_space_id = ""
>> -local t2_space_id = ""
>> -t1_space_id = test:execsql([[SELECT * from "_space" where "name"='T1']])["id"]
>> -t2_space_id = test:execsql([[SELECT * from "_space" where "name"='T2']])["id"]
>> +local _ = test:execsql([[SELECT * from "_space" where "name"='T1']])["id"]
>> +local _ = test:execsql([[SELECT * from "_space" where "name"='T2']])["id"]
> But nothing changed. It was the same before my comment. By 'delete' them I
> mean literally 'delete'. SELECTs don't have any effect unlike DML/DDL. You
> can remove them and nothing will change.
>
> ====================

It was a misunderstanding. Removed it now.

--- a/test/sql-tap/select9.test.lua
+++ b/test/sql-tap/select9.test.lua
@@ -274,8 +274,6 @@ test:do_execsql_test(
          -- </select9-2.0>
      })

-local _ = test:execsql([[SELECT * from "_space" where "name"='T1']])["id"]
-local _ = test:execsql([[SELECT * from "_space" where "name"='T2']])["id"]
  --X(276, "X!cmd", [=[["db","eval","SELECT * from _space where 
name='t2'","data","\n  set t2_space_id $data(id)\n"]]=])
  --local function reverse(lhs, rhs)
  --    return X(283, "X!cmd", [=[["string","compare",["rhs"],["lhs"]]]=])

>       })
>   
> -local _ = test:execsql([[SELECT * from "_space" where "name"='T1']])["id"]
> -local _ = test:execsql([[SELECT * from "_space" where "name"='T2']])["id"]
>   --X(276, "X!cmd", [=[["db","eval","SELECT * from _space where name='t2'","data","\n  set t2_space_id $data(id)\n"]]=])
> ====================
>
> However even if we would would to keep them you wouldn't need `local _ = `.
> You can call functions without saving their result into a variable.

luacheck reports an error when result of function is not assigned to 
variable.

With patch:

--- a/test/sql-tap/select9.test.lua
+++ b/test/sql-tap/select9.test.lua
@@ -274,8 +274,7 @@ test:do_execsql_test(
          -- </select9-2.0>
      })

-local _ = test:execsql([[SELECT * from "_space" where "name"='T1']])["id"]
-local _ = test:execsql([[SELECT * from "_space" where "name"='T2']])["id"]
+test:execsql([[SELECT * from "_space" where "name"='T1']])["id"]
  --X(276, "X!cmd", [=[["db","eval","SELECT * from _space where 
name='t2'","data","\n  set t2_space_id $data(id)\n"]]=])
  --local function reverse(lhs, rhs)
  --    return X(283, "X!cmd", [=[["string","compare",["rhs"],["lhs"]]]=])

it reports:

Checking test/sql-tap/select9.test.lua            1 error

     test/sql-tap/select9.test.lua:289:1: (E011) expected '=' near 
'iOuterLoop'

Total: 0 warnings / 1 error in 264 files


iOuterLoop is a variable on a next uncommented line. Seems Lua requires 
that function's result must be assigned to variable.



More information about the Tarantool-patches mailing list