Skip to content
Permalink
Browse files

Fix one iteration loop warnings

Use next instead of pairs to test if a table is empty.
  • Loading branch information...
TheCycoONE committed Jun 4, 2018
1 parent 8a06c12 commit 0076539bfdf8635f5135040bdb2da222db05b9d6
Showing with 3 additions and 12 deletions.
  1. +0 −3 .luacheckrc
  2. +2 −5 CorsixTH/Lua/entities/object.lua
  3. +1 −4 CorsixTH/Lua/room.lua
@@ -139,7 +139,6 @@ add_ignore("CorsixTH/Lua/rooms/operating_theatre.lua", "wait_for_ready")
-- W211: unused variable XYZ
-- W212: unused argument XYZ
-- W231: variable XYZ is never accessed
-- W512: loop is executed at most once
-- W542: empty if branch
add_ignore("CorsixTH/CorsixTH.lua", "121")
add_ignore("CorsixTH/Lua/app.lua", "122")
@@ -182,7 +181,6 @@ add_ignore("CorsixTH/Lua/entities/humanoid.lua", "212")
add_ignore("CorsixTH/Lua/entities/inspector.lua", "212")
add_ignore("CorsixTH/Lua/entities/machine.lua", "212")
add_ignore("CorsixTH/Lua/entities/object.lua", "212")
add_ignore("CorsixTH/Lua/entities/object.lua", "512")
add_ignore("CorsixTH/Lua/entities/patient.lua", "212")
add_ignore("CorsixTH/Lua/entities/patient.lua", "542")
add_ignore("CorsixTH/Lua/entities/staff.lua", "212")
@@ -213,7 +211,6 @@ add_ignore("CorsixTH/Lua/objects/machines/operating_table.lua", "542")
add_ignore("CorsixTH/Lua/persistance.lua", "231") -- th_getupvalue assignments in lua5.2/5.3 code
add_ignore("CorsixTH/Lua/research_department.lua", "212")
add_ignore("CorsixTH/Lua/room.lua", "212")
add_ignore("CorsixTH/Lua/room.lua", "512")
add_ignore("CorsixTH/Lua/rooms/cardiogram.lua", "212")
add_ignore("CorsixTH/Lua/rooms/general_diag.lua", "212")
add_ignore("CorsixTH/Lua/rooms/psych.lua", "212")
@@ -296,18 +296,15 @@ end
function Object:setTile(x, y)
local function coordinatesAreInFootprint(object_footprint, xpos, ypos)
for _, xy in ipairs(object_footprint) do
if(xy[1] == xpos and xy[2] == ypos) then
if xy[1] == xpos and xy[2] == ypos then
return true
end
end
return false
end

local function isEmpty(table)
for _, _ in pairs(table) do
return false
end
return true
return next(table) == nil
end

local function getComplementaryPassableFlag(passable_flag)
@@ -258,10 +258,7 @@ function Room:testStaffCriteria(criteria, extra_humanoid)
end
return false
else
for _, _ in pairs(missing) do
return false
end
return true
return next(missing) == nil
end
end

0 comments on commit 0076539

Please sign in to comment.
You can’t perform that action at this time.