summaryrefslogtreecommitdiffstats
path: root/.luacheckrc
blob: 28ef054d19af668d6549573eca348d8c19bd52e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
-- SPDX-License-Identifier: GPL-3.0-or-later
std = 'luajit'
new_read_globals = {
	'cache',
	'eval_cmd',
	'event',
	'help',
	'_hint_root_file',
	'hostname',
	'map',
	'modules',
	'net',
	'package_version',
	'quit',
	'resolve',
	'ta_update',
	'fromjson',
	'todname',
	'tojson',
	'user',
	'worker',
	'kluautil_list_dir',
	-- Sandbox declarations
	'kB',
	'MB',
	'GB',
	'sec',
	'second',
	'minute',
	'min',
	'hour',
	'day',
	'panic',
	'log',
	'log_error',
	'log_warn',
	'log_info',
	'log_debug',
	'log_fmt',
	'log_qry',
	'log_req',
	'log_level',
	'log_target',
	'log_groups',
	'LOG_CRIT',
	'LOG_ERR',
	'LOG_WARNING',
	'LOG_NOTICE',
	'LOG_INFO',
	'LOG_DEBUG',
	'mode',
	'reorder_RR',
	'option',
	'env',
	'debugging',
	'kres',
	'libknot_SONAME',
	'libzscanner_SONAME',
	'table_print',
	'_ENV',
}

new_globals = {
	-- Modules are allowed to be set and accessed from global namespace
	'policy',
	'view',
	'stats',
	'http',
	'trust_anchors',
	'bogus_log',
}

-- Luacheck < 0.18 doesn't support new_read_globals
for _, v in ipairs(new_read_globals) do
	table.insert(new_globals, v)
end

exclude_files = {
	'modules/policy/lua-aho-corasick', -- Vendored
	'tests/config/tapered',
	'build*/**', -- build outputs
	'pkg/**', -- packaging outputs
}

-- Ignore some pedantic checks
ignore = {
	'4.1/err', -- Shadowing err
	'4.1/.',   -- Shadowing one letter variables
}

-- Sandbox can set global variables
files['**/daemon/lua'].ignore = {'111', '121', '122'}
files['**/daemon/lua/kres-gen-*.lua'].ignore = {'631'} -- Allow overly long lines
-- Tests and scripts can use global variables
files['scripts'].ignore = {'111', '112', '113'}
files['tests'].ignore = {'111', '112', '113'}
files['**/utils/upgrade'].ignore = {'111', '112', '113'}
files['**/modules/**/*.test.lua'].ignore = {'111', '112', '113', '121', '122'}
files['**/daemon/**/*.test.lua'].ignore = {'111', '112', '113', '121', '122'}