2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00

[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.
This commit is contained in:
Frans de Jonge 2019-01-31 18:10:58 +01:00 committed by GitHub
parent b68cdc202d
commit c0c4bcdace
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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