Skip to content

Commit 8e819ca

Browse files
committed
Check for indent spaces and fixed found problems. Lib C/C++ code is not checked.
1 parent 03e600a commit 8e819ca

File tree

93 files changed

+710
-603
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+710
-603
lines changed

.github/workflows/whitespace_checks.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414
- '**.sh'
1515
- '**.cmake'
1616
- '**.glsl'
17+
- '**.lua'
1718
pull_request:
1819
paths:
1920
- '**.txt'
@@ -24,6 +25,7 @@ on:
2425
- '**.sh'
2526
- '**.cmake'
2627
- '**.glsl'
28+
- '**.lua'
2729

2830
jobs:
2931
trailing_whitespaces:
@@ -34,6 +36,23 @@ jobs:
3436
- name: Check trailing whitespaces
3537
run: if git ls-files | grep -E '\.txt$|\.md$|\.[ch]$|\.cpp$|\.hpp$|\.sh$|\.cmake$|\.glsl$' | xargs grep -n '\s$'; then echo -e "\033[0;31mFound trailing whitespace"; (exit 1); else (exit 0); fi
3638

39+
indent_spaces:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
# Line endings are already ensured by .gitattributes
44+
- name: Check for unsupported multiline comments
45+
run: |
46+
if git ls-files | grep -E '^src/.*\.cpp$|^src/.*\.[ch]$' | xargs grep -n '\*/.*/\*'; then echo -e "\033[0;31mUnsupported combination of multiline comments. New multiline comment should begin on new line."; (exit 1); else (exit 0); fi
47+
if git ls-files | grep -E '\.lua$' | xargs grep -n '\]\]--.*--\[\['; then echo -e "\033[0;31mUnsupported combination of multiline comments. New multiline comment should begin on new line."; (exit 1); else (exit 0); fi
48+
- name: Preprocess files
49+
run: |
50+
git ls-files | grep -E '^src/.*\.cpp$|^src/.*\.[ch]$' | xargs -L 1 -P $(($(nproc) + 1)) python3 ./util/ci/indent_tab_preprocess.py "/\\*" "\\*/"
51+
git ls-files | grep -E '\.lua$' | xargs -L 1 -P $(($(nproc) + 1)) python3 ./util/ci/indent_tab_preprocess.py "--\\[\\[*" "--\\]\\]"
52+
- name: Check indent spaces
53+
run: |
54+
if git ls-files | grep -E '^src/.*\.cpp$|^src/.*\.[ch]$|\.lua' | xargs grep -n -P '^\t*[ ]'; then echo -e "\033[0;31mFound indent whitespace"; (exit 1); else (exit 0); fi
55+
3756
tabs_lua_api_files:
3857
runs-on: ubuntu-latest
3958
steps:

builtin/common/serialize.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ end
193193
function core.serialize(value)
194194
local rope = {}
195195
serialize(value, function(text)
196-
-- Faster than table.insert(rope, text) on PUC Lua 5.1
196+
-- Faster than table.insert(rope, text) on PUC Lua 5.1
197197
rope[#rope + 1] = text
198198
end)
199199
return table_concat(rope)

builtin/common/vector.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ metatable.__tostring = vector.to_string
7171

7272
function vector.equals(a, b)
7373
return a.x == b.x and
74-
a.y == b.y and
75-
a.z == b.z
74+
a.y == b.y and
75+
a.z == b.z
7676
end
7777
metatable.__eq = vector.equals
7878

@@ -380,7 +380,7 @@ function vector.random_direction()
380380
local x, y, z, l2
381381
repeat -- expected less than two attempts on average (volume sphere vs. cube)
382382
x, y, z = math.random() * 2 - 1, math.random() * 2 - 1, math.random() * 2 - 1
383-
l2 = x*x + y*y + z*z
383+
l2 = x*x + y*y + z*z
384384
until l2 <= 1 and l2 >= 1e-6
385385
-- normalize
386386
local l = math.sqrt(l2)

builtin/fstk/buttonbar.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ local function buttonbar_formspec(self)
4040
-- `BASE_SPACING` is used as the minimum spacing, like `gap` in CSS Flexbox.
4141

4242
-- The number of buttons per page is always calculated as if the scroll
43-
-- buttons were visible.
43+
-- buttons were visible.
4444
local avail_space = self.size.x - 2*BASE_SPACING - 2*get_scroll_btn_width()
4545
local btns_per_page = math.floor((avail_space - BASE_SPACING) / (btn_size + BASE_SPACING))
4646

builtin/game/falling.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ core.register_entity(":__builtin:falling_node", {
8080
self.floats = core.get_item_group(node.name, "float") ~= 0
8181

8282
-- Save liquidtype for falling water
83-
self.liquidtype = def.liquidtype
83+
self.liquidtype = def.liquidtype
8484

8585
-- Set entity visuals
8686
if def.drawtype == "torchlike" or def.drawtype == "signlike" then

builtin/game/register.lua

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,17 +247,17 @@ function core.register_tool(name, tooldef)
247247
tooldef.inventory_image = tooldef.image
248248
end
249249
if tooldef.tool_capabilities == nil and
250-
(tooldef.full_punch_interval ~= nil or
251-
tooldef.basetime ~= nil or
252-
tooldef.dt_weight ~= nil or
253-
tooldef.dt_crackiness ~= nil or
254-
tooldef.dt_crumbliness ~= nil or
255-
tooldef.dt_cuttability ~= nil or
256-
tooldef.basedurability ~= nil or
257-
tooldef.dd_weight ~= nil or
258-
tooldef.dd_crackiness ~= nil or
259-
tooldef.dd_crumbliness ~= nil or
260-
tooldef.dd_cuttability ~= nil) then
250+
(tooldef.full_punch_interval ~= nil or
251+
tooldef.basetime ~= nil or
252+
tooldef.dt_weight ~= nil or
253+
tooldef.dt_crackiness ~= nil or
254+
tooldef.dt_crumbliness ~= nil or
255+
tooldef.dt_cuttability ~= nil or
256+
tooldef.basedurability ~= nil or
257+
tooldef.dd_weight ~= nil or
258+
tooldef.dd_crackiness ~= nil or
259+
tooldef.dd_crumbliness ~= nil or
260+
tooldef.dd_cuttability ~= nil) then
261261
tooldef.tool_capabilities = {
262262
full_punch_interval = tooldef.full_punch_interval,
263263
basetime = tooldef.basetime,

builtin/game/voxelarea.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ end
4646
function VoxelArea:index(x, y, z)
4747
local MinEdge = self.MinEdge
4848
local i = (z - MinEdge.z) * self.zstride +
49-
(y - MinEdge.y) * self.ystride +
50-
(x - MinEdge.x) + 1
49+
(y - MinEdge.y) * self.ystride +
50+
(x - MinEdge.x) + 1
5151
return math_floor(i)
5252
end
5353

5454
function VoxelArea:indexp(p)
5555
local MinEdge = self.MinEdge
5656
local i = (p.z - MinEdge.z) * self.zstride +
57-
(p.y - MinEdge.y) * self.ystride +
58-
(p.x - MinEdge.x) + 1
57+
(p.y - MinEdge.y) * self.ystride +
58+
(p.x - MinEdge.x) + 1
5959
return math_floor(i)
6060
end
6161

@@ -78,15 +78,15 @@ end
7878
function VoxelArea:contains(x, y, z)
7979
local MaxEdge, MinEdge = self.MaxEdge, self.MinEdge
8080
return (x >= MinEdge.x) and (x <= MaxEdge.x) and
81-
(y >= MinEdge.y) and (y <= MaxEdge.y) and
82-
(z >= MinEdge.z) and (z <= MaxEdge.z)
81+
(y >= MinEdge.y) and (y <= MaxEdge.y) and
82+
(z >= MinEdge.z) and (z <= MaxEdge.z)
8383
end
8484

8585
function VoxelArea:containsp(p)
8686
local MaxEdge, MinEdge = self.MaxEdge, self.MinEdge
8787
return (p.x >= MinEdge.x) and (p.x <= MaxEdge.x) and
88-
(p.y >= MinEdge.y) and (p.y <= MaxEdge.y) and
89-
(p.z >= MinEdge.z) and (p.z <= MaxEdge.z)
88+
(p.y >= MinEdge.y) and (p.y <= MaxEdge.y) and
89+
(p.z >= MinEdge.z) and (p.z <= MaxEdge.z)
9090
end
9191

9292
function VoxelArea:containsi(i)

games/devtest/mods/soundstuff/racecar.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ local drive_distance = 30
44

55
minetest.register_entity("soundstuff:racecar", {
66
initial_properties = {
7-
physical = false,
8-
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
9-
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
10-
visual = "upright_sprite",
11-
visual_size = {x = 1, y = 1, z = 1},
12-
textures = {"soundstuff_racecar.png", "soundstuff_racecar.png^[transformFX"},
13-
static_save = false,
14-
},
7+
physical = false,
8+
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
9+
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
10+
visual = "upright_sprite",
11+
visual_size = {x = 1, y = 1, z = 1},
12+
textures = {"soundstuff_racecar.png", "soundstuff_racecar.png^[transformFX"},
13+
static_save = false,
14+
},
1515

1616
on_activate = function(self, _staticdata, _dtime_s)
1717
self.min_x = self.object:get_pos().x - drive_distance * 0.5

games/devtest/mods/testentities/selectionbox.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ minetest.register_globalstep(function()
6868
hud_ids[pname] = hud_id or player:hud_add({
6969
type = "text", -- See HUD element types
7070
position = {x=0.5, y=0.5},
71-
text = "X",
71+
text = "X",
7272
number = 0xFF0000,
7373
alignment = {x=0, y=0},
7474
})

games/devtest/mods/tiled/init.lua

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,38 @@ local align_help = "Texture spans over a space of 8×8 nodes"
22
local align_help_n = "Tiles looks the same for every node"
33

44
minetest.register_node("tiled:tiled", {
5-
description = "Tiled Node (world-aligned)".."\n"..align_help,
6-
tiles = {{
7-
name = "tiled_tiled.png",
8-
align_style = "world",
9-
scale = 8,
10-
}},
11-
groups = {cracky=3},
5+
description = "Tiled Node (world-aligned)".."\n"..align_help,
6+
tiles = {{
7+
name = "tiled_tiled.png",
8+
align_style = "world",
9+
scale = 8,
10+
}},
11+
groups = {cracky=3},
1212
})
1313

1414
minetest.register_node("tiled:tiled_rooted", {
15-
description = "Tiled 'plantlike_rooted' Node (world-aligned)".."\n"..
16-
"Base node texture spans over a space of 8×8 nodes".."\n"..
17-
"A plantlike thing grows on top",
18-
paramtype = "light",
19-
drawtype = "plantlike_rooted",
20-
tiles = {{
21-
name = "tiled_tiled.png",
22-
align_style = "world",
23-
scale = 8,
24-
}},
25-
special_tiles = {"tiled_tiled_node.png"},
26-
groups = {cracky=3},
15+
description =
16+
"Tiled 'plantlike_rooted' Node (world-aligned)".."\n"..
17+
"Base node texture spans over a space of 8×8 nodes".."\n"..
18+
"A plantlike thing grows on top",
19+
paramtype = "light",
20+
drawtype = "plantlike_rooted",
21+
tiles = {{
22+
name = "tiled_tiled.png",
23+
align_style = "world",
24+
scale = 8,
25+
}},
26+
special_tiles = {"tiled_tiled_node.png"},
27+
groups = {cracky=3},
2728
})
2829

2930
minetest.register_node("tiled:tiled_n", {
30-
description = "Tiled Node (node-aligned)".."\n"..align_help_n,
31-
tiles = {{
32-
name = "tiled_tiled_node.png",
33-
align_style = "node",
34-
}},
35-
groups = {cracky=3},
31+
description = "Tiled Node (node-aligned)".."\n"..align_help_n,
32+
tiles = {{
33+
name = "tiled_tiled_node.png",
34+
align_style = "node",
35+
}},
36+
groups = {cracky=3},
3637
})
3738

3839
stairs.register_stair_and_slab("tiled_n", "tiled:tiled_n",
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11

22
unittests.register("test_get_version", function()
3-
local version = core.get_version()
4-
assert(type(version) == "table")
5-
assert(type(version.project) == "string")
6-
assert(type(version.string) == "string")
7-
assert(type(version.proto_min) == "number")
8-
assert(type(version.proto_max) == "number")
9-
assert(version.proto_max >= version.proto_min)
10-
assert(type(version.is_dev) == "boolean")
11-
if version.is_dev then
12-
assert(type(version.hash) == "string")
13-
else
14-
assert(version.hash == nil)
15-
end
3+
local version = core.get_version()
4+
assert(type(version) == "table")
5+
assert(type(version.project) == "string")
6+
assert(type(version.string) == "string")
7+
assert(type(version.proto_min) == "number")
8+
assert(type(version.proto_max) == "number")
9+
assert(version.proto_max >= version.proto_min)
10+
assert(type(version.is_dev) == "boolean")
11+
if version.is_dev then
12+
assert(type(version.hash) == "string")
13+
else
14+
assert(version.hash == nil)
15+
end
1616
end)
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
local function raycast_with_pointabilities(start_pos, end_pos, pointabilities)
22
local ray = core.raycast(start_pos, end_pos, nil, nil, pointabilities)
33
for hit in ray do
4-
if hit.type == "node" then
5-
return hit.under
6-
end
4+
if hit.type == "node" then
5+
return hit.under
6+
end
77
end
8-
return nil
8+
return nil
99
end
1010

1111
local function test_raycast_pointabilities(player, pos1)
12-
local pos2 = pos1:offset(0, 0, 1)
13-
local pos3 = pos1:offset(0, 0, 2)
12+
local pos2 = pos1:offset(0, 0, 1)
13+
local pos3 = pos1:offset(0, 0, 2)
1414

15-
local oldnode1 = core.get_node(pos1)
16-
local oldnode2 = core.get_node(pos2)
17-
local oldnode3 = core.get_node(pos3)
18-
core.swap_node(pos1, {name = "air"})
19-
core.swap_node(pos2, {name = "testnodes:not_pointable"})
20-
core.swap_node(pos3, {name = "testnodes:pointable"})
15+
local oldnode1 = core.get_node(pos1)
16+
local oldnode2 = core.get_node(pos2)
17+
local oldnode3 = core.get_node(pos3)
18+
core.swap_node(pos1, {name = "air"})
19+
core.swap_node(pos2, {name = "testnodes:not_pointable"})
20+
core.swap_node(pos3, {name = "testnodes:pointable"})
2121

22-
local p = nil
23-
assert(raycast_with_pointabilities(pos1, pos3, p) == pos3)
22+
local p = nil
23+
assert(raycast_with_pointabilities(pos1, pos3, p) == pos3)
2424

25-
p = core.registered_items["testtools:blocked_pointing_staff"].pointabilities
26-
assert(raycast_with_pointabilities(pos1, pos3, p) == nil)
25+
p = core.registered_items["testtools:blocked_pointing_staff"].pointabilities
26+
assert(raycast_with_pointabilities(pos1, pos3, p) == nil)
2727

28-
p = core.registered_items["testtools:ultimate_pointing_staff"].pointabilities
29-
assert(raycast_with_pointabilities(pos1, pos3, p) == pos2)
28+
p = core.registered_items["testtools:ultimate_pointing_staff"].pointabilities
29+
assert(raycast_with_pointabilities(pos1, pos3, p) == pos2)
3030

31-
core.swap_node(pos1, oldnode1)
32-
core.swap_node(pos2, oldnode2)
33-
core.swap_node(pos3, oldnode3)
31+
core.swap_node(pos1, oldnode1)
32+
core.swap_node(pos2, oldnode2)
33+
core.swap_node(pos3, oldnode3)
3434
end
3535

3636
unittests.register("test_raycast_pointabilities", test_raycast_pointabilities, {map=true})

games/devtest/mods/util_commands/init.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,10 @@ minetest.register_chatcommand("dump_wear_bar", {
234234
})
235235

236236
core.register_chatcommand("set_saturation", {
237-
params = "<saturation>",
238-
description = "Set the saturation for current player.",
239-
func = function(player_name, param)
240-
local saturation = tonumber(param)
241-
minetest.get_player_by_name(player_name):set_lighting({saturation = saturation })
242-
end
237+
params = "<saturation>",
238+
description = "Set the saturation for current player.",
239+
func = function(player_name, param)
240+
local saturation = tonumber(param)
241+
minetest.get_player_by_name(player_name):set_lighting({saturation = saturation })
242+
end
243243
})

src/client/client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ void Client::ReceiveAll()
974974
} catch (const con::InvalidIncomingDataException &e) {
975975
infostream << "Client::ReceiveAll(): "
976976
"InvalidIncomingDataException: what()="
977-
<< e.what() << std::endl;
977+
<< e.what() << std::endl;
978978
}
979979
}
980980
}

src/client/clientlauncher.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ bool ClientLauncher::launch_game(std::string &error_message,
503503

504504
auto &worldspec = start_data.world_spec;
505505
infostream << "Selected world: " << worldspec.name
506-
<< " [" << worldspec.path << "]" << std::endl;
506+
<< " [" << worldspec.path << "]" << std::endl;
507507

508508
if (start_data.address.empty()) {
509509
// For singleplayer and local server

src/client/clientmedia.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ void ClientMediaDownloader::startRemoteMediaTransfers()
452452

453453
if (filestatus->received ||
454454
(filestatus->current_remote < 0 &&
455-
!m_outstanding_hash_sets)) {
455+
!m_outstanding_hash_sets)) {
456456
// If we arrive here, we conclusively know that we
457457
// won't fetch this file from a remote server in the
458458
// future. So update the name bound if possible.

src/client/content_cso.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ class SmokePuffCSO: public ClientSimpleObject
5353
bool pos_ok;
5454
MapNode n = env->getMap().getNode(floatToInt(pos, BS), &pos_ok);
5555
light = pos_ok ? decode_light(n.getLightBlend(env->getDayNightRatio(),
56-
env->getGameDef()->ndef()->getLightingFlags(n)))
57-
: 64;
56+
env->getGameDef()->ndef()->getLightingFlags(n)))
57+
: 64;
5858
video::SColor color(255,light,light,light);
5959
m_spritenode->setColor(color);
6060
}

0 commit comments

Comments
 (0)