2017-09-07 04:26:20 +00:00
#!/usr/bin/env bash
CI_DIR = " $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd ) "
# shellcheck source=/dev/null
source " ${ CI_DIR } /common.sh "
2024-06-15 20:54:31 +00:00
exit_code = 0
2017-09-07 04:26:20 +00:00
2024-06-15 20:54:31 +00:00
echo -e " \n ${ ANSI_GREEN } shellcheck results ${ ANSI_RESET } "
" ${ CI_DIR } /helper_shellchecks.sh " || exit_code = 1
echo -e " \\n ${ ANSI_GREEN } Checking for unscaled sizes ${ ANSI_RESET } "
2017-09-07 04:26:20 +00:00
# stick `|| true` at the end to prevent Travis exit on failed command
2019-12-30 15:20:31 +00:00
unscaled_size_check = $( grep -nr --include= *.lua --exclude= koptoptions.lua --exclude-dir= base --exclude-dir= luajit-rocks --exclude-dir= install --exclude-dir= keyboardlayouts --exclude-dir= *arm* "\\(padding\\|margin\\|bordersize\\|width\\|height\\|radius\\|linesize\\) = [0-9]\\{1,2\\}" | grep -v '= 0' | grep -v '= [0-9]/[0-9]' | grep -Ev '(default_option_height|default_option_padding)' | grep -v scaleBySize | grep -v 'unscaled_size_check: ignore' || true )
2017-09-07 04:26:20 +00:00
# Also check Geom objects; for legibility two regular expressions rather than
# one enormous indecipharable blob.
2017-10-08 14:33:59 +00:00
unscaled_size_check_geom = $( grep -E -nr --include= *.lua --exclude= gesturerange_spec.lua --exclude-dir= base --exclude-dir= luajit-rocks --exclude-dir= *arm* 'Geom:new{.+ [wh] = [0-9]{1,4}' | grep -Ev '[wh] = 0' | grep -v '= [0-9]/[0-9]' | grep -v scaleBySize || true )
2017-09-07 04:26:20 +00:00
if [ " ${ unscaled_size_check } " ] || [ " ${ unscaled_size_check_geom } " ] ; then
2024-06-15 20:54:31 +00:00
echo -e " \\n ${ ANSI_RED } Warning: it looks like you might be using unscaled sizes.\\nIt is almost always preferable to defer to one of the predefined sizes in ui.size in the following files: ${ ANSI_RESET } "
2017-09-07 04:26:20 +00:00
echo " ${ unscaled_size_check } "
echo " ${ unscaled_size_check_geom } "
2024-06-15 20:54:31 +00:00
exit_code = 1
2017-09-07 04:26:20 +00:00
fi
2018-04-29 13:15:11 +00:00
tab_detected = $( grep -P "\\t" --include \* .lua --exclude= { dateparser.lua,xml.lua} --recursive { reader,setupkoenv,datastorage} .lua frontend plugins spec || true )
if [ " ${ tab_detected } " ] ; then
2024-06-15 20:54:31 +00:00
echo -e " \\n ${ ANSI_RED } Warning: tab character detected. Please use spaces. ${ ANSI_RESET } "
2018-04-29 13:15:11 +00:00
echo " ${ tab_detected } "
2024-06-15 20:54:31 +00:00
exit_code = 1
2018-04-29 13:15:11 +00:00
fi
2019-08-26 13:49:50 +00:00
untagged_todo = $( grep -Pin "[^\-]\-\-(\s+)?@?(todo|fixme|warning)" --include \* .lua --exclude= { dateparser.lua,xml.lua} --recursive { reader,setupkoenv,datastorage} .lua frontend plugins spec || true )
2019-08-23 17:53:53 +00:00
if [ " ${ untagged_todo } " ] ; then
echo -e " \\n ${ ANSI_RED } Warning: possible improperly tagged todo, fixme or warning detected. "
2024-06-15 20:54:31 +00:00
echo -e " \\n ${ ANSI_RED } use --- followed by @todo, @fixme or @warning. ${ ANSI_RESET } "
2019-08-23 17:53:53 +00:00
echo " ${ untagged_todo } "
2024-06-15 20:54:31 +00:00
exit_code = 1
2019-01-31 17:10:58 +00:00
fi
2024-06-15 20:54:31 +00:00
echo -e " \n ${ ANSI_GREEN } Luacheck results ${ ANSI_RESET } "
luacheck -q { reader,setupkoenv,datastorage} .lua frontend plugins spec || exit_code = 1
exit ${ exit_code }