History

autoload.lua: fix some lint warnings

Fixes: autoload.lua:201:1: setting undefined field filter of global table autoload.lua:209:1: setting undefined field append of global table autoload.lua:322:11: value assigned to variable extensions is unused

Kacper Michajłow committed 2 years ago

Commit a1caa001 parent b4fcf7d1 file · +21 −20Browse files

Unified · Split

TOOLS/lua/autoload.lua+21−20
@@ -198,21 +198,6 @@ function is_ignored(file) · 197 unmodified lines
198 return false198 return false
199end199end
200 200
201table.filter = function(t, iter)
202 for i = #t, 1, -1 do
203 if not iter(t[i]) then
204 table.remove(t, i)
205 end
206 end
207end
208
209table.append = function(t1, t2)
210 local t1_size = #t1
211 for i = 1, #t2 do
212 t1[t1_size + i] = t2[i]
213 end
214end
215
216-- alphanum sorting for humans in Lua201-- alphanum sorting for humans in Lua
217-- http://notebook.kulchenko.com/algorithms/alphanumeric-natural-sorting-for-humans-in-lua202-- http://notebook.kulchenko.com/algorithms/alphanumeric-natural-sorting-for-humans-in-lua
218 203
@@ -245,7 +230,16 @@ function scan_dir(path, current_file, dir_mode, separator, dir_depth, total_file · 26 unmodified lines
245 local files = utils.readdir(path, "files") or {}230 local files = utils.readdir(path, "files") or {}
246 local dirs = dir_mode ~= "ignore" and utils.readdir(path, "dirs") or {}231 local dirs = dir_mode ~= "ignore" and utils.readdir(path, "dirs") or {}
247 local prefix = path == "." and "" or path232 local prefix = path == "." and "" or path
248 table.filter(files, function (v)233
234 local filter = function(t, iter)
235 for i = #t, 1, -1 do
236 if not iter(t[i]) then
237 table.remove(t, i)
238 end
239 end
240 end
241
242 filter(files, function (v)
249 -- The current file could be a hidden file, ignoring it doesn't load other243 -- The current file could be a hidden file, ignoring it doesn't load other
250 -- files from the current directory.244 -- files from the current directory.
251 local current = prefix .. v == current_file245 local current = prefix .. v == current_file
@@ -262,7 +256,7 @@ function scan_dir(path, current_file, dir_mode, separator, dir_depth, total_file · 10 unmodified lines
262 end256 end
263 return extensions[string.lower(ext)]257 return extensions[string.lower(ext)]
264 end)258 end)
265 table.filter(dirs, function(d)259 filter(dirs, function(d)
266 return not ((o.ignore_hidden and string.match(d, "^%.")))260 return not ((o.ignore_hidden and string.match(d, "^%.")))
267 end)261 end)
268 alphanumsort(files)262 alphanumsort(files)
@@ -272,7 +266,14 @@ function scan_dir(path, current_file, dir_mode, separator, dir_depth, total_file · 3 unmodified lines
272 files[i] = prefix .. file266 files[i] = prefix .. file
273 end267 end
274 268
275 table.append(total_files, files)269 local append = function(t1, t2)
270 local t1_size = #t1
271 for i = 1, #t2 do
272 t1[t1_size + i] = t2[i]
273 end
274 end
275
276 append(total_files, files)
276 if dir_mode == "recursive" then277 if dir_mode == "recursive" then
277 for _, dir in ipairs(dirs) do278 for _, dir in ipairs(dirs) do
278 scan_dir(prefix .. dir .. separator, current_file, dir_mode,279 scan_dir(prefix .. dir .. separator, current_file, dir_mode,
@@ -282,7 +283,7 @@ function scan_dir(path, current_file, dir_mode, separator, dir_depth, total_file · 3 unmodified lines
282 for i, dir in ipairs(dirs) do283 for i, dir in ipairs(dirs) do
283 dirs[i] = prefix .. dir284 dirs[i] = prefix .. dir
284 end285 end
285 table.append(total_files, dirs)286 append(total_files, dirs)
286 end287 end
287end288end
288 289
@@ -319,7 +320,7 @@ function find_and_add_entries() · 30 unmodified lines
319 end320 end
320 end321 end
321 322
322 local extensions = {}323 local extensions
323 if o.same_type then324 if o.same_type then
324 if EXTENSIONS_VIDEO[string.lower(this_ext)] ~= nil then325 if EXTENSIONS_VIDEO[string.lower(this_ext)] ~= nil then
325 extensions = EXTENSIONS_VIDEO326 extensions = EXTENSIONS_VIDEO

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t