2016-10-20 11:30:45 +00:00
|
|
|
" Author: Bart Libert <bart.libert@gmail.com>
|
|
|
|
" Description: cppcheck linter for cpp files
|
|
|
|
|
2017-07-16 21:11:43 +00:00
|
|
|
call ale#Set('cpp_cppcheck_executable', 'cppcheck')
|
|
|
|
call ale#Set('cpp_cppcheck_options', '--enable=style')
|
|
|
|
|
2017-04-16 00:24:08 +00:00
|
|
|
function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort
|
2019-06-03 20:49:51 +00:00
|
|
|
let l:compile_commands_option = ale#handlers#cppcheck#GetCompileCommandsOptions(a:buffer)
|
|
|
|
let l:buffer_path_include = empty(l:compile_commands_option)
|
|
|
|
\ ? ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer)
|
2017-05-02 20:18:17 +00:00
|
|
|
\ : ''
|
2021-02-06 20:13:28 +00:00
|
|
|
let l:template = ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
|
2017-05-02 20:18:17 +00:00
|
|
|
|
2021-03-01 20:11:10 +00:00
|
|
|
return '%e -q --language=c++'
|
2020-08-06 19:50:44 +00:00
|
|
|
\ . l:template
|
2019-05-20 21:08:03 +00:00
|
|
|
\ . ale#Pad(l:compile_commands_option)
|
|
|
|
\ . ale#Pad(ale#Var(a:buffer, 'cpp_cppcheck_options'))
|
2019-06-03 20:49:51 +00:00
|
|
|
\ . l:buffer_path_include
|
2017-04-16 00:24:08 +00:00
|
|
|
\ . ' %t'
|
|
|
|
endfunction
|
|
|
|
|
2016-10-20 11:30:45 +00:00
|
|
|
call ale#linter#Define('cpp', {
|
|
|
|
\ 'name': 'cppcheck',
|
|
|
|
\ 'output_stream': 'both',
|
2019-02-22 18:05:04 +00:00
|
|
|
\ 'executable': {b -> ale#Var(b, 'cpp_cppcheck_executable')},
|
2021-03-01 20:11:10 +00:00
|
|
|
\ 'cwd': function('ale#handlers#cppcheck#GetCwd'),
|
2019-02-22 18:05:04 +00:00
|
|
|
\ 'command': function('ale_linters#cpp#cppcheck#GetCommand'),
|
2017-04-24 21:27:18 +00:00
|
|
|
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
|
2016-10-20 11:30:45 +00:00
|
|
|
\})
|