mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
minor: various luacheck fixes
This commit is contained in:
@@ -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 196
|
||||
- test $(grep Total ./luacheck.out | awk '{print $2}') -le 168
|
||||
|
||||
after_success:
|
||||
- make coverage
|
||||
|
||||
@@ -9,8 +9,8 @@ local DownloadMgr = {
|
||||
onConfirm = function() end,
|
||||
}
|
||||
|
||||
function DownloadMgr:new(o)
|
||||
local o = o or {}
|
||||
function DownloadMgr:new(from_o)
|
||||
local o = from_o or {}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
return o
|
||||
|
||||
@@ -70,7 +70,7 @@ function Font:getFace(font, size)
|
||||
if not size then size = self.sizemap[font] end
|
||||
-- original size before scaling by screen DPI
|
||||
local orig_size = size
|
||||
local size = Screen:scaleBySize(size)
|
||||
size = Screen:scaleBySize(size)
|
||||
|
||||
local hash = font..size
|
||||
local face_obj = self.faces[hash]
|
||||
@@ -81,7 +81,7 @@ function Font:getFace(font, size)
|
||||
realname = font
|
||||
end
|
||||
realname = self.fontdir.."/"..realname
|
||||
ok, face = pcall(Freetype.newFace, realname, size)
|
||||
local ok, face = pcall(Freetype.newFace, realname, size)
|
||||
if not ok then
|
||||
DEBUG("#! Font "..font.." ("..realname..") not supported: "..face)
|
||||
return nil
|
||||
|
||||
@@ -20,7 +20,7 @@ local Geom = {
|
||||
}
|
||||
|
||||
function Geom:new(o)
|
||||
local o = o or {}
|
||||
if not o then o = {} end
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
return o
|
||||
|
||||
@@ -2,7 +2,6 @@ local InfoMessage = require("ui/widget/infomessage")
|
||||
local ConfirmBox = require("ui/widget/confirmbox")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Device = require("device")
|
||||
local DEBUG = require("dbg")
|
||||
local T = require("ffi/util").template
|
||||
local _ = require("gettext")
|
||||
local NetworkMgr = {}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
--]]
|
||||
local util = require("ffi/util")
|
||||
local luxl = require("luxl")
|
||||
local DEBUG = require("dbg")
|
||||
local ffi = require("ffi")
|
||||
|
||||
local OPDSParser = {}
|
||||
@@ -18,7 +17,7 @@ local unescape_map = {
|
||||
["apos"] = "'"
|
||||
}
|
||||
|
||||
local gsub, char = string.gsub, string.char
|
||||
local gsub = string.gsub
|
||||
local function unescape(str)
|
||||
return gsub(str, '(&(#?)([%d%a]+);)', function(orig, n, s)
|
||||
return unescape_map[s] or n=="#" and util.unichar(tonumber(s)) or orig
|
||||
|
||||
@@ -75,7 +75,7 @@ function OTAManager:checkUpdate()
|
||||
local local_zsync_file = ota_dir .. zsync_file
|
||||
-- download zsync file from OTA server
|
||||
DEBUG("downloading zsync file", ota_zsync_file)
|
||||
local r, c, h = http.request{
|
||||
local _, c, _ = http.request{
|
||||
url = ota_zsync_file,
|
||||
sink = ltn12.sink.file(io.open(local_zsync_file, "w"))}
|
||||
if c ~= 200 then
|
||||
|
||||
@@ -5,8 +5,8 @@ local TimeVal = {
|
||||
usec = 0,
|
||||
}
|
||||
|
||||
function TimeVal:new(o)
|
||||
local o = o or {}
|
||||
function TimeVal:new(from_o)
|
||||
local o = from_o or {}
|
||||
if o.sec == nil then
|
||||
o.sec = 0
|
||||
end
|
||||
|
||||
@@ -55,7 +55,8 @@ function Translator:loadPage(target_lang, source_lang, text)
|
||||
DEBUG("request", request)
|
||||
http.TIMEOUT, https.TIMEOUT = 10, 10
|
||||
local httpRequest = parsed.scheme == 'http' and http.request or https.request
|
||||
local code, headers, status = socket.skip(1, httpRequest(request))
|
||||
-- first argument returned by skip is code
|
||||
local _, headers, status = socket.skip(1, httpRequest(request))
|
||||
|
||||
-- raise error message when network is unavailable
|
||||
if headers == nil then
|
||||
|
||||
@@ -9,7 +9,6 @@ local HorizontalGroup = require("ui/widget/horizontalgroup")
|
||||
local VerticalSpan = require("ui/widget/verticalspan")
|
||||
local VerticalGroup = require("ui/widget/verticalgroup")
|
||||
local FixedTextWidget = require("ui/widget/fixedtextwidget")
|
||||
local ProgressWidget = require("ui/widget/progresswidget")
|
||||
local ToggleSwitch = require("ui/widget/toggleswitch")
|
||||
local ConfirmBox = require("ui/widget/confirmbox")
|
||||
local ImageWidget = require("ui/widget/imagewidget")
|
||||
@@ -176,9 +175,6 @@ function ConfigOption:init()
|
||||
local item_font_size = self.options[c].item_font_size and self.options[c].item_font_size or default_item_font_size
|
||||
local option_height = Screen:scaleBySize(self.options[c].height and self.options[c].height or default_option_height)
|
||||
local item_spacing_with = self.options[c].spacing and self.options[c].spacing or default_items_spacing
|
||||
local items_spacing = HorizontalSpan:new{
|
||||
width = Screen:scaleBySize(item_spacing_with)
|
||||
}
|
||||
local enabled = true
|
||||
if self.options[c].enabled_func then
|
||||
enabled = self.options[c].enabled_func(self.config.configurable)
|
||||
@@ -224,16 +220,15 @@ function ConfigOption:init()
|
||||
-- check if current value is stored in configurable or calculated in runtime
|
||||
local val = self.options[c].current_func and self.options[c].current_func()
|
||||
or self.config.configurable[self.options[c].name]
|
||||
local min_diff = nil
|
||||
local min_diff
|
||||
if type(val) == "table" then
|
||||
min_diff = value_diff(val[1], self.options[c].values[1][1])
|
||||
else
|
||||
min_diff = value_diff(val, self.options[c].values[1])
|
||||
end
|
||||
|
||||
local diff = nil
|
||||
local diff
|
||||
for index, val_ in pairs(self.options[c].values) do
|
||||
local diff = nil
|
||||
if type(val) == "table" then
|
||||
diff = value_diff(val[1], val_[1])
|
||||
else
|
||||
@@ -277,7 +272,7 @@ function ConfigOption:init()
|
||||
width = math.min(max_item_spacing, Screen:scaleBySize(item_spacing_with))
|
||||
}
|
||||
for d = 1, #self.options[c].item_text do
|
||||
local option_item = nil
|
||||
local option_item
|
||||
if option_items_fixed then
|
||||
option_item = OptionTextItem:new{
|
||||
FixedTextWidget:new{
|
||||
@@ -584,7 +579,7 @@ function ConfigDialog:onMakeDefault(name, name_text, values, labels, position)
|
||||
labels[position]
|
||||
),
|
||||
ok_callback = function()
|
||||
local name = self.config_options.prefix.."_"..name
|
||||
name = self.config_options.prefix.."_"..name
|
||||
G_reader_settings:saveSetting(name, values[position])
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -41,7 +41,7 @@ local Screen = Device.screen
|
||||
|
||||
local ellipsis, space = "...", " "
|
||||
local ellipsis_width, space_width
|
||||
function truncateTextByWidth(text, face, max_width, prepend_space)
|
||||
local function truncateTextByWidth(text, face, max_width, prepend_space)
|
||||
if not ellipsis_width then
|
||||
ellipsis_width = RenderText:sizeUtf8Text(0, max_width, face, ellipsis).x
|
||||
end
|
||||
|
||||
@@ -52,7 +52,8 @@ function Wikipedia:loadPage(text, lang, intro, plain)
|
||||
DEBUG("request", request)
|
||||
http.TIMEOUT, https.TIMEOUT = 10, 10
|
||||
local httpRequest = parsed.scheme == 'http' and http.request or https.request
|
||||
local code, headers, status = socket.skip(1, httpRequest(request))
|
||||
-- first argument returned by skip is code
|
||||
local _, headers, status = socket.skip(1, httpRequest(request))
|
||||
|
||||
-- raise error message when network is unavailable
|
||||
if headers == nil then
|
||||
|
||||
22
kodev
22
kodev
@@ -2,7 +2,7 @@
|
||||
|
||||
CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
function assert_return_zero {
|
||||
function assert_ret_zero {
|
||||
if [ $1 -ne 0 ]; then
|
||||
if [ ! -z $2 ]; then
|
||||
echo $2
|
||||
@@ -45,43 +45,43 @@ ${SUPPORTED_TARGETS}"
|
||||
;;
|
||||
kindle)
|
||||
make TARGET=kindle
|
||||
assert_return_zero $?
|
||||
assert_ret_zero $?
|
||||
;;
|
||||
kobo)
|
||||
make TARGET=kobo
|
||||
assert_return_zero $?
|
||||
assert_ret_zero $?
|
||||
;;
|
||||
kindle-legacy)
|
||||
make TARGET=kindle-legacy
|
||||
assert_return_zero $?
|
||||
assert_ret_zero $?
|
||||
;;
|
||||
android)
|
||||
if [ ! -d ${CURDIR}/base/toolchain/android-toolchain ]; then
|
||||
make android-toolchain
|
||||
assert_return_zero $?
|
||||
assert_ret_zero $?
|
||||
fi
|
||||
make TARGET=android
|
||||
assert_return_zero $?
|
||||
assert_ret_zero $?
|
||||
;;
|
||||
pocketbook)
|
||||
if [ ! -d ${CURDIR}/base/toolchain/pocketbook-toolchain ]; then
|
||||
make pocketbook-toolchain
|
||||
assert_return_zero $?
|
||||
assert_ret_zero $?
|
||||
fi
|
||||
make TARGET=pocketbook
|
||||
assert_return_zero $?
|
||||
assert_ret_zero $?
|
||||
;;
|
||||
ubuntu-touch)
|
||||
make TARGET=ubuntu-touch
|
||||
assert_return_zero $?
|
||||
assert_ret_zero $?
|
||||
;;
|
||||
win32)
|
||||
make TARGET=win32
|
||||
assert_return_zero $?
|
||||
assert_ret_zero $?
|
||||
;;
|
||||
*)
|
||||
make
|
||||
assert_return_zero $? "Failed to build emulator!"
|
||||
assert_ret_zero $? "Failed to build emulator!"
|
||||
setup_env
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -343,9 +343,11 @@ local TestInputText = InputText:new{
|
||||
-----------------------------------------------------
|
||||
local KeyValuePage = require("ui/widget/keyvaluepage")
|
||||
local kvp = KeyValuePage:new{
|
||||
title = 'Statistics',
|
||||
title = 'Statistics This is a very very log item whose length should exceed the width of the men',
|
||||
kv_pairs = {
|
||||
{"1 Current period", "00:00:00"},
|
||||
{"This is a very very log item whose length should exceed the width of the menu.", "value"},
|
||||
{"2 Time to read", "00:00:00 00:00:00 00:00:00 00:00:00"},
|
||||
{"2 Time to read", "00:00:00"},
|
||||
{"3 Time to read", "00:00:00"},
|
||||
{"4 Time to read", "00:00:00"},
|
||||
@@ -377,7 +379,7 @@ local kvp = KeyValuePage:new{
|
||||
--UIManager:show(TestGrid)
|
||||
UIManager:show(TestVisible)
|
||||
UIManager:show(Clock:new())
|
||||
--UIManager:show(M)
|
||||
-- UIManager:show(M)
|
||||
--UIManager:show(Quiz)
|
||||
--UIManager:show(readerwindow)
|
||||
--UIManager:show(touch_menu)
|
||||
|
||||
Reference in New Issue
Block a user