mirror of
https://github.com/1bardesign/batteries.git
synced 2024-11-22 06:04:35 +00:00
lint: Fix shadow issues
Fix shadowing by using variables with a different name or _. I don't think any of these warnings were actual bugs and fixed them to maintain the same behaviour.
This commit is contained in:
parent
8d41c6d3d1
commit
a5ebc1e501
@ -8,13 +8,6 @@ return {
|
||||
"213", -- Unused loop variable.
|
||||
"231", -- Local variable is set but never accessed.
|
||||
"311", -- Value assigned to a local variable is unused.
|
||||
"412", -- Redefining an argument.
|
||||
"413", -- Redefining a loop variable.
|
||||
"421", -- Shadowing a local variable.
|
||||
"422", -- Shadowing an argument.
|
||||
"423", -- Shadowing a loop variable.
|
||||
"423", -- Shadowing a loop variable.
|
||||
"432", -- Shadowing an upvalue argument.
|
||||
"631", -- Line is too long.
|
||||
},
|
||||
files = {
|
||||
|
@ -75,7 +75,7 @@ end
|
||||
|
||||
--replace everything in assert with nop functions that just return their second argument, for near-zero overhead on release
|
||||
function assert:nop()
|
||||
local nop = function(self, a)
|
||||
local nop = function(_, a)
|
||||
return a
|
||||
end
|
||||
setmetatable(self, {
|
||||
|
@ -209,7 +209,7 @@ end
|
||||
function functional.stitch(t, f)
|
||||
local result = {}
|
||||
for i, v in ipairs(t) do
|
||||
local v = f(v, i)
|
||||
v = f(v, i)
|
||||
if v ~= nil then
|
||||
if type(v) == "table" then
|
||||
for _, e in ipairs(v) do
|
||||
|
14
sort.lua
14
sort.lua
@ -56,8 +56,8 @@ function sort._merge(array, workspace, low, middle, high, less)
|
||||
local i, j, k
|
||||
i = 1
|
||||
-- copy first half of array to auxiliary array
|
||||
for j = low, middle do
|
||||
workspace[i] = array[j]
|
||||
for w = low, middle do
|
||||
workspace[i] = array[w]
|
||||
i = i + 1
|
||||
end
|
||||
-- sieve through
|
||||
@ -78,8 +78,8 @@ function sort._merge(array, workspace, low, middle, high, less)
|
||||
k = k + 1
|
||||
end
|
||||
-- copy back any remaining elements of first half
|
||||
for k = k, j - 1 do
|
||||
array[k] = workspace[i]
|
||||
for w = k, j - 1 do
|
||||
array[w] = workspace[i]
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
@ -121,7 +121,8 @@ end
|
||||
|
||||
function sort.stable_sort(array, less)
|
||||
--setup
|
||||
local trivial, n, less = sort._sort_setup(array, less)
|
||||
local trivial, n
|
||||
trivial, n, less = sort._sort_setup(array, less)
|
||||
if not trivial then
|
||||
--temp storage; allocate ahead of time
|
||||
local workspace = {}
|
||||
@ -135,7 +136,8 @@ end
|
||||
|
||||
function sort.insertion_sort(array, less)
|
||||
--setup
|
||||
local trivial, n, less = sort._sort_setup(array, less)
|
||||
local trivial, n
|
||||
trivial, n, less = sort._sort_setup(array, less)
|
||||
if not trivial then
|
||||
sort._insertion_sort_impl(array, 1, n, less)
|
||||
end
|
||||
|
@ -398,8 +398,8 @@ function tablex.collapse(t)
|
||||
local r = {}
|
||||
for _, v in ipairs(t) do
|
||||
if type(v) == "table" then
|
||||
for _, v in ipairs(v) do
|
||||
table.insert(r, v)
|
||||
for _, w in ipairs(v) do
|
||||
table.insert(r, w)
|
||||
end
|
||||
else
|
||||
table.insert(r, v)
|
||||
|
Loading…
Reference in New Issue
Block a user