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
| local core_utils = require "luacheck.core_utils"
|
| local stage = {}
|
| stage.warnings = {
| ["541"] = {message_format = "empty do..end block", fields = {}},
| ["542"] = {message_format = "empty if branch", fields = {}}
| }
|
| local function check_block(chstate, block, code)
| if #block == 0 then
| chstate:warn_range(code, block)
| end
| end
|
|
| local function check_node(chstate, node)
| if node.tag == "Do" then
| check_block(chstate, node, "541")
| return
| end
|
| for index = 2, #node, 2 do
| check_block(chstate, node[index], "542")
| end
|
| if #node % 2 == 1 then
| check_block(chstate, node[#node], "542")
| end
| end
|
| function stage.run(chstate)
| core_utils.each_statement(chstate, {"Do", "If"}, check_node)
| end
|
| return stage
|
|