diff options
author | rubenwardy <rw@rubenwardy.com> | 2019-08-06 19:30:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-06 19:30:18 +0100 |
commit | 8e757859d6a6bf6482480904e8485e9344e567ab (patch) | |
tree | 3304aa9393a753b85143389c6f6ffec990cfa12e /builtin/common | |
parent | 8da35c22d1c8933090330b2f3c44b4cf2c6e6760 (diff) | |
download | minetest-8e757859d6a6bf6482480904e8485e9344e567ab.tar.gz minetest-8e757859d6a6bf6482480904e8485e9344e567ab.tar.bz2 minetest-8e757859d6a6bf6482480904e8485e9344e567ab.zip |
Add luacheck to check builtin (#7895)
Diffstat (limited to 'builtin/common')
-rw-r--r-- | builtin/common/filterlist.lua | 1 | ||||
-rw-r--r-- | builtin/common/information_formspecs.lua | 7 | ||||
-rw-r--r-- | builtin/common/misc_helpers.lua | 17 | ||||
-rw-r--r-- | builtin/common/serialize.lua | 1 |
4 files changed, 12 insertions, 14 deletions
diff --git a/builtin/common/filterlist.lua b/builtin/common/filterlist.lua index 1ba1d8741..e30379f2f 100644 --- a/builtin/common/filterlist.lua +++ b/builtin/common/filterlist.lua @@ -250,7 +250,6 @@ end -------------------------------------------------------------------------------- function compare_worlds(world1,world2) - if world1.path ~= world2.path then return false end diff --git a/builtin/common/information_formspecs.lua b/builtin/common/information_formspecs.lua index 6a0b00bbc..10fe37b8f 100644 --- a/builtin/common/information_formspecs.lua +++ b/builtin/common/information_formspecs.lua @@ -31,7 +31,6 @@ local mod_cmds = {} local function load_mod_command_tree() mod_cmds = {} - local check_player_privs = core.check_player_privs for name, def in pairs(core.registered_chatcommands) do mod_cmds[def.mod_origin] = mod_cmds[def.mod_origin] or {} local cmds = mod_cmds[def.mod_origin] @@ -86,8 +85,8 @@ end local function build_privs_formspec(name) local privs = {} - for name, def in pairs(core.registered_privileges) do - privs[#privs + 1] = { name, def } + for priv_name, def in pairs(core.registered_privileges) do + privs[#privs + 1] = { priv_name, def } end table.sort(privs, function(a, b) return a[1] < b[1] end) @@ -137,7 +136,7 @@ help_command.func = function(name, param) if param == "" or param == "all" then core.show_formspec(name, "__builtin:help_cmds", build_chatcommands_formspec(name)) - return + return end return old_help_func(name, param) diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index 25632b4ca..d6673a691 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -128,6 +128,7 @@ function dump(o, indent, nested, level) if t ~= "table" then return basic_dump(o) end + -- Contains table -> true/nil of currently nested tables nested = nested or {} if nested[o] then @@ -136,10 +137,11 @@ function dump(o, indent, nested, level) nested[o] = true indent = indent or "\t" level = level or 1 - local t = {} + + local ret = {} local dumped_indexes = {} for i, v in ipairs(o) do - t[#t + 1] = dump(v, indent, nested, level + 1) + ret[#ret + 1] = dump(v, indent, nested, level + 1) dumped_indexes[i] = true end for k, v in pairs(o) do @@ -148,7 +150,7 @@ function dump(o, indent, nested, level) k = "["..dump(k, indent, nested, level + 1).."]" end v = dump(v, indent, nested, level + 1) - t[#t + 1] = k.." = "..v + ret[#ret + 1] = k.." = "..v end end nested[o] = nil @@ -157,10 +159,10 @@ function dump(o, indent, nested, level) local end_indent_str = "\n"..string.rep(indent, level - 1) return string.format("{%s%s%s}", indent_str, - table.concat(t, ","..indent_str), + table.concat(ret, ","..indent_str), end_indent_str) end - return "{"..table.concat(t, ", ").."}" + return "{"..table.concat(ret, ", ").."}" end -------------------------------------------------------------------------------- @@ -407,9 +409,8 @@ if INIT == "game" then end local old_itemstack = ItemStack(itemstack) - local new_itemstack, removed = core.item_place_node( - itemstack, placer, pointed_thing, param2, prevent_after_place - ) + local new_itemstack = core.item_place_node(itemstack, placer, + pointed_thing, param2, prevent_after_place) return infinitestacks and old_itemstack or new_itemstack end diff --git a/builtin/common/serialize.lua b/builtin/common/serialize.lua index 692ddd5f0..c91d2d5ce 100644 --- a/builtin/common/serialize.lua +++ b/builtin/common/serialize.lua @@ -218,4 +218,3 @@ test_in = {escape_chars="\n\r\t\v\\\"\'", non_european="θשׁ٩∂"} test_out = core.deserialize(core.serialize(test_in)) assert(test_in.escape_chars == test_out.escape_chars) assert(test_in.non_european == test_out.non_european) - |