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

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Tue Mar 2 00:27:42 MSK 2021


> --- 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.

That is hardly possible. We have Lua calls not saved into anything.
For instance, grep fiber.name(...) calls.

I suspect it is because you left ["id"] thing after the call. Because
result of [] indeed makes no sense without being used.


More information about the Tarantool-patches mailing list