Skip to content

Commit

Permalink
Add support for redis built-ins
Browse files Browse the repository at this point in the history
  • Loading branch information
mcraq committed Aug 26, 2024
1 parent cc089e3 commit 5dfd597
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/luacheck/builtin_standards/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ local love = require "luacheck.builtin_standards.love"
local minetest = require "luacheck.builtin_standards.minetest"
local playdate = require "luacheck.builtin_standards.playdate"
local ngx = require "luacheck.builtin_standards.ngx"
local redis5 = require "luacheck.builtin_standards.redis5"
local redis6 = require "luacheck.builtin_standards.redis6"
local redis7 = require "luacheck.builtin_standards.redis7"
local standards = require "luacheck.standards"

local builtin_standards = {}
Expand Down Expand Up @@ -264,6 +267,9 @@ lua_defs.luajit = add_defs(make_min_def("luajit"), {
})
lua_defs.ngx_lua = add_defs(lua_defs.luajit, ngx)
lua_defs.max = add_defs(lua_defs.lua51c, lua_defs.lua52c, lua_defs.lua53c, lua_defs.lua54c, lua_defs.luajit)
lua_defs.redis5 = add_defs(lua_defs.lua51, redis5)
lua_defs.redis6 = add_defs(lua_defs.redis5, redis6)
lua_defs.redis7 = add_defs(lua_defs.redis6, redis7)

for name, def in pairs(lua_defs) do
builtin_standards[name] = def_to_std(def)
Expand Down
68 changes: 68 additions & 0 deletions src/luacheck/builtin_standards/redis5.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
local empty = {}

local redis = {
fields = {
ARGV = {
other_fields = true,
},
KEYS = {
other_fields = true,
},

redis = {
fields = {
call = empty,
pcall = empty,
error_reply = empty,
status_reply = empty,
sha1hex = empty,
log = empty,
set_repl = empty,
replicate_commands = empty,
breakpoint = empty,
debug = empty,
},
},

cjson = {
fields = {
decode = empty,
encode = empty,
},
},

struct = {
fields = {
pack = empty,
unpack = empty,
size = empty,
}
},

cmsgpack = {
fields = {
pack = empty,
unpack = empty,
}
},

bit = {
fields = {
tobit = empty,
tohex = empty,
bnot = empty,
bor = empty,
band = empty,
bxor = empty,
lshift = empty,
rshift = empty,
arshift = empty,
rol = empty,
ror = empty,
bswap = empty,
}
}
}
}

return redis
14 changes: 14 additions & 0 deletions src/luacheck/builtin_standards/redis6.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
local empty = {}

local redis = {
fields = {
redis = {
fields = {
setresp = empty,
}

}
}
}

return redis
14 changes: 14 additions & 0 deletions src/luacheck/builtin_standards/redis7.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
local empty = {}

local redis = {
fields = {
redis = {
REDIS_VERSION = {},
REDIS_VERSION_NUM = {},
acl_check_cmd = empty,
register_function = empty,
}
}
}

return redis

0 comments on commit 5dfd597

Please sign in to comment.