diff --git a/.github/workflows/ant.yaml b/.github/workflows/ant.yaml index ffb18c9..de2b75d 100644 --- a/.github/workflows/ant.yaml +++ b/.github/workflows/ant.yaml @@ -36,6 +36,13 @@ jobs: - uses: leafo/gh-actions-lua@v10 with: luaVersion: '5.3' + + - name: Setup LuaRocks + uses: leafo/gh-actions-luarocks@v4.3.0 + + - name: Install Luacheck + run: luarocks install luacheck + - run: luacheck . # TODO: add ar-io-sdk e2e tests against lua code to be bundled on changes (e.g. create a new ant, publish it and validate it works with the sdk) diff --git a/.luacheckrc b/.luacheckrc index d3579b9..758147f 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,6 +1,6 @@ allow_defined = true exclude_files = { - "src/crypto", + "dist/", } globals = { "Handlers", diff --git a/spec/setup.lua b/spec/setup.lua index 2f99a0c..5336958 100644 --- a/spec/setup.lua +++ b/spec/setup.lua @@ -1,7 +1,7 @@ package.path = "./src/?.lua;./src/common/?.lua;" .. package.path _G.ao = { - send = function(obj) + send = function(_) return true end, id = "test", @@ -15,8 +15,4 @@ _G.Handlers = { }, } -os.clock = function() - return 0 -end - print("Setup global ao mocks successfully...") diff --git a/src/common/initialize.lua b/src/common/initialize.lua index f4f3b9e..ee1c314 100644 --- a/src/common/initialize.lua +++ b/src/common/initialize.lua @@ -56,7 +56,7 @@ function initialize.initializeANTState(state) end local function findObject(array, key, value) - for i, object in ipairs(array) do + for _, object in ipairs(array) do if object[key] == value then return object end diff --git a/src/common/json.lua b/src/common/json.lua index d8ee08e..ce0cd80 100644 --- a/src/common/json.lua +++ b/src/common/json.lua @@ -49,7 +49,7 @@ local function escape_char(c) return "\\" .. (escape_char_map[c] or string.format("u%04x", c:byte())) end -local function encode_nil(val) +local function encode_nil() return "null" end @@ -77,7 +77,7 @@ local function encode_table(val, stack) error("invalid table: sparse array") end -- Encode - for i, v in ipairs(val) do + for _, v in ipairs(val) do table.insert(res, encode(v, stack)) end stack[val] = nil diff --git a/src/common/main.lua b/src/common/main.lua index a09c713..8ea17ee 100644 --- a/src/common/main.lua +++ b/src/common/main.lua @@ -327,13 +327,13 @@ function ant.init() end) Handlers.add(camel(ActionMap.Records), utils.hasMatchingTag("Action", ActionMap.Records), function(msg) - local records = records.getRecords() + local allRecords = records.getRecords() -- Credit-Notice message template, that is sent to the Recipient of the transfer local recordsNotice = { Target = msg.From, Action = "Records-Notice", - Data = records, + Data = allRecords, } -- Add forwarded tags to the records notice messages @@ -515,7 +515,7 @@ function ant.init() end local srcCodeTxIdStatus, srcCodeTxIdResult = pcall(utils.validateArweaveId, srcCodeTxId) - if srcCodeTxIdStatus and not srcCodeTxIdStatus then + if srcCodeTxIdStatus and not srcCodeTxIdResult then ao.send({ Target = msg.From, Action = "Invalid-Evolve-Notice", diff --git a/src/common/utils.lua b/src/common/utils.lua index 4f3b56b..12784e6 100644 --- a/src/common/utils.lua +++ b/src/common/utils.lua @@ -7,7 +7,7 @@ local utils = { _version = "0.0.1" } local function isArray(table) if type(table) == "table" then local maxIndex = 0 - for k, v in pairs(table) do + for k, _ in pairs(table) do if type(k) ~= "number" or k < 1 or math.floor(k) ~= k then return false -- If there's a non-integer key, it's not an array end diff --git a/src/process.lua b/src/process.lua index f5c0891..63325db 100644 --- a/src/process.lua +++ b/src/process.lua @@ -29,21 +29,6 @@ function Send(msg) _ao.send(msg) return "message added to outbox" end - -function Spawn(module, msg) - if not msg then - msg = {} - end - - _ao.spawn(module, msg) - return "spawn process request" -end - -function Assign(assignment) - _ao.assign(assignment) - return "assignment added to outbox" -end - function Tab(msg) local inputs = {} for _, o in ipairs(msg.Tags) do