more luacheck fixes

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

@ -71,7 +71,7 @@ script:
- make all - make all
- travis_retry make testfront - travis_retry make testfront
- luajit $(which luacheck) --no-color -q frontend | tee ./luacheck.out - 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: after_success:
- make coverage - make coverage

@ -22,7 +22,8 @@ local Font = require("ui/font")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local _ = require("gettext") local _ = require("gettext")
function getDefaultDir()
local function getDefaultDir()
if Device:isKindle() then if Device:isKindle() then
return "/mnt/us/documents" return "/mnt/us/documents"
elseif Device:isKobo() then elseif Device:isKobo() then
@ -34,7 +35,7 @@ function getDefaultDir()
end end
end end
function restoreScreenMode() local function restoreScreenMode()
local screen_mode = G_reader_settings:readSetting("fm_screen_mode") local screen_mode = G_reader_settings:readSetting("fm_screen_mode")
if Screen:getScreenMode() ~= screen_mode then if Screen:getScreenMode() ~= screen_mode then
Screen:setScreenMode(screen_mode or "portrait") Screen:setScreenMode(screen_mode or "portrait")
@ -273,7 +274,7 @@ function FileManager:deleteFile(file)
local is_doc = DocumentRegistry:getProvider(file_abs_path) local is_doc = DocumentRegistry:getProvider(file_abs_path)
ok, err = os.remove(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 if is_doc ~= nil then
-- also delete history/settings for documents -- also delete history/settings for documents
local sidecar_dir = docsettings:getSidecarDir(file_abs_path) local sidecar_dir = docsettings:getSidecarDir(file_abs_path)
@ -281,7 +282,8 @@ function FileManager:deleteFile(file)
util.purgeDir(sidecar_dir) util.purgeDir(sidecar_dir)
end end
local legacy_history_file = docsettings:getHistoryPath(file) 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 end
UIManager:show(InfoMessage:new{ UIManager:show(InfoMessage:new{
text = util.template(_("Successfully deleted %1"), file), 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, checked_func = function() return self.ui.file_chooser.show_hidden end,
callback = function() self.ui:toggleHiddenFiles() 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, self.ui:getSortingMenuTable())
table.insert(self.tab_item_table.setting, { table.insert(self.tab_item_table.setting, {
text = _("Reverse sorting"), text = _("Reverse sorting"),
@ -125,10 +124,10 @@ function FileManagerMenu:setUpdateItemTable()
table.insert(self.tab_item_table.tools, { table.insert(self.tab_item_table.tools, {
text = _("OPDS catalog"), text = _("OPDS catalog"),
callback = function() callback = function()
local FileManager = require("apps/filemanager/filemanager")
local OPDSCatalog = require("apps/opdscatalog/opdscatalog") local OPDSCatalog = require("apps/opdscatalog/opdscatalog")
function OPDSCatalog:onExit() function OPDSCatalog:onExit()
DEBUG("refresh filemanager") FileManager:onRefresh()
filemanager:onRefresh()
end end
OPDSCatalog:showCatalog() OPDSCatalog:showCatalog()
end, end,

@ -1,7 +1,7 @@
local ffi = require("ffi") local ffi = require("ffi")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local MessageQueue = require("ui/message/messagequeue") 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 czmq = ffi.load("libs/libczmq.so.1")
local filemq = ffi.load("libs/libfmq.so.1") local filemq = ffi.load("libs/libfmq.so.1")

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

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

@ -1,10 +1,8 @@
local ffi = require("ffi") local ffi = require("ffi")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local util = require("ffi/util")
local Event = require("ui/event")
local MessageQueue = require("ui/message/messagequeue") 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 czmq = ffi.load("libs/libczmq.so.1")
local zyre = ffi.load("libs/libzyre.so.1") local zyre = ffi.load("libs/libzyre.so.1")

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

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

Loading…
Cancel
Save