cppcheck: update for the new error format. Remove duplicate code.
This commit is contained in:
parent
c10aa8d6d5
commit
d31868a5ba
@ -28,6 +28,10 @@ endif
|
|||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
|
function! SyntaxCheckers_c_cppcheck_Preprocess(errors)
|
||||||
|
return map(copy(a:errors), 'substitute(v:val, ''\v^\[[^]]+\]\zs( -\> \[[^]]+\])+\ze:'', "", "")')
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! SyntaxCheckers_c_cppcheck_GetLocList() dict
|
function! SyntaxCheckers_c_cppcheck_GetLocList() dict
|
||||||
let makeprg = self.makeprgBuild({
|
let makeprg = self.makeprgBuild({
|
||||||
\ 'args': syntastic#c#ReadConfig(g:syntastic_cppcheck_config_file),
|
\ 'args': syntastic#c#ReadConfig(g:syntastic_cppcheck_config_file),
|
||||||
@ -46,6 +50,7 @@ function! SyntaxCheckers_c_cppcheck_GetLocList() dict
|
|||||||
let loclist = SyntasticMake({
|
let loclist = SyntasticMake({
|
||||||
\ 'makeprg': makeprg,
|
\ 'makeprg': makeprg,
|
||||||
\ 'errorformat': errorformat,
|
\ 'errorformat': errorformat,
|
||||||
|
\ 'preprocess': 'SyntaxCheckers_c_cppcheck_Preprocess',
|
||||||
\ 'returns': [0] })
|
\ 'returns': [0] })
|
||||||
|
|
||||||
for e in loclist
|
for e in loclist
|
||||||
|
@ -21,48 +21,11 @@ if exists("g:loaded_syntastic_cpp_cppcheck_checker")
|
|||||||
endif
|
endif
|
||||||
let g:loaded_syntastic_cpp_cppcheck_checker = 1
|
let g:loaded_syntastic_cpp_cppcheck_checker = 1
|
||||||
|
|
||||||
if !exists('g:syntastic_cppcheck_config_file')
|
runtime! syntax_checkers/c/*.vim
|
||||||
let g:syntastic_cppcheck_config_file = '.syntastic_cppcheck_config'
|
|
||||||
endif
|
|
||||||
|
|
||||||
let s:save_cpo = &cpo
|
|
||||||
set cpo&vim
|
|
||||||
|
|
||||||
function! SyntaxCheckers_cpp_cppcheck_GetLocList() dict
|
|
||||||
let makeprg = self.makeprgBuild({
|
|
||||||
\ 'args': syntastic#c#ReadConfig(g:syntastic_cppcheck_config_file),
|
|
||||||
\ 'args_after': '-q --enable=style' })
|
|
||||||
|
|
||||||
let errorformat =
|
|
||||||
\ '[%f:%l]: (%trror) %m,' .
|
|
||||||
\ '[%f:%l]: (%tarning) %m,' .
|
|
||||||
\ '[%f:%l]: (%ttyle) %m,' .
|
|
||||||
\ '[%f:%l]: (%terformance) %m,' .
|
|
||||||
\ '[%f:%l]: (%tortability) %m,' .
|
|
||||||
\ '[%f:%l]: (%tnformation) %m,' .
|
|
||||||
\ '[%f:%l]: (%tnconclusive) %m,' .
|
|
||||||
\ '%-G%.%#'
|
|
||||||
|
|
||||||
let loclist = SyntasticMake({
|
|
||||||
\ 'makeprg': makeprg,
|
|
||||||
\ 'errorformat': errorformat,
|
|
||||||
\ 'returns': [0] })
|
|
||||||
|
|
||||||
for e in loclist
|
|
||||||
if e['type'] =~? '\m^[SPI]'
|
|
||||||
let e['type'] = 'w'
|
|
||||||
let e['subtype'] = 'Style'
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
return loclist
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||||
\ 'filetype': 'cpp',
|
\ 'filetype': 'cpp',
|
||||||
\ 'name': 'cppcheck'})
|
\ 'name': 'cppcheck',
|
||||||
|
\ 'redirect': 'c/cppcheck'})
|
||||||
let &cpo = s:save_cpo
|
|
||||||
unlet s:save_cpo
|
|
||||||
|
|
||||||
" vim: set et sts=4 sw=4:
|
" vim: set et sts=4 sw=4:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user