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.
"212/self", -- Unused argument self.
"213", -- Unused loop variable.
"311", -- Value assigned to a local variable is unused.
"631", -- Line is too long.
},
files = {

View File

@ -136,7 +136,7 @@ function colour.rgb_to_hsl(r, g, b)
local l, d = max + min, max - min
local s = d / (l > 1 and (2 - l) or l)
l = l / 2
local h = nil --depends on below
local h --depends on below
if max == r then
h = (g - b) / d
if g < b then h = h + 6 end
@ -145,6 +145,7 @@ function colour.rgb_to_hsl(r, g, b)
else
h = (r - g) / d + 4
end
assert(h)
return h / 6, s, l
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
--check coincident lines
local intersected = "none"
local intersected
if
math.abs(numera) < 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
assert(intersected)
if intersected == "both" then
--simply displace along A normal

View File

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