lint: Don't assign values that will never be used

No bugs here, but giving an initial value can hide cases where we fail
to set a value. Use an assert instead so we can see errors if we change
and break this code.

Except break_next which goes out of scope after it's assigned (I guess
it used to be outside the loop).
This commit is contained in:
David Briscoe 2022-03-03 00:01:20 -08:00
parent 5118cc42bb
commit 0c193d7901
4 changed files with 4 additions and 4 deletions

View File

@ -4,7 +4,6 @@ return {
"211", -- Unused local variable. "211", -- Unused local variable.
"212/self", -- Unused argument self. "212/self", -- Unused argument self.
"213", -- Unused loop variable. "213", -- Unused loop variable.
"311", -- Value assigned to a local variable is unused.
"631", -- Line is too long. "631", -- Line is too long.
}, },
files = { files = {

View File

@ -136,7 +136,7 @@ function colour.rgb_to_hsl(r, g, b)
local l, d = max + min, max - min local l, d = max + min, max - min
local s = d / (l > 1 and (2 - l) or l) local s = d / (l > 1 and (2 - l) or l)
l = l / 2 l = l / 2
local h = nil --depends on below local h --depends on below
if max == r then if max == r then
h = (g - b) / d h = (g - b) / d
if g < b then h = h + 6 end if g < b then h = h + 6 end
@ -145,6 +145,7 @@ function colour.rgb_to_hsl(r, g, b)
else else
h = (r - g) / d + 4 h = (r - g) / d + 4
end end
assert(h)
return h / 6, s, l return h / 6, s, l
end end

View File

@ -186,7 +186,7 @@ function intersect.line_line_collide(a_start, a_end, a_rad, b_start, b_end, b_ra
local numerb = dx1 * dyab - dy1 * dxab local numerb = dx1 * dyab - dy1 * dxab
--check coincident lines --check coincident lines
local intersected = "none" local intersected
if if
math.abs(numera) < COLLIDE_EPS and math.abs(numera) < COLLIDE_EPS and
math.abs(numerb) < COLLIDE_EPS and math.abs(numerb) < COLLIDE_EPS and
@ -215,6 +215,7 @@ function intersect.line_line_collide(a_start, a_end, a_rad, b_start, b_end, b_ra
end end
end end
end end
assert(intersected)
if intersected == "both" then if intersected == "both" then
--simply displace along A normal --simply displace along A normal

View File

@ -153,7 +153,6 @@ function pretty._process(input, config, processing_state)
end end
if break_next then if break_next then
table.insert(line_chunks, table.remove(chunks, 1)) table.insert(line_chunks, table.remove(chunks, 1))
break_next = false
end end
end end
chunks = line_chunks chunks = line_chunks