From a34fb0a6a7f920cd4d9a3e50facf51f8d5defea2 Mon Sep 17 00:00:00 2001 From: Bart Libert Date: Thu, 20 Oct 2016 13:30:45 +0200 Subject: Add support for cppcheck (#126) * Add support for cppcheck * Fix vint error in cppcheck handler * Add vader test for CppCheck format handler --- autoload/ale/handlers.vim | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'autoload') diff --git a/autoload/ale/handlers.vim b/autoload/ale/handlers.vim index cca35d46..5322bfb2 100644 --- a/autoload/ale/handlers.vim +++ b/autoload/ale/handlers.vim @@ -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: " -- cgit v1.2.3