Add luacheck + fix warnings detected by it

This commit is contained in:
tour 2024-09-14 20:06:27 +02:00
parent 2a90c58c50
commit 9c723301ec
5 changed files with 10 additions and 9 deletions

4
.luacheckrc Normal file
View File

@ -0,0 +1,4 @@
std = "lua51+luajit+minetest"
globals = {"test_string_to_table"}
read_globals = {"DIR_DELIM"}

View File

@ -1,9 +1,8 @@
local function stringToTable(str)
local parseTable -- defined later, but we need it in parseValue
local function parseValue(s, i)
s = s:match("^%s*(.-)%s*$", i) -- Trim leading/trailing spaces
i = 1
local function parseValue(s, idx)
s = s:match("^%s*(.-)%s*$", idx) -- Trim leading/trailing spaces
if s:sub(1, 1) == "{" then
return parseTable(s)
@ -47,7 +46,6 @@ local function stringToTable(str)
local function parseKey(s, i)
s = s:match("^%s*(.-)%s*$", i) -- Trim leading/trailing spaces
i = 1
if s:find("^[%a_]") then
local key = s:match("^[%a%d_]*")
if key ~= "true" and key ~= "false" and key ~= "nil" then

View File

@ -55,7 +55,6 @@ local function codedStringToTable(str)
local tbl = {}
local key, value
local next_key = 1
local inKey = true
local depth = 0
local buffer = ""

View File

@ -95,7 +95,7 @@ local function stringToTable(str)
local success = true
local tbl
local replacements = 0
local replacements
local table_count = 0
repeat
str, replacements = str:gsub("({[^{}]*})", function (match)