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

lunarmodules / luacheck / 21044623957

15 Jan 2026 08:02PM UTC coverage: 97.014% (-0.03%) from 97.042%
21044623957

push

github

web-flow
Merge da3776733 into 6fc4af915

5 of 7 new or added lines in 1 file covered. (71.43%)

5 existing lines in 4 files now uncovered.

6303 of 6497 relevant lines covered (97.01%)

19269.74 hits per line

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

98.77
/src/luacheck/builtin_standards/init.lua
1
local love = require "luacheck.builtin_standards.love"
588✔
2
local luanti = require "luacheck.builtin_standards.luanti"
588✔
3
local playdate = require "luacheck.builtin_standards.playdate"
588✔
4
local ngx = require "luacheck.builtin_standards.ngx"
588✔
5
local standards = require "luacheck.standards"
588✔
6

7
local builtin_standards = {}
588✔
8

9
local function def_to_std(def)
10
   return {read_globals = def.fields}
31,164✔
11
end
12

13
local function add_defs(...)
14
   local res = {}
9,996✔
15

16
   for _, def in ipairs({...}) do
32,928✔
17
      standards.add_std_table(res, def_to_std(def))
22,932✔
18
   end
19

20
   return res
9,996✔
21
end
22

23
local empty = {}
588✔
24

25
local string_defs = {}
588✔
26

27
string_defs.min = standards.def_fields("byte", "char", "dump", "find", "format", "gmatch",
1,176✔
28
   "gsub", "len", "lower", "match", "rep", "reverse", "sub", "upper")
1,176✔
29

30
string_defs.lua51 = add_defs(string_defs.min, standards.def_fields("gfind"))
588✔
31
string_defs.lua52 = string_defs.min
588✔
32
string_defs.lua53 = add_defs(string_defs.min, standards.def_fields("pack", "packsize", "unpack"))
588✔
33
string_defs.lua54 = string_defs.lua53
588✔
34
string_defs.lua55 = string_defs.lua54
588✔
35
string_defs.luajit = string_defs.lua51
588✔
36

37
local file_defs = {}
588✔
38

39
file_defs.min = {
588✔
40
   fields = {
588✔
41
      __gc = empty,
588✔
42
      __index = {other_fields = true},
588✔
43
      __tostring = empty,
588✔
44
      close = empty,
588✔
45
      flush = empty,
588✔
46
      lines = empty,
588✔
47
      read = empty,
588✔
48
      seek = empty,
588✔
49
      setvbuf = empty,
588✔
50
      write = empty
588✔
51
   }
588✔
52
}
588✔
53

54
file_defs.lua51 = file_defs.min
588✔
55
file_defs.lua52 = file_defs.min
588✔
56
file_defs.lua53 = add_defs(file_defs.min, {fields = {__name = string_defs.lua53}})
588✔
57
file_defs.lua54 = add_defs(file_defs.min, {fields = {__name = string_defs.lua54}})
588✔
58
file_defs.lua55 = file_defs.lua54
588✔
59
file_defs.luajit = file_defs.min
588✔
60

61
local function make_min_def(method_defs)
62
   local string_def = string_defs[method_defs]
3,528✔
63
   local file_def = file_defs[method_defs]
3,528✔
64

65
   return {
3,528✔
66
      fields = {
3,528✔
67
         _G = {other_fields = true, read_only = false},
3,528✔
68
         _VERSION = string_def,
3,528✔
69
         arg = {other_fields = true},
3,528✔
70
         assert = empty,
3,528✔
71
         collectgarbage = empty,
3,528✔
72
         coroutine = standards.def_fields("create", "resume", "running", "status", "wrap", "yield"),
3,528✔
73
         debug = standards.def_fields("debug", "gethook", "getinfo", "getlocal", "getmetatable", "getregistry",
7,056✔
74
            "getupvalue", "sethook", "setlocal", "setmetatable", "setupvalue", "traceback"),
7,056✔
75
         dofile = empty,
3,528✔
76
         error = empty,
3,528✔
77
         getmetatable = empty,
3,528✔
78
         io = {
3,528✔
79
            fields = {
3,528✔
80
               close = empty,
3,528✔
81
               flush = empty,
3,528✔
82
               input = empty,
3,528✔
83
               lines = empty,
3,528✔
84
               open = empty,
3,528✔
85
               output = empty,
3,528✔
86
               popen = empty,
3,528✔
87
               read = empty,
3,528✔
88
               stderr = file_def,
3,528✔
89
               stdin = file_def,
3,528✔
90
               stdout = file_def,
3,528✔
91
               tmpfile = empty,
3,528✔
92
               type = empty,
3,528✔
93
               write = empty
3,528✔
94
            }
3,528✔
95
         },
3,528✔
96
         ipairs = empty,
3,528✔
97
         load = empty,
3,528✔
98
         loadfile = empty,
3,528✔
99
         math = standards.def_fields("abs", "acos", "asin", "atan", "ceil", "cos",
7,056✔
100
            "deg", "exp", "floor", "fmod", "huge", "log",
3,528✔
101
            "max", "min", "modf", "pi", "rad", "random", "randomseed",
3,528✔
102
            "sin", "sqrt", "tan"),
7,056✔
103
         next = empty,
3,528✔
104
         os = standards.def_fields("clock", "date", "difftime", "execute", "exit", "getenv",
7,056✔
105
            "remove", "rename", "setlocale", "time", "tmpname"),
7,056✔
106
         package = {
3,528✔
107
            fields = {
3,528✔
108
               config = string_def,
3,528✔
109
               cpath = {fields = string_def.fields, read_only = false},
3,528✔
110
               loaded = {other_fields = true, read_only = false},
3,528✔
111
               loadlib = empty,
3,528✔
112
               path = {fields = string_def.fields, read_only = false},
3,528✔
113
               preload = {other_fields = true, read_only = false}
3,528✔
114
            }
3,528✔
115
         },
3,528✔
116
         pairs = empty,
3,528✔
117
         pcall = empty,
3,528✔
118
         print = empty,
3,528✔
119
         rawequal = empty,
3,528✔
120
         rawget = empty,
3,528✔
121
         rawset = empty,
3,528✔
122
         require = empty,
3,528✔
123
         select = empty,
3,528✔
124
         setmetatable = empty,
3,528✔
125
         string = string_def,
3,528✔
126
         table = standards.def_fields("concat", "insert", "remove", "sort"),
3,528✔
127
         tonumber = empty,
3,528✔
128
         tostring = empty,
3,528✔
129
         type = empty,
3,528✔
130
         xpcall = empty
3,528✔
131
      }
3,528✔
132
   }
3,528✔
133
end
134

135
local bit32_def = standards.def_fields("arshift", "band", "bnot", "bor", "btest", "bxor", "extract",
1,176✔
136
   "lrotate", "lshift", "replace", "rrotate", "rshift")
588✔
137

138
local lua_defs = {}
588✔
139

140
lua_defs.min = make_min_def("min")
588✔
141
lua_defs.lua51 = add_defs(make_min_def("lua52"), {
1,176✔
142
   fields = {
588✔
143
      debug = standards.def_fields("getfenv", "setfenv"),
588✔
144
      getfenv = empty,
588✔
145
      loadstring = empty,
588✔
146
      math = standards.def_fields("atan2", "cosh", "frexp", "ldexp", "log10", "pow", "sinh", "tanh"),
588✔
147
      module = empty,
588✔
148
      newproxy = empty,
588✔
149
      package = {
588✔
150
         fields = {
588✔
151
            loaders = {other_fields = true, read_only = false},
588✔
152
            seeall = empty
588✔
153
         }
588✔
154
      },
588✔
155
      setfenv = empty,
588✔
156
      table = standards.def_fields("maxn"),
588✔
157
      unpack = empty
588✔
158
   }
588✔
159
})
588✔
160
lua_defs.lua51c = add_defs(lua_defs.lua51, make_min_def("lua51"), {
1,176✔
161
   fields = {
588✔
162
      gcinfo = empty,
588✔
163
      math = standards.def_fields("mod"),
588✔
164
      table = standards.def_fields("foreach", "foreachi", "getn", "setn")
588✔
165
   }
588✔
166
})
588✔
167
lua_defs.lua52 = add_defs(make_min_def("lua52"), {
1,176✔
168
   fields = {
588✔
169
      _ENV = {other_fields = true, read_only = false},
588✔
170
      bit32 = bit32_def,
588✔
171
      debug = standards.def_fields("getuservalue", "setuservalue", "upvalueid", "upvaluejoin"),
588✔
172
      math = standards.def_fields("atan2", "cosh", "frexp", "ldexp", "pow", "sinh", "tanh"),
588✔
173
      package = {
588✔
174
         fields = {
588✔
175
            searchers = {other_fields = true, read_only = false},
588✔
176
            searchpath = empty
588✔
177
         }
588✔
178
      },
588✔
179
      rawlen = empty,
588✔
180
      table = standards.def_fields("pack", "unpack")
588✔
181
   }
588✔
182
})
588✔
183
lua_defs.lua52c = add_defs(lua_defs.lua52, {
1,176✔
184
   fields = {
588✔
185
      loadstring = empty,
588✔
186
      math = standards.def_fields("log10"),
588✔
187
      module = empty,
588✔
188
      package = {
588✔
189
         fields = {
588✔
190
            loaders = {other_fields = true, read_only = false},
588✔
191
            seeall = empty
588✔
192
         }
588✔
193
      },
588✔
194
      table = standards.def_fields("maxn"),
588✔
195
      unpack = empty
588✔
196
   }
588✔
197
})
588✔
198
lua_defs.lua53 = add_defs(make_min_def("lua53"), {
1,176✔
199
   fields = {
588✔
200
      _ENV = {other_fields = true, read_only = false},
588✔
201
      coroutine = standards.def_fields("isyieldable"),
588✔
202
      debug = standards.def_fields("getuservalue", "setuservalue", "upvalueid", "upvaluejoin"),
588✔
203
      math = standards.def_fields("maxinteger", "mininteger", "tointeger", "type", "ult"),
588✔
204
      package = {
588✔
205
         fields = {
588✔
206
            searchers = {other_fields = true, read_only = false},
588✔
207
            searchpath = empty
588✔
208
         }
588✔
209
      },
588✔
210
      rawlen = empty,
588✔
211
      table = standards.def_fields("move", "pack", "unpack"),
588✔
212
      utf8 = {
588✔
213
         fields = {
588✔
214
            char = empty,
588✔
215
            charpattern = string_defs.lua53,
588✔
216
            codepoint = empty,
588✔
217
            codes = empty,
588✔
218
            len = empty,
588✔
219
            offset = empty
588✔
220
         }
588✔
221
      }
588✔
222
   }
588✔
223
})
588✔
224
lua_defs.lua53c = add_defs(lua_defs.lua53, {
1,176✔
225
   fields = {
588✔
226
      bit32 = bit32_def,
588✔
227
      math = standards.def_fields("atan2", "cosh", "frexp", "ldexp", "log10", "pow", "sinh", "tanh")
588✔
228
   }
588✔
229
})
588✔
230
lua_defs.lua54 = add_defs(lua_defs.lua53, {
1,176✔
231
   fields = {
588✔
232
      warn = empty,
588✔
233
      debug = standards.def_fields("setcstacklimit"),
588✔
234
      coroutine = standards.def_fields("close"),
588✔
235
   }
588✔
236
})
588✔
237
lua_defs.lua54c = add_defs(lua_defs.lua54, {
1,176✔
238
   fields = {
588✔
239
      math = standards.def_fields("atan2", "cosh", "frexp", "ldexp", "log10", "pow", "sinh", "tanh")
588✔
240
   }
588✔
241
})
588✔
242
lua_defs.lua55 = add_defs(lua_defs.lua54, {
1,176✔
243
   fields = {
588✔
244
      table = standards.def_fields("create")
588✔
245
   }
588✔
246
})
588✔
247
lua_defs.lua55c = add_defs(lua_defs.lua55, {
1,176✔
248
   fields = {
588✔
249
      math = standards.def_fields("atan2", "cosh", "frexp", "ldexp", "log10", "pow", "sinh", "tanh")
588✔
250
   }
588✔
251
})
588✔
252
lua_defs.luajit = add_defs(make_min_def("luajit"), {
1,176✔
253
   fields = {
588✔
254
      bit = standards.def_fields("arshift", "band", "bnot", "bor", "bswap", "bxor", "lshift", "rol", "ror",
1,176✔
255
         "rshift", "tobit", "tohex"),
1,176✔
256
      coroutine = standards.def_fields("isyieldable"),
588✔
257
      debug = standards.def_fields("getfenv", "setfenv", "upvalueid", "upvaluejoin"),
588✔
258
      gcinfo = empty,
588✔
259
      getfenv = empty,
588✔
260
      jit = {other_fields = true},
588✔
261
      loadstring = empty,
588✔
262
      math = standards.def_fields("atan2", "cosh", "frexp", "ldexp", "log10", "mod", "pow", "sinh", "tanh"),
588✔
263
      module = empty,
588✔
264
      newproxy = empty,
588✔
265
      package = {
588✔
266
         fields = {
588✔
267
            loaders = {other_fields = true, read_only = false},
588✔
268
            searchpath = empty,
588✔
269
            seeall = empty
588✔
270
         }
588✔
271
      },
588✔
272
      setfenv = empty,
588✔
273
      table = standards.def_fields("clear", "foreach", "foreachi", "getn", "maxn", "move", "new"),
588✔
274
      unpack = empty
588✔
275
   }
588✔
276
})
588✔
277
lua_defs.ngx_lua = add_defs(lua_defs.luajit, ngx)
588✔
278
lua_defs.max = add_defs(
1,176✔
279
   lua_defs.lua51c,
588✔
280
   lua_defs.lua52c,
588✔
281
   lua_defs.lua53c,
588✔
282
   lua_defs.lua54c,
588✔
283
   lua_defs.lua55c,
588✔
284
   lua_defs.luajit
285
)
1,176✔
286

287
for name, def in pairs(lua_defs) do
8,820✔
288
   builtin_standards[name] = def_to_std(def)
8,232✔
289
end
290

291
local function get_running_lua_std_name()
292
   if rawget(_G, "jit") then
588✔
293
      return "luajit"
×
294
   elseif _VERSION == "Lua 5.1" then
588✔
295
      return "lua51c"
147✔
296
   elseif _VERSION == "Lua 5.2" then
441✔
297
      return "lua52c"
147✔
UNCOV
298
   elseif _VERSION == "Lua 5.3" then
294✔
UNCOV
299
      return "lua53c"
147✔
300
   elseif _VERSION == "Lua 5.4" then
147✔
301
      return "lua54c"
147✔
302
   elseif _VERSION == "Lua 5.5" then
×
303
      return "lua55c"
×
304
   else
305
      return "max"
×
306
   end
307
end
308

309
builtin_standards._G = builtin_standards[get_running_lua_std_name()]
588✔
310

311
builtin_standards.busted = {
588✔
312
   read_globals = {
588✔
313
      "describe", "insulate", "expose", "it", "pending", "before_each", "after_each", "match",
588✔
314
      "lazy_setup", "lazy_teardown", "strict_setup", "strict_teardown", "setup", "teardown",
588✔
315
      "context", "spec", "test", "assert", "spy", "mock", "stub", "finally", "randomize"
588✔
316
   }
588✔
317
}
588✔
318

319
builtin_standards.love = love
588✔
320

321
builtin_standards.luanti = luanti
588✔
322
-- Minetest was renamed to Luanti. Keep an alias for compatibility.
323
builtin_standards.minetest = luanti
588✔
324

325
builtin_standards.playdate = playdate
588✔
326

327
builtin_standards.rockspec = {
588✔
328
   globals = {
588✔
329
      "rockspec_format", "package", "version", "description", "dependencies", "supported_platforms",
588✔
330
      "external_dependencies", "source", "build", "hooks", "deploy", "build_dependencies", "test_dependencies", "test"
588✔
331
   }
588✔
332
}
588✔
333

334
builtin_standards.luacheckrc = {
588✔
335
   globals = {
588✔
336
      "global", "unused", "redefined", "unused_args", "unused_secondaries", "self", "compat", "allow_defined",
588✔
337
      "allow_defined_top", "module", "globals", "read_globals", "new_globals", "new_read_globals", "not_globals",
588✔
338
      "ignore", "enable", "only", "std", "max_line_length", "max_code_line_length", "max_string_line_length",
588✔
339
      "max_comment_line_length", "max_cyclomatic_complexity", "quiet", "color", "codes", "ranges", "formatter",
588✔
340
      "cache", "jobs", "files", "stds", "exclude_files", "include_files", "operators"
588✔
341
   }
588✔
342
}
588✔
343

344
builtin_standards.ldoc = {
588✔
345
   globals = {
588✔
346
      -- Fields from cli parameters
347
      "file", "project", "title", "package", "all", "format", "output", "dir", "colon", "boilerplate", "ext", "one",
588✔
348
      "style", "template", "merge", "icon",
588✔
349
      -- `config.ld` additional fields
350
      "description", "full_description", "examples", "readme", "topics", "pretty", "prettify_files", "charset", "sort",
588✔
351
      "no_return_or_parms", "no_lua_ref", "backtick_references", "plain", "wrap", "manual_url", "no_summary",
588✔
352
      "custom_tags", "custom_see_handler", "custom_display_name_handler", "not_luadoc", "no_space_before_args",
588✔
353
      "template_escape", "user_keywords", "postprocess_html",
588✔
354
      -- Available functions
355
      "alias", "add_language_extension", "add_section", "new_type", "tparam_alias", "custom_see_handler",
588✔
356
      -- "Undocumented" fields
357
      "kind_names", "topics", "unqualified", "dont_escape_underscore", "custom_css", "version", "no_args_infer",
588✔
358
      "parse_extra", "output", "dir", "charset", "ignore", "module_file", "vars", "wrap", "not_luadoc",
588✔
359
      "merge_error_groups", "sort_modules", "use_markdown_titles", "custom_references", "global_lookup", "convert_opt"
588✔
360
   }
588✔
361
}
588✔
362

363
builtin_standards.sile = {
588✔
364
   globals = {
588✔
365
      package = { fields = { "searchpath" } },
588✔
366
      "SILE", "SU", "luautf8", "pl", "fluent", "executablePath", "extendSilePath", "CASILE"
588✔
367
   }
588✔
368
}
588✔
369

370
builtin_standards.none = {}
588✔
371

372
return builtin_standards
588✔
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