[Tarantool-patches] [PATCH v7] test: fix luacheck warnings in test/long_run-py

sergeyb at tarantool.org sergeyb at tarantool.org
Wed Jan 13 17:35:17 MSK 2021


From: Sergey Bronnikov <sergeyb at tarantool.org>

Closes #5460

Reviewed-by: Vladislav Shpilevoy <v.shpilevoy at tarantool.org>
Reviewed-by: Igor Munkin <imun at tarantool.org>

Co-authored-by: Vladislav Shpilevoy <v.shpilevoy at tarantool.org>
Co-authored-by: Igor Munkin <imun at tarantool.org>
---

Changelog v7:

- updated an exclusion mask in .luacheckrc

Changelog v6:

- splitted patch in test/ for patches per sub-directory
- adjusted supressions in .luacheckrc
- fixed formatting issues in .luacheckrc

Gitlab CI: https://gitlab.com/tarantool/tarantool/-/pipelines/241108315
Issue: https://github.com/tarantool/tarantool/issues/5460
Branch: ligurio/gh-5460-luacheck-warnings-test-long_run-py

 .luacheckrc                         |  2 +-
 test/long_run-py/lua/finalizers.lua |  8 +++-----
 test/long_run-py/suite.lua          | 16 +++++++++-------
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/.luacheckrc b/.luacheckrc
index 4b829f3dc..68736d8db 100644
--- a/.luacheckrc
+++ b/.luacheckrc
@@ -37,7 +37,7 @@ exclude_files = {
     "test/box-tap/**/*.lua",
     "test/engine/**/*.lua",
     "test/engine_long/**/*.lua",
-    "test/long_run-py/**/*.lua",
+    "test/long_run-py/lua/finalizers.lua",
     "test/luajit-tap/**/*.lua",
     "test/replication/**/*.lua",
     "test/replication-py/**/*.lua",
diff --git a/test/long_run-py/lua/finalizers.lua b/test/long_run-py/lua/finalizers.lua
index 69146a323..cb6400363 100644
--- a/test/long_run-py/lua/finalizers.lua
+++ b/test/long_run-py/lua/finalizers.lua
@@ -1,19 +1,17 @@
 #!/usr/bin/env tarantool
 
-function on_gc(t)
+local function on_gc()
 end;
 
-function test_finalizers()
+local function test_finalizers()
     local result = {}
     local i = 1
     local ffi = require('ffi')
     while true do
-        result[i] = ffi.gc(ffi.cast('void *', 0), on_gc)
+        local result[i] = ffi.gc(ffi.cast('void *', 0), on_gc)
         i = i + 1
     end
-    return "done"
 end;
 
 test_finalizers()
 test_finalizers()
-
diff --git a/test/long_run-py/suite.lua b/test/long_run-py/suite.lua
index 0b33dec7d..7a09dd2b8 100644
--- a/test/long_run-py/suite.lua
+++ b/test/long_run-py/suite.lua
@@ -1,17 +1,16 @@
 
-function string_function()
+local function string_function()
     local random_number
     local random_string
     random_string = ""
-    for x = 1,20,1 do
+    for _ = 1,20,1 do
         random_number = math.random(65, 90)
         random_string = random_string .. string.char(random_number)
     end
     return random_string
 end
 
-function delete_replace_update(engine_name)
-    local string_value
+local function delete_replace_update(engine_name)
     if (box.space._space.index.name:select{'tester'}[1] ~= nil) then
         box.space.tester:drop()
     end
@@ -41,7 +40,6 @@ function delete_replace_update(engine_name)
         random_number = math.random(1,6)
 
         string_value_3 = string_function()
---      print('<'..counter..'> [' ..  random_number .. '] value_2: ' .. string_value_2 .. ' value_3: ' .. string_value_3)
         if random_number == 1 then
             box.space.tester:delete{string_value_2}
         end
@@ -71,8 +69,7 @@ function delete_replace_update(engine_name)
     return {counter, random_number, string_value_2, string_value_3}
 end
 
-function delete_insert(engine_name)
-    local string_value
+local function delete_insert(engine_name)
     if (box.space._space.index.name:select{'tester'}[1] ~= nil) then
         box.space.tester:drop()
     end
@@ -109,3 +106,8 @@ function delete_insert(engine_name)
     box.space.tester:drop()
     return {counter, string_value_2}
 end
+
+return {
+    delete_replace_update = delete_replace_update;
+    delete_insert = delete_insert;
+}
-- 
2.25.1



More information about the Tarantool-patches mailing list