more luacheck fixes

pull/1820/head
Qingping Hou 8 years ago
parent 3c647ff244
commit 6a6469fa09

@ -71,7 +71,7 @@ script:
- make all
- travis_retry make testfront
- luajit $(which luacheck) --no-color -q frontend | tee ./luacheck.out
- test $(grep Total ./luacheck.out | awk '{print $2}') -le 168
- test $(grep Total ./luacheck.out | awk '{print $2}') -le 140
after_success:
- make coverage

@ -22,7 +22,8 @@ local Font = require("ui/font")
local DEBUG = require("dbg")
local _ = require("gettext")
function getDefaultDir()
local function getDefaultDir()
if Device:isKindle() then
return "/mnt/us/documents"
elseif Device:isKobo() then
@ -34,7 +35,7 @@ function getDefaultDir()
end
end
function restoreScreenMode()
local function restoreScreenMode()
local screen_mode = G_reader_settings:readSetting("fm_screen_mode")
if Screen:getScreenMode() ~= screen_mode then
Screen:setScreenMode(screen_mode or "portrait")
@ -273,7 +274,7 @@ function FileManager:deleteFile(file)
local is_doc = DocumentRegistry:getProvider(file_abs_path)
ok, err = os.remove(file_abs_path)
if err == nil then
if ok and err == nil then
if is_doc ~= nil then
-- also delete history/settings for documents
local sidecar_dir = docsettings:getSidecarDir(file_abs_path)
@ -281,7 +282,8 @@ function FileManager:deleteFile(file)
util.purgeDir(sidecar_dir)
end
local legacy_history_file = docsettings:getHistoryPath(file)
ok, err = os.remove(legacy_history_file)
-- @todo: check return from os.remove
os.remove(legacy_history_file)
end
UIManager:show(InfoMessage:new{
text = util.template(_("Successfully deleted %1"), file),

@ -85,7 +85,6 @@ function FileManagerMenu:setUpdateItemTable()
checked_func = function() return self.ui.file_chooser.show_hidden end,
callback = function() self.ui:toggleHiddenFiles() end
})
local FileManager = require("apps/filemanager/filemanager")
table.insert(self.tab_item_table.setting, self.ui:getSortingMenuTable())
table.insert(self.tab_item_table.setting, {
text = _("Reverse sorting"),
@ -125,10 +124,10 @@ function FileManagerMenu:setUpdateItemTable()
table.insert(self.tab_item_table.tools, {
text = _("OPDS catalog"),
callback = function()
local FileManager = require("apps/filemanager/filemanager")
local OPDSCatalog = require("apps/opdscatalog/opdscatalog")
function OPDSCatalog:onExit()
DEBUG("refresh filemanager")
filemanager:onRefresh()
FileManager:onRefresh()
end
OPDSCatalog:showCatalog()
end,

@ -1,7 +1,7 @@
local ffi = require("ffi")
local DEBUG = require("dbg")
local MessageQueue = require("ui/message/messagequeue")
local dummy = require("ffi/zeromq_h")
local _ = require("ffi/zeromq_h")
local czmq = ffi.load("libs/libczmq.so.1")
local filemq = ffi.load("libs/libfmq.so.1")

@ -1,11 +1,9 @@
local ffi = require("ffi")
local util = require("ffi/util")
local Event = require("ui/event")
local DEBUG = require("dbg")
local dummy = require("ffi/zeromq_h")
local _ = require("ffi/zeromq_h")
local czmq = ffi.load("libs/libczmq.so.1")
local zyre = ffi.load("libs/libzyre.so.1")
local MessageQueue = {}
@ -39,7 +37,6 @@ function MessageQueue:handleZMsgs(messages)
end
local function pop_string()
local str_p = czmq.zmsg_popstr(messages[1])
local message_size = czmq.zmsg_size(messages[1])
local res = ffi.string(str_p)
czmq.zstr_free(ffi.new('char *[1]', str_p))
drop_message()
@ -64,7 +61,6 @@ function MessageQueue:handleZMsgs(messages)
return header
end
if #messages == 0 then return end
local message_size = czmq.zmsg_size(messages[1])
local command = pop_string()
DEBUG("ØMQ message", command)
if command == "ENTER" then

@ -1,6 +1,5 @@
local ffi = require("ffi")
local DEBUG = require("dbg")
local Event = require("ui/event")
local MessageQueue = require("ui/message/messagequeue")
local _ = require("ffi/zeromq_h")
@ -24,7 +23,8 @@ function StreamMessageQueue:start()
end
local id_size = ffi.new("size_t[1]", 256)
local buffer = ffi.new("uint8_t[?]", id_size[0])
rc = zmq.zmq_getsockopt(self.socket, ffi.C.ZMQ_IDENTITY, buffer, id_size)
-- @todo: check return of zmq_getsockopt
zmq.zmq_getsockopt(self.socket, ffi.C.ZMQ_IDENTITY, buffer, id_size)
self.id = ffi.string(buffer, id_size[0])
DEBUG("id", #self.id, self.id)
end
@ -65,7 +65,7 @@ function StreamMessageQueue:waitEvent()
while czmq.zpoller_wait(self.poller, 0) ~= nil and wait_packages > 0 do
local id_frame = czmq.zframe_recv(self.socket)
if id_frame ~= nil then
local id = self:handleZframe(id_frame)
self:handleZframe(id_frame)
end
local frame = czmq.zframe_recv(self.socket)
if frame ~= nil then

@ -1,10 +1,8 @@
local ffi = require("ffi")
local DEBUG = require("dbg")
local util = require("ffi/util")
local Event = require("ui/event")
local MessageQueue = require("ui/message/messagequeue")
local dummy = require("ffi/zeromq_h")
local _ = require("ffi/zeromq_h")
local czmq = ffi.load("libs/libczmq.so.1")
local zyre = ffi.load("libs/libzyre.so.1")

@ -99,9 +99,9 @@ function FileChooser:genItemTableFromPath(path)
local item_table = {}
for i, dir in ipairs(dirs) do
local path = self.path.."/"..dir.name
local subdir_path = self.path.."/"..dir.name
local items = 0
local ok, iter, dir_obj = pcall(lfs.dir, path)
ok, iter, dir_obj = pcall(lfs.dir, subdir_path)
if ok then
for f in iter, dir_obj do
items = items + 1
@ -116,13 +116,13 @@ function FileChooser:genItemTableFromPath(path)
table.insert(item_table, {
text = dir.name.."/",
mandatory = istr,
path = path
path = subdir_path
})
end
for _, file in ipairs(files) do
local full_path = self.path.."/"..file.name
local file_size = lfs.attributes(full_path, "size") or 0
local sstr = ""
local sstr
if file_size > 1024*1024 then
sstr = string.format("%4.1f MB", file_size/1024/1024)
elseif file_size > 1024 then

@ -149,13 +149,13 @@ function TouchMenuBar:init()
local icon_sep_width = Screen:scaleBySize(2)
local icons_sep_width = icon_sep_width * (#self.icons + 1)
-- we assume all icons are of the same width
local ib = IconButton:new{icon_file = self.icons[1]}
local content_width = ib:getSize().w * #self.icons + icons_sep_width
local tmp_ib = IconButton:new{icon_file = self.icons[1]}
local content_width = tmp_ib:getSize().w * #self.icons + icons_sep_width
local spacing_width = (self.width - content_width)/(#self.icons*2)
local spacing = HorizontalSpan:new{
width = math.min(spacing_width, Screen:scaleBySize(20))
}
self.height = ib:getSize().h + Screen:scaleBySize(10)
self.height = tmp_ib:getSize().h + Screen:scaleBySize(10)
self.show_parent = self.show_parent or self
self.bar_icon_group = HorizontalGroup:new{}
-- build up image widget for menu icon bar
@ -225,7 +225,6 @@ function TouchMenuBar:init()
table.insert(self.bar_icon_group, self.icon_widgets[k])
table.insert(self.bar_icon_group, icon_sep)
start_seg = _start_seg
end_seg = _end_seg
end
@ -451,7 +450,7 @@ function TouchMenu:updateItems()
--VerticalSpan:new{
--width = self.item_height
--})
--break
break
end -- if i <= self.items
end -- for c=1, self.perpage

Loading…
Cancel
Save