diff options
author | w0rp <devw0rp@gmail.com> | 2017-11-13 16:08:09 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-11-13 16:08:09 +0000 |
commit | 6c112dd1cc0225d2549f364b5e8a7693755634c2 (patch) | |
tree | 00ab4f019d336f1bf538c528cf4f0390be2aacd5 /ale_linters/sh | |
parent | a5f7f51c9a13f103a51cb91b6abdd53fade3600a (diff) | |
download | ale-6c112dd1cc0225d2549f364b5e8a7693755634c2.zip |
Fix #1122 - Handle notes for shellcheck errors again, and use type 'I' for notes
Diffstat (limited to 'ale_linters/sh')
-rw-r--r-- | ale_linters/sh/shellcheck.vim | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/ale_linters/sh/shellcheck.vim b/ale_linters/sh/shellcheck.vim index e79b3b88..3e60ad31 100644 --- a/ale_linters/sh/shellcheck.vim +++ b/ale_linters/sh/shellcheck.vim @@ -70,6 +70,41 @@ function! ale_linters#sh#shellcheck#GetCommand(buffer, version_output) abort \ . ' -f gcc -' endfunction +function! ale_linters#sh#shellcheck#Handle(buffer, lines) abort + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)?:? ([^:]+): (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if l:match[4] is# 'error' + let l:type = 'E' + elseif l:match[4] is# 'note' + let l:type = 'I' + else + let l:type = 'W' + endif + + let l:item = { + \ 'lnum': str2nr(l:match[2]), + \ 'type': l:type, + \ 'text': l:match[5], + \} + + if !empty(l:match[3]) + let l:item.col = str2nr(l:match[3]) + endif + + " If the filename is something like <stdin>, <nofile> or -, then + " this is an error for the file we checked. + if l:match[1] isnot# '-' && l:match[1][0] isnot# '<' + let l:item['filename'] = l:match[1] + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + call ale#linter#Define('sh', { \ 'name': 'shellcheck', \ 'executable_callback': 'ale_linters#sh#shellcheck#GetExecutable', @@ -77,5 +112,5 @@ call ale#linter#Define('sh', { \ {'callback': 'ale_linters#sh#shellcheck#VersionCheck'}, \ {'callback': 'ale_linters#sh#shellcheck#GetCommand'}, \ ], -\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', +\ 'callback': 'ale_linters#sh#shellcheck#Handle', \}) |