Add support for cppcheck (#126)

* Add support for cppcheck

* Fix vint error in cppcheck handler

* Add vader test for CppCheck format handler
This commit is contained in:
Bart Libert
2016-10-20 13:30:45 +02:00
committed by w0rp
parent acb209aa11
commit a34fb0a6a7
6 changed files with 129 additions and 5 deletions

View File

@@ -45,7 +45,6 @@ function! ale#handlers#HandleUnixFormatAsWarning(buffer, lines) abort
return s:HandleUnixFormat(a:buffer, a:lines, 'W')
endfunction
function! ale#handlers#HandleGCCFormat(buffer, lines) abort
" Look for lines like the following.
"
@@ -76,6 +75,35 @@ function! ale#handlers#HandleGCCFormat(buffer, lines) abort
return l:output
endfunction
function! ale#handlers#HandleCppCheckFormat(buffer, lines) abort
" Look for lines like the following.
"
" [test.cpp:5]: (error) Array 'a[10]' accessed at index 10, which is out of bounds
let l:pattern = '^\[.\{-}:\(\d\+\)\]: (\(.\{-}\)) \(.\+\)'
let l:output = []
for l:line in a:lines
let l:match = matchlist(l:line, l:pattern)
if len(l:match) == 0
continue
endif
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': 0,
\ 'text': l:match[3] . ' (' . l:match[2] . ')',
\ 'type': l:match[2] ==# 'error' ? 'E' : 'W',
\ 'nr': -1,
\})
endfor
return l:output
endfunction
function! ale#handlers#HandleCSSLintFormat(buffer, lines) abort
" Matches patterns line the following:
"