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

Showing the changes to TOOLS/lua/autoload.lua (1 of 1 file). Show all

Unified · Split

TOOLS/lua/autoload.lua+21−20
@@ -198,21 +198,6 @@ function is_ignored(file) · 197 unmodified lines
198198 return false
199199 end
200200
201−table.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
207−end
208−
209−table.append = function(t1, t2)
210− local t1_size = #t1
211− for i = 1, #t2 do
212− t1[t1_size + i] = t2[i]
213− end
214−end
215−
216201 -- alphanum sorting for humans in Lua
217202 -- http://notebook.kulchenko.com/algorithms/alphanumeric-natural-sorting-for-humans-in-lua
218203
@@ -245,7 +230,16 @@ function scan_dir(path, current_file, dir_mode, separator, dir_depth, total_file · 26 unmodified lines
245230 local files = utils.readdir(path, "files") or {}
246231 local dirs = dir_mode ~= "ignore" and utils.readdir(path, "dirs") or {}
247232 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)
249243 -- The current file could be a hidden file, ignoring it doesn't load other
250244 -- files from the current directory.
251245 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
262256 end
263257 return extensions[string.lower(ext)]
264258 end)
265− table.filter(dirs, function(d)
259+ filter(dirs, function(d)
266260 return not ((o.ignore_hidden and string.match(d, "^%.")))
267261 end)
268262 alphanumsort(files)
@@ -272,7 +266,14 @@ function scan_dir(path, current_file, dir_mode, separator, dir_depth, total_file · 3 unmodified lines
272266 files[i] = prefix .. file
273267 end
274268
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)
276277 if dir_mode == "recursive" then
277278 for _, dir in ipairs(dirs) do
278279 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
282283 for i, dir in ipairs(dirs) do
283284 dirs[i] = prefix .. dir
284285 end
285− table.append(total_files, dirs)
286+ append(total_files, dirs)
286287 end
287288 end
288289
@@ -319,7 +320,7 @@ function find_and_add_entries() · 30 unmodified lines
319320 end
320321 end
321322
322− local extensions = {}
323+ local extensions
323324 if o.same_type then
324325 if EXTENSIONS_VIDEO[string.lower(this_ext)] ~= nil then
325326 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