diff options
author | Christoph Koehler <ckoehle@sandia.gov> | 2019-06-03 21:49:51 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2019-06-03 21:54:23 +0100 |
commit | 4129c356e85ef05836d2dd726cae679ae7f4afc9 (patch) | |
tree | 682612020651417ee4b38be423d9b96f058cc3e7 /ale_linters | |
parent | c6a5cbb3c737261bc46477733b3aa26203eb63d9 (diff) | |
download | ale-4129c356e85ef05836d2dd726cae679ae7f4afc9.zip |
Fix #1279 - Run cppcheck differently when modified
cppcheck is now run without the --project option and from the buffer's
directory instead when the buffer has been modified. Saving the buffer
will get results by linting the project instead.
Diffstat (limited to 'ale_linters')
-rw-r--r-- | ale_linters/c/cppcheck.vim | 13 | ||||
-rw-r--r-- | ale_linters/cpp/cppcheck.vim | 13 |
2 files changed, 10 insertions, 16 deletions
diff --git a/ale_linters/c/cppcheck.vim b/ale_linters/c/cppcheck.vim index b2ded90f..309b2851 100644 --- a/ale_linters/c/cppcheck.vim +++ b/ale_linters/c/cppcheck.vim @@ -5,20 +5,17 @@ call ale#Set('c_cppcheck_executable', 'cppcheck') call ale#Set('c_cppcheck_options', '--enable=style') function! ale_linters#c#cppcheck#GetCommand(buffer) abort - " Search upwards from the file for compile_commands.json. - " - " If we find it, we'll `cd` to where the compile_commands.json file is, - " then use the file to set up import paths, etc. - let [l:dir, l:json_path] = ale#c#FindCompileCommands(a:buffer) - let l:cd_command = !empty(l:dir) ? ale#path#CdString(l:dir) : '' - let l:compile_commands_option = !empty(l:json_path) - \ ? '--project=' . ale#Escape(l:json_path[len(l:dir) + 1: ]) + let l:cd_command = ale#handlers#cppcheck#GetCdCommand(a:buffer) + 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) \ : '' return l:cd_command \ . '%e -q --language=c' \ . ale#Pad(l:compile_commands_option) \ . ale#Pad(ale#Var(a:buffer, 'c_cppcheck_options')) + \ . l:buffer_path_include \ . ' %t' endfunction diff --git a/ale_linters/cpp/cppcheck.vim b/ale_linters/cpp/cppcheck.vim index dae0774e..7cd80dbc 100644 --- a/ale_linters/cpp/cppcheck.vim +++ b/ale_linters/cpp/cppcheck.vim @@ -5,20 +5,17 @@ call ale#Set('cpp_cppcheck_executable', 'cppcheck') call ale#Set('cpp_cppcheck_options', '--enable=style') function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort - " Search upwards from the file for compile_commands.json. - " - " If we find it, we'll `cd` to where the compile_commands.json file is, - " then use the file to set up import paths, etc. - let [l:dir, l:json_path] = ale#c#FindCompileCommands(a:buffer) - let l:cd_command = !empty(l:dir) ? ale#path#CdString(l:dir) : '' - let l:compile_commands_option = !empty(l:json_path) - \ ? '--project=' . ale#Escape(l:json_path[len(l:dir) + 1: ]) + let l:cd_command = ale#handlers#cppcheck#GetCdCommand(a:buffer) + 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) \ : '' return l:cd_command \ . '%e -q --language=c++' \ . ale#Pad(l:compile_commands_option) \ . ale#Pad(ale#Var(a:buffer, 'cpp_cppcheck_options')) + \ . l:buffer_path_include \ . ' %t' endfunction |