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

alerque / luacheck / 10600181429

28 Aug 2024 03:54PM UTC coverage: 97.063% (-0.01%) from 97.077%
10600181429

push

github

alerque
chore: Correct availability of clobals in reader/writers

3 of 3 new or added lines in 1 file covered. (100.0%)

5 existing lines in 4 files now uncovered.

6312 of 6503 relevant lines covered (97.06%)

23960.52 hits per line

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

99.35
/src/luacheck/builtin_standards/init.lua
1
local love = require "luacheck.builtin_standards.love"
580✔
2
local minetest = require "luacheck.builtin_standards.minetest"
580✔
3
local pandoc = require "luacheck.builtin_standards.pandoc"
580✔
4
local playdate = require "luacheck.builtin_standards.playdate"
580✔
5
local ngx = require "luacheck.builtin_standards.ngx"
580✔
6
local standards = require "luacheck.standards"
580✔
7

8
local builtin_standards = {}
580✔
9

10
local function def_to_std(def)
11
   return {read_globals = def.fields}
26,680✔
12
end
13

14
local function add_defs(...)
15
   local res = {}
8,700✔
16

17
   for _, def in ipairs({...}) do
28,420✔
18
      standards.add_std_table(res, def_to_std(def))
19,720✔
19
   end
20

21
   return res
8,700✔
22
end
23

24
local empty = {}
580✔
25

26
local string_defs = {}
580✔
27

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

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

37
local file_defs = {}
580✔
38

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

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

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

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

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

137
local lua_defs = {}
580✔
138

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

269
for name, def in pairs(lua_defs) do
7,540✔
270
   builtin_standards[name] = def_to_std(def)
6,960✔
271
end
272

273
local function get_running_lua_std_name()
274
   if rawget(_G, "jit") then
580✔
275
      return "luajit"
×
276
   elseif _VERSION == "Lua 5.1" then
580✔
277
      return "lua51c"
145✔
278
   elseif _VERSION == "Lua 5.2" then
435✔
279
      return "lua52c"
145✔
UNCOV
280
   elseif _VERSION == "Lua 5.3" then
290✔
UNCOV
281
      return "lua53c"
145✔
282
   elseif _VERSION == "Lua 5.4" then
145✔
283
      return "lua54c"
145✔
284
   else
285
      return "max"
×
286
   end
287
end
288

289
builtin_standards._G = builtin_standards[get_running_lua_std_name()]
580✔
290

291
builtin_standards.busted = {
580✔
292
   read_globals = {
580✔
293
      "describe", "insulate", "expose", "it", "pending", "before_each", "after_each", "match",
580✔
294
      "lazy_setup", "lazy_teardown", "strict_setup", "strict_teardown", "setup", "teardown",
580✔
295
      "context", "spec", "test", "assert", "spy", "mock", "stub", "finally", "randomize"
580✔
296
   }
580✔
297
}
580✔
298

299
builtin_standards.love = love
580✔
300

301
builtin_standards.minetest = minetest
580✔
302

303
builtin_standards.playdate = playdate
580✔
304

305
builtin_standards.rockspec = {
580✔
306
   globals = {
580✔
307
      "rockspec_format", "package", "version", "description", "dependencies", "supported_platforms",
580✔
308
      "external_dependencies", "source", "build", "hooks", "deploy", "build_dependencies", "test_dependencies", "test"
580✔
309
   }
580✔
310
}
580✔
311

312
builtin_standards.luacheckrc = {
580✔
313
   globals = {
580✔
314
      "global", "unused", "redefined", "unused_args", "unused_secondaries", "self", "compat", "allow_defined",
580✔
315
      "allow_defined_top", "module", "globals", "read_globals", "new_globals", "new_read_globals", "not_globals",
580✔
316
      "ignore", "enable", "only", "std", "max_line_length", "max_code_line_length", "max_string_line_length",
580✔
317
      "max_comment_line_length", "max_cyclomatic_complexity", "quiet", "color", "codes", "ranges", "formatter",
580✔
318
      "cache", "jobs", "files", "stds", "exclude_files", "include_files", "operators"
580✔
319
   }
580✔
320
}
580✔
321

322
builtin_standards.ldoc = {
580✔
323
   globals = {
580✔
324
      -- Fields from cli parameters
325
      "file", "project", "title", "package", "all", "format", "output", "dir", "colon", "boilerplate", "ext", "one",
580✔
326
      "style", "template", "merge", "icon",
580✔
327
      -- `config.ld` additional fields
328
      "description", "full_description", "examples", "readme", "topics", "pretty", "prettify_files", "charset", "sort",
580✔
329
      "no_return_or_parms", "no_lua_ref", "backtick_references", "plain", "wrap", "manual_url", "no_summary",
580✔
330
      "custom_tags", "custom_see_handler", "custom_display_name_handler", "not_luadoc", "no_space_before_args",
580✔
331
      "template_escape", "user_keywords", "postprocess_html",
580✔
332
      -- Available functions
333
      "alias", "add_language_extension", "add_section", "new_type", "tparam_alias", "custom_see_handler",
580✔
334
      -- "Undocumented" fields
335
      "kind_names", "topics", "unqualified", "dont_escape_underscore", "custom_css", "version", "no_args_infer",
580✔
336
      "parse_extra", "output", "dir", "charset", "ignore", "module_file", "vars", "wrap", "not_luadoc",
580✔
337
      "merge_error_groups", "sort_modules", "use_markdown_titles", "custom_references", "global_lookup", "convert_opt"
580✔
338
   }
580✔
339
}
580✔
340

341
builtin_standards.sile = {
580✔
342
   globals = {
580✔
343
      package = { fields = { "searchpath" } },
580✔
344
      "SILE", "SU", "luautf8", "pl", "fluent", "executablePath", "extendSilePath", "CASILE"
580✔
345
   }
580✔
346
}
580✔
347

348
builtin_standards.pandoc = pandoc.pandoc
580✔
349
builtin_standards.pandoc_filter = pandoc.filter
580✔
350
builtin_standards.pandoc_custom = pandoc.custom
580✔
351
builtin_standards.pandoc_script = pandoc.script
580✔
352

353
builtin_standards.none = {}
580✔
354

355
return builtin_standards
580✔
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

© 2025 Coveralls, Inc