Download:
child 319:e2f4e8c5795c
parent 317:fce877c8a1cc
318:1c0790b558b7
Anton Shestakov <av6@dwimlabs.net>, Sun, 15 Oct 2017 09:55:04 +0800
linters: add shellcheck (installed from repos), it's useful in some cases

4 файлов изменено, 20 вставок(+), 0 удалений(-) [+]
dockerfiles/ubuntu-xenial file | annotate | diff | comparison | revisions
incoming.py file | annotate | diff | comparison | revisions
linters/shellcheck.yml file | annotate | diff | comparison | revisions
tests/test_incoming.py file | annotate | diff | comparison | revisions
--- a/dockerfiles/ubuntu-xenial Mon Oct 09 21:26:13 2017 +0800
+++ b/dockerfiles/ubuntu-xenial Sun Oct 15 09:55:04 2017 +0800
@@ -14,6 +14,7 @@
unzip \
npm \
virtualenv \
+ shellcheck \
&& rm -rf /var/lib/apt/lists/*
RUN useradd worker --create-home --user-group
--- a/incoming.py Mon Oct 09 21:26:13 2017 +0800
+++ b/incoming.py Sun Oct 15 09:55:04 2017 +0800
@@ -58,6 +58,10 @@
# jshint
(r'.* \((E\d{3})\)$', 'error'),
(r'.* \((W\d{3})\)$', 'warning'),
+
+ # shellcheck
+ (r'^(?:warning|note): .* \[(SC\d{4})\]$', 'warning'),
+ (r'^error: .* \[(SC\d{4})\]$', 'error'),
)
for regex, cls in patterns:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/linters/shellcheck.yml Sun Oct 15 09:55:04 2017 +0800
@@ -0,0 +1,3 @@
+exec: ['shellcheck']
+flags: ['--format', 'gcc']
+version: ['--version']
--- a/tests/test_incoming.py Mon Oct 09 21:26:13 2017 +0800
+++ b/tests/test_incoming.py Sun Oct 15 09:55:04 2017 +0800
@@ -53,6 +53,18 @@
assert extra['link_start'] == 0
assert extra['link_end'] == 17
+ # shellcheck
+ errors, warnings, extra = mlo('helper.sh:121:5: note: hello. [SC1234]')
+ assert errors == 0
+ assert warnings == 1
+ assert set(extra) == usual_keys | {'code'}
+ assert extra['cls'] == 'warning'
+ assert extra['code'] == 'SC1234'
+ assert extra['filename'] == 'helper.sh'
+ assert extra['line_number'] == 121
+ assert extra['link_start'] == 0
+ assert extra['link_end'] == 13
+
# generic
errors, warnings, extra = mlo('requirements.txt:5:1: PIL is obsolete.')
assert errors == 0