From c0c4bcdace7121133ffd5f19f9848e040261801c Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Thu, 31 Jan 2019 18:10:58 +0100 Subject: [PATCH] [chore, CI] Ensure no whitespace between gettext() call and string (#4530) Follow-up to https://github.com/koreader/koreader/pull/4524 The regex in the Python wasn't actually picking up on that style of writing it at all, because it's not only ugly, but also so counter-intuitive that I overlooked to test for and add support for it. ``` _( [[ ``` It'd be easy to fix up the Python regex a little, and perhaps I will, but either way it makes more sense to automatically enforce this as a coding standard. --- .ci/check.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.ci/check.sh b/.ci/check.sh index 8a9a20702..894444ef7 100755 --- a/.ci/check.sh +++ b/.ci/check.sh @@ -23,10 +23,17 @@ fi 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 - echo -e "\\n${ANSI_RED}Error TAB character detected" + echo -e "\\n${ANSI_RED}Warning: tab character detected. Please use spaces." echo "${tab_detected}" exit 1 fi +newline_split=$(grep -Pzo "(_|gettext)\((\n|\s)+('|\"|\[\[)" --include \*.lua --exclude={dateparser.lua,xml.lua} --recursive {reader,setupkoenv,datastorage}.lua frontend plugins spec || true) +if [ "${newline_split}" ]; then + echo -e "\\n${ANSI_RED}Warning: whitespace detected between gettext() call and string." + echo "${newline_split}" + exit 1 +fi + echo -e "\n${ANSI_GREEN}Luacheck results" luajit "$(which luacheck)" --no-color -q {reader,setupkoenv,datastorage}.lua frontend plugins spec