From 315773caf4ee32c440df27d2339ad0f00460e8c5 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Fri, 20 Apr 2018 13:12:18 -0300 Subject: Some luacheck cleanups --- src/luarocks/build.lua | 1 + src/luarocks/core/util.lua | 15 +++++++-------- src/luarocks/repos.lua | 4 ++-- src/luarocks/search.lua | 2 +- src/luarocks/upload/api.lua | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index f7de616d..dfc54cb8 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua @@ -164,6 +164,7 @@ function build.build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_m assert(type(need_to_fetch) == "boolean") assert(type(namespace) == "string" or not namespace) + local ok local rockspec, err, errcode = fetch.load_rockspec(rockspec_file) if err then return nil, err, errcode diff --git a/src/luarocks/core/util.lua b/src/luarocks/core/util.lua index 99fd1618..68fd931d 100644 --- a/src/luarocks/core/util.lua +++ b/src/luarocks/core/util.lua @@ -45,14 +45,14 @@ end -- Written by Julio Manuel Fernandez-Diaz, -- Heavily based on "Saving tables with cycles", PIL2, p. 113. -- @param t table: is the table. --- @param name string: is the name of the table (optional) --- @param indent string: is a first indentation (optional). +-- @param tname string: is the name of the table (optional) +-- @param top_indent string: is a first indentation (optional). -- @return string: the pretty-printed table -function util.show_table(t, name, indent) +function util.show_table(t, tname, top_indent) local cart -- a container local autoref -- for self references - local function is_empty_table(t) return next(t) == nil end + local function is_empty_table(tbl) return next(tbl) == nil end local function basic_serialize (o) local so = tostring(o) @@ -87,7 +87,6 @@ function util.show_table(t, name, indent) autoref = autoref .. name .. " = " .. saved[value] .. ";\n" else saved[value] = name - --if tablecount(value) == 0 then if is_empty_table(value) then cart = cart .. " = {};\n" else @@ -105,12 +104,12 @@ function util.show_table(t, name, indent) end end - name = name or "__unnamed__" + tname = tname or "__unnamed__" if type(t) ~= "table" then - return name .. " = " .. basic_serialize(t) + return tname .. " = " .. basic_serialize(t) end cart, autoref = "", "" - add_to_cart(t, name, indent) + add_to_cart(t, tname, top_indent) return cart .. autoref end diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua index 00e7d3b8..1464db96 100644 --- a/src/luarocks/repos.lua +++ b/src/luarocks/repos.lua @@ -136,9 +136,9 @@ function repos.has_binaries(name, version) local rock_manifest = manif.load_rock_manifest(name, version) if rock_manifest and rock_manifest.bin then - for name, md5 in pairs(rock_manifest.bin) do + for bin_name, md5 in pairs(rock_manifest.bin) do -- TODO verify that it is the same file. If it isn't, find the actual command. - if fs.is_actual_binary(dir.path(cfg.deploy_bin_dir, name)) then + if fs.is_actual_binary(dir.path(cfg.deploy_bin_dir, bin_name)) then return true end end diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua index 0edef10a..9b4ec88b 100644 --- a/src/luarocks/search.lua +++ b/src/luarocks/search.lua @@ -351,7 +351,7 @@ function search.pick_installed_rock(query, given_tree) local version = nil local repo_url - local package, versions = util.sortedpairs(result_tree)() + local _, versions = util.sortedpairs(result_tree)() --question: what do we do about multiple versions? This should --give us the latest version on the last repo (which is usually the global one) for vs, repositories in util.sortedpairs(versions, vers.compare_versions) do diff --git a/src/luarocks/upload/api.lua b/src/luarocks/upload/api.lua index a9afd1af..f541e896 100644 --- a/src/luarocks/upload/api.lua +++ b/src/luarocks/upload/api.lua @@ -21,8 +21,8 @@ end function Api:load_config() local upload_conf = upload_config_file() if not upload_conf then return nil end - local cfg, err = persist.load_into_table(upload_conf) - return cfg + local config, err = persist.load_into_table(upload_conf) + return config end function Api:save_config() -- cgit v1.2.3-55-g6feb