Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Luanti (formerly Minetest) standard to 5.10.0 #118

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion luacheck-dev-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ build = {
luacheck = "src/luacheck/init.lua",
["luacheck.builtin_standards"] = "src/luacheck/builtin_standards/init.lua",
["luacheck.builtin_standards.love"] = "src/luacheck/builtin_standards/love.lua",
["luacheck.builtin_standards.minetest"] = "src/luacheck/builtin_standards/minetest.lua",
["luacheck.builtin_standards.luanti"] = "src/luacheck/builtin_standards/luanti.lua",
["luacheck.builtin_standards.playdate"] = "src/luacheck/builtin_standards/playdate.lua",
["luacheck.builtin_standards.ngx"] = "src/luacheck/builtin_standards/ngx.lua",
["luacheck.cache"] = "src/luacheck/cache.lua",
Expand Down
23 changes: 13 additions & 10 deletions spec/cli_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ Checking spec/samples/globals.lua 2 warnings
Checking spec/samples/indirect_globals.lua 3 warnings
Checking spec/samples/inline_options.lua 7 warnings / 2 errors
Checking spec/samples/line_length.lua 8 warnings
Checking spec/samples/minetest.lua 2 warnings
Checking spec/samples/luanti.lua 2 warnings
Checking spec/samples/python_code.lua 1 error
Checking spec/samples/read_globals.lua 5 warnings
Checking spec/samples/read_globals_inline_options.lua 3 warnings
Expand All @@ -1269,7 +1269,7 @@ Checking globals.lua 2 warnings
Checking indirect_globals.lua 3 warnings
Checking inline_options.lua 7 warnings / 2 errors
Checking line_length.lua 8 warnings
Checking minetest.lua 2 warnings
Checking luanti.lua 2 warnings
Checking python_code.lua 1 error
Checking read_globals.lua 5 warnings
Checking read_globals_inline_options.lua 3 warnings
Expand All @@ -1295,7 +1295,7 @@ Checking globals.lua 2 warnings
Checking indirect_globals.lua 3 warnings
Checking inline_options.lua 7 warnings / 2 errors
Checking line_length.lua 8 warnings
Checking minetest.lua 2 warnings
Checking luanti.lua 2 warnings
Checking python_code.lua 1 error
Checking redefined.lua 7 warnings
Checking reversed_fornum.lua 1 warning
Expand Down Expand Up @@ -1355,13 +1355,16 @@ Total: 1 warning / 0 errors in 1 file
end)

describe("responds to builtin std preset", function()
it("minetest", function()
-- make sure minetest sample has something that normally throws a lint error
assert.equal(1, get_exitcode "spec/samples/minetest.lua --no-config")
-- turning on minetest std should pass all lints
assert.equal(0, get_exitcode "spec/samples/minetest.lua --no-config --std minetest")
-- confirm minetest std set isn't just blindly allowing anything
assert.equal(1, get_exitcode "spec/samples/sample.rockspec --no-config --std minetest")
it("luanti", function()
-- make sure luanti sample has something that normally throws a lint error
assert.equal(1, get_exitcode "spec/samples/luanti.lua --no-config")
-- test both the new "luanti" std name and the "minetest" compatibility alias
for _, std_name in ipairs {"luanti", "minetest"} do
-- turning on luanti std should pass all lints
assert.equal(0, get_exitcode("spec/samples/luanti.lua --no-config --std " .. std_name))
-- confirm luanti std set isn't just blindly allowing anything
assert.equal(1, get_exitcode("spec/samples/sample.rockspec --no-config --std " .. std_name))
end
end)
end)

Expand Down
2 changes: 2 additions & 0 deletions spec/samples/luanti.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
local _ = core
local _ = core.get_current_modname()
2 changes: 0 additions & 2 deletions spec/samples/minetest.lua

This file was deleted.

6 changes: 4 additions & 2 deletions src/luacheck/builtin_standards/init.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local love = require "luacheck.builtin_standards.love"
local minetest = require "luacheck.builtin_standards.minetest"
local luanti = require "luacheck.builtin_standards.luanti"
local playdate = require "luacheck.builtin_standards.playdate"
local ngx = require "luacheck.builtin_standards.ngx"
local standards = require "luacheck.standards"
Expand Down Expand Up @@ -297,7 +297,9 @@ builtin_standards.busted = {

builtin_standards.love = love

builtin_standards.minetest = minetest
builtin_standards.luanti = luanti
-- Minetest was renamed to Luanti. Keep an alias for compatibility.
builtin_standards.minetest = luanti

builtin_standards.playdate = playdate

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
-- minetest lua api standard
-- lua-api reference: https://github.com/minetest/minetest/blob/master/doc/lua_api.md
-- Luanti Lua API standard
-- API reference: https://github.com/minetest/minetest/blob/master/doc/lua_api.md
-- Changelog: https://dev.minetest.net/Changelog
-- Current version of this standard: 5.10.0
local standards = require "luacheck.standards"

local empty = {}
local read_write = {read_only = false}
local open_table = {read_only = false, other_fields = true}

-- main namespace
local minetest = {
local core = {
fields = {
-- Utilities
get_current_modname = empty,
Expand All @@ -16,6 +18,7 @@ local minetest = {
get_game_info = empty,
get_worldpath = empty,
is_singleplayer = empty,
is_valid_player_name = empty,
features = open_table,
has_feature = empty,
get_player_information = empty,
Expand All @@ -30,8 +33,10 @@ local minetest = {
sha1 = empty,
colorspec_to_colorstring = empty,
colorspec_to_bytes = empty,
colorspec_to_table = empty,
encode_png = empty,
urlencode = empty,
time_to_day_night_ratio = empty,

-- Logging
debug = empty,
Expand Down Expand Up @@ -167,6 +172,7 @@ local minetest = {
set_node = empty,
add_node = empty,
bulk_set_node = empty,
bulk_swap_node = empty,
swap_node = empty,
remove_node = empty,
get_node = empty,
Expand Down Expand Up @@ -395,6 +401,12 @@ local minetest = {
get_translated_string = empty,
translate = empty,

-- IPC
ipc_set = empty,
ipc_get = empty,
ipc_cas = empty,
ipc_poll = empty,

-- Global tables
registered_items = open_table,
registered_nodes = open_table,
Expand Down Expand Up @@ -430,7 +442,7 @@ local minetest = {
}

-- Table additions
local table = standards.def_fields("copy", "indexof", "insert_all", "key_value_swap", "shuffle")
local table = standards.def_fields("copy", "indexof", "insert_all", "key_value_swap", "shuffle", "keyof")

-- String additions
local string = standards.def_fields("split", "trim")
Expand All @@ -445,12 +457,15 @@ local bit = standards.def_fields("tobit","tohex","bnot","band","bor","bxor","lsh
-- vector util
local vector = standards.def_fields("new", "zero", "copy", "from_string", "to_string", "direction", "distance",
"length", "normalize", "floor", "round", "apply", "combine", "equals", "sort", "angle", "dot", "cross", "offset",
"check", "in_area", "add", "subtract", "multiply", "divide", "rotate", "rotate_around_axis", "dir_to_rotation")
"check", "in_area", "add", "subtract", "multiply", "divide", "rotate", "rotate_around_axis", "dir_to_rotation",
"ceil", "sign", "abs", "random_in_area", "random_direction")

return {
read_globals = {
-- main namespace
minetest = minetest,
core = core,
-- compatibility alias
minetest = core,

-- extensions
table = table,
Expand Down
2 changes: 1 addition & 1 deletion src/luacheck/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Links:
" luajit - globals of LuaJIT 2.x;\n" ..
" ngx_lua - globals of Openresty lua-nginx-module 0.10.10, including standard LuaJIT 2.x globals;\n" ..
" love - globals added by LÖVE;\n" ..
" minetest - globals added by minetest;\n" ..
" luanti - globals added by Luanti (formerly Minetest);\n" ..
" playdate - globals added by the Playdate SDK;\n" ..
" busted - globals added by Busted 2.0, by default added for files ending with _spec.lua within spec, " ..
"test, and tests subdirectories;\n" ..
Expand Down
Loading