Fix more issues discovered by luacheck

This commit is contained in:
Starbeamrainbowlabs 2021-07-30 19:52:36 +01:00
parent 64ed01132e
commit 3c414f2dbd
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 9 additions and 3 deletions

View file

@ -2,11 +2,17 @@ quiet = 1
codes = true codes = true
exclude_files = { exclude_files = {
".luarocks/*" ".luarocks/*",
"worldeditadditions/utils/bit.lua"
} }
ignore = {"631", "61[124]", "412", "21[123]"} ignore = {
"631", "61[124]",
"412",
"321/bit",
"21[123]"
}
-- Read-write globals (i.e. they can be defined) -- Read-write globals (i.e. they can be defined)
globals = { globals = {

View file

@ -5,7 +5,7 @@
-- @param decimals number The number of decimal places to show. -- @param decimals number The number of decimal places to show.
-- @return string A formatted string that represents the given input number. -- @return string A formatted string that represents the given input number.
function worldeditadditions.format.human_size(n, decimals) function worldeditadditions.format.human_size(n, decimals)
sizes = { "", "K", "M", "G", "T", "P", "E", "Y", "Z" } local sizes = { "", "K", "M", "G", "T", "P", "E", "Y", "Z" }
local factor = math.floor((#tostring(n) - 1) / 3) local factor = math.floor((#tostring(n) - 1) / 3)
local multiplier = 10^(decimals or 0) local multiplier = 10^(decimals or 0)
local result = math.floor(0.5 + (n / math.pow(1000, factor)) * multiplier) / multiplier local result = math.floor(0.5 + (n / math.pow(1000, factor)) * multiplier) / multiplier