diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2018-04-20 13:12:18 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-04-23 11:14:55 -0300 |
commit | 315773caf4ee32c440df27d2339ad0f00460e8c5 (patch) | |
tree | 5099a421ef5b5caf833822acd98287e863584199 | |
parent | 846534767fe4623005d60963d9e4e5f8660c1857 (diff) | |
download | luarocks-315773caf4ee32c440df27d2339ad0f00460e8c5.tar.gz luarocks-315773caf4ee32c440df27d2339ad0f00460e8c5.tar.bz2 luarocks-315773caf4ee32c440df27d2339ad0f00460e8c5.zip |
Some luacheck cleanups
-rw-r--r-- | src/luarocks/build.lua | 1 | ||||
-rw-r--r-- | src/luarocks/core/util.lua | 15 | ||||
-rw-r--r-- | src/luarocks/repos.lua | 4 | ||||
-rw-r--r-- | src/luarocks/search.lua | 2 | ||||
-rw-r--r-- | 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 | |||
164 | assert(type(need_to_fetch) == "boolean") | 164 | assert(type(need_to_fetch) == "boolean") |
165 | assert(type(namespace) == "string" or not namespace) | 165 | assert(type(namespace) == "string" or not namespace) |
166 | 166 | ||
167 | local ok | ||
167 | local rockspec, err, errcode = fetch.load_rockspec(rockspec_file) | 168 | local rockspec, err, errcode = fetch.load_rockspec(rockspec_file) |
168 | if err then | 169 | if err then |
169 | return nil, err, errcode | 170 | 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 | |||
45 | -- Written by Julio Manuel Fernandez-Diaz, | 45 | -- Written by Julio Manuel Fernandez-Diaz, |
46 | -- Heavily based on "Saving tables with cycles", PIL2, p. 113. | 46 | -- Heavily based on "Saving tables with cycles", PIL2, p. 113. |
47 | -- @param t table: is the table. | 47 | -- @param t table: is the table. |
48 | -- @param name string: is the name of the table (optional) | 48 | -- @param tname string: is the name of the table (optional) |
49 | -- @param indent string: is a first indentation (optional). | 49 | -- @param top_indent string: is a first indentation (optional). |
50 | -- @return string: the pretty-printed table | 50 | -- @return string: the pretty-printed table |
51 | function util.show_table(t, name, indent) | 51 | function util.show_table(t, tname, top_indent) |
52 | local cart -- a container | 52 | local cart -- a container |
53 | local autoref -- for self references | 53 | local autoref -- for self references |
54 | 54 | ||
55 | local function is_empty_table(t) return next(t) == nil end | 55 | local function is_empty_table(tbl) return next(tbl) == nil end |
56 | 56 | ||
57 | local function basic_serialize (o) | 57 | local function basic_serialize (o) |
58 | local so = tostring(o) | 58 | local so = tostring(o) |
@@ -87,7 +87,6 @@ function util.show_table(t, name, indent) | |||
87 | autoref = autoref .. name .. " = " .. saved[value] .. ";\n" | 87 | autoref = autoref .. name .. " = " .. saved[value] .. ";\n" |
88 | else | 88 | else |
89 | saved[value] = name | 89 | saved[value] = name |
90 | --if tablecount(value) == 0 then | ||
91 | if is_empty_table(value) then | 90 | if is_empty_table(value) then |
92 | cart = cart .. " = {};\n" | 91 | cart = cart .. " = {};\n" |
93 | else | 92 | else |
@@ -105,12 +104,12 @@ function util.show_table(t, name, indent) | |||
105 | end | 104 | end |
106 | end | 105 | end |
107 | 106 | ||
108 | name = name or "__unnamed__" | 107 | tname = tname or "__unnamed__" |
109 | if type(t) ~= "table" then | 108 | if type(t) ~= "table" then |
110 | return name .. " = " .. basic_serialize(t) | 109 | return tname .. " = " .. basic_serialize(t) |
111 | end | 110 | end |
112 | cart, autoref = "", "" | 111 | cart, autoref = "", "" |
113 | add_to_cart(t, name, indent) | 112 | add_to_cart(t, tname, top_indent) |
114 | return cart .. autoref | 113 | return cart .. autoref |
115 | end | 114 | end |
116 | 115 | ||
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) | |||
136 | 136 | ||
137 | local rock_manifest = manif.load_rock_manifest(name, version) | 137 | local rock_manifest = manif.load_rock_manifest(name, version) |
138 | if rock_manifest and rock_manifest.bin then | 138 | if rock_manifest and rock_manifest.bin then |
139 | for name, md5 in pairs(rock_manifest.bin) do | 139 | for bin_name, md5 in pairs(rock_manifest.bin) do |
140 | -- TODO verify that it is the same file. If it isn't, find the actual command. | 140 | -- TODO verify that it is the same file. If it isn't, find the actual command. |
141 | if fs.is_actual_binary(dir.path(cfg.deploy_bin_dir, name)) then | 141 | if fs.is_actual_binary(dir.path(cfg.deploy_bin_dir, bin_name)) then |
142 | return true | 142 | return true |
143 | end | 143 | end |
144 | end | 144 | 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) | |||
351 | 351 | ||
352 | local version = nil | 352 | local version = nil |
353 | local repo_url | 353 | local repo_url |
354 | local package, versions = util.sortedpairs(result_tree)() | 354 | local _, versions = util.sortedpairs(result_tree)() |
355 | --question: what do we do about multiple versions? This should | 355 | --question: what do we do about multiple versions? This should |
356 | --give us the latest version on the last repo (which is usually the global one) | 356 | --give us the latest version on the last repo (which is usually the global one) |
357 | for vs, repositories in util.sortedpairs(versions, vers.compare_versions) do | 357 | 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 | |||
21 | function Api:load_config() | 21 | function Api:load_config() |
22 | local upload_conf = upload_config_file() | 22 | local upload_conf = upload_config_file() |
23 | if not upload_conf then return nil end | 23 | if not upload_conf then return nil end |
24 | local cfg, err = persist.load_into_table(upload_conf) | 24 | local config, err = persist.load_into_table(upload_conf) |
25 | return cfg | 25 | return config |
26 | end | 26 | end |
27 | 27 | ||
28 | function Api:save_config() | 28 | function Api:save_config() |