• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lunarmodules / luacheck / 24662353255

20 Apr 2026 10:48AM UTC coverage: 97.095% (+0.07%) from 97.027%
24662353255

push

github

web-flow
fix(ci): build LuaJIT using system malloc for lualanes tests (#144)

6318 of 6507 relevant lines covered (97.1%)

26928.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.3
/src/luacheck/core_utils.lua
1
local decoder = require "luacheck.decoder"
876✔
2
local utils = require "luacheck.utils"
876✔
3

4
local core_utils = {}
876✔
5

6
-- Attempts to evaluate a node as a Lua value, without resolving locals.
7
-- Returns Lua value and its string representation on success, nothing on failure.
8
function core_utils.eval_const_node(node)
876✔
9
   if node.tag == "True" then
522✔
10
      return true, "true"
×
11
   elseif node.tag == "False" then
522✔
12
      return false, "false"
×
13
   elseif node.tag == "String" then
522✔
14
      local chars = decoder.decode(node[1])
420✔
15
      return node[1], chars:get_printable_substring(1, chars:get_length())
700✔
16
   else
17
      local is_negative
18

19
      if node.tag == "Op" and node[1] == "unm" then
102✔
20
         is_negative = true
18✔
21
         node = node[2]
18✔
22
      end
23

24
      if node.tag ~= "Number" then
102✔
25
         return
18✔
26
      end
27

28
      local str = node[1]
84✔
29

30
      if str:find("[iIuUlL]") then
84✔
31
         -- Ignore LuaJIT cdata literals.
32
         return
×
33
      end
34

35
      -- On Lua 5.3+ convert to float to get same results as on Lua 5.1 and 5.2.
36
      if (_VERSION == "Lua 5.3" or _VERSION == "Lua 5.4") and not str:find("[%.eEpP]") then
84✔
37
         str = str .. ".0"
22✔
38
      end
39

40
      local number = tonumber(str)
84✔
41

42
      if not number then
84✔
43
         return
×
44
      end
45

46
      if is_negative then
84✔
47
         number = -number
18✔
48
      end
49

50
      if number == number and number < 1/0 and number > -1/0 then
84✔
51
         return number, (is_negative and "-" or "") .. node[1]
84✔
52
      end
53
   end
54
end
55

56
local statement_containing_tags = utils.array_to_set({"Do", "While", "Repeat", "Fornum", "Forin", "If"})
876✔
57

58
-- `items` is an array of nodes or nested item arrays.
59
local function scan_for_statements(chstate, items, tags, callback, ...)
60
   for _, item in ipairs(items) do
77,448✔
61
      if tags[item.tag] then
53,160✔
62
         callback(chstate, item, ...)
5,040✔
63
      end
64

65
      if not item.tag or statement_containing_tags[item.tag] then
53,160✔
66
         scan_for_statements(chstate, item, tags, callback, ...)
13,992✔
67
      end
68
   end
69
end
70

71
-- Calls `callback(chstate, node, ...)` for each statement node within AST with tag in given array.
72
function core_utils.each_statement(chstate, tags_array, callback, ...)
876✔
73
   local tags = utils.array_to_set(tags_array)
4,512✔
74

75
   for _, line in ipairs(chstate.lines) do
14,808✔
76
      scan_for_statements(chstate, line.node[2], tags, callback, ...)
10,296✔
77
   end
78
end
79

80
local function location_comparator(warning1, warning2)
81
   if warning1.line ~= warning2.line then
35,251✔
82
      return warning1.line < warning2.line
29,509✔
83
   elseif warning1.column ~= warning2.column then
5,742✔
84
      return warning1.column < warning2.column
4,635✔
85
   else
86
      return warning1.code < warning2.code
1,107✔
87
   end
88
end
89

90
-- Sorts an array of warnings by location information as provided in `line` and `column` fields.
91
function core_utils.sort_by_location(warnings)
876✔
92
   table.sort(warnings, location_comparator)
3,126✔
93
end
94

95
return core_utils
876✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc