Fix #1122 - Handle notes for shellcheck errors again, and use type 'I' for notes

This commit is contained in:
w0rp
2017-11-13 16:08:09 +00:00
parent a5f7f51c9a
commit 6c112dd1cc
2 changed files with 76 additions and 1 deletions

View File

@@ -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',
\})