From 5dfd597604a7e03313b8acfa0dae40f662219db7 Mon Sep 17 00:00:00 2001 From: Michael Crawford Date: Fri, 23 Aug 2024 13:55:42 -0400 Subject: [PATCH] Add support for redis built-ins --- src/luacheck/builtin_standards/init.lua | 6 ++ src/luacheck/builtin_standards/redis5.lua | 68 +++++++++++++++++++++++ src/luacheck/builtin_standards/redis6.lua | 14 +++++ src/luacheck/builtin_standards/redis7.lua | 14 +++++ 4 files changed, 102 insertions(+) create mode 100644 src/luacheck/builtin_standards/redis5.lua create mode 100644 src/luacheck/builtin_standards/redis6.lua create mode 100644 src/luacheck/builtin_standards/redis7.lua diff --git a/src/luacheck/builtin_standards/init.lua b/src/luacheck/builtin_standards/init.lua index 097fee2d..0d06f053 100644 --- a/src/luacheck/builtin_standards/init.lua +++ b/src/luacheck/builtin_standards/init.lua @@ -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 = {} @@ -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) diff --git a/src/luacheck/builtin_standards/redis5.lua b/src/luacheck/builtin_standards/redis5.lua new file mode 100644 index 00000000..4edf0cd4 --- /dev/null +++ b/src/luacheck/builtin_standards/redis5.lua @@ -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 diff --git a/src/luacheck/builtin_standards/redis6.lua b/src/luacheck/builtin_standards/redis6.lua new file mode 100644 index 00000000..e145f1bb --- /dev/null +++ b/src/luacheck/builtin_standards/redis6.lua @@ -0,0 +1,14 @@ +local empty = {} + +local redis = { + fields = { + redis = { + fields = { + setresp = empty, + } + + } + } +} + +return redis diff --git a/src/luacheck/builtin_standards/redis7.lua b/src/luacheck/builtin_standards/redis7.lua new file mode 100644 index 00000000..8b453530 --- /dev/null +++ b/src/luacheck/builtin_standards/redis7.lua @@ -0,0 +1,14 @@ +local empty = {} + +local redis = { + fields = { + redis = { + REDIS_VERSION = {}, + REDIS_VERSION_NUM = {}, + acl_check_cmd = empty, + register_function = empty, + } + } +} + +return redis