Skip to content

Commit

Permalink
Fix #3579 - Escape cppcheck arguments for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
w0rp committed Feb 6, 2021
1 parent 77c0348 commit 388cf33
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ale_linters/c/cppcheck.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function! ale_linters#c#cppcheck#GetCommand(buffer) abort
let l:buffer_path_include = empty(l:compile_commands_option)
\ ? ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer)
\ : ''
let l:template = ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}'''
let l:template = ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')

return l:cd_command
\ . '%e -q --language=c'
Expand Down
2 changes: 1 addition & 1 deletion ale_linters/cpp/cppcheck.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort
let l:buffer_path_include = empty(l:compile_commands_option)
\ ? ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer)
\ : ''
let l:template = ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}'''
let l:template = ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')

return l:cd_command
\ . '%e -q --language=c++'
Expand Down
10 changes: 5 additions & 5 deletions test/command_callback/test_c_cppcheck_command_callbacks.vader
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Before:
call ale#assert#SetUpLinterTest('c', 'cppcheck')
let b:command_tail = ' -q --language=c --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}'' --enable=style -I' . ale#Escape(ale#path#Simplify(g:dir)) .' %t'
let b:command_tail = ' -q --language=c --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}') . ' --enable=style -I' . ale#Escape(ale#path#Simplify(g:dir)) .' %t'

After:
" Remove a test file we might open for some tests.
Expand All @@ -26,7 +26,7 @@ Execute(cppcheck for C should detect compile_commands.json files):
\ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/one'))
\ . ale#Escape('cppcheck')
\ . ' -q --language=c'
\ . ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}'''
\ . ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
\ . ' --project=' . ale#Escape('compile_commands.json')
\ . ' --enable=style %t'

Expand All @@ -37,7 +37,7 @@ Execute(cppcheck for C should detect compile_commands.json files in build direct
\ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/with_build_dir'))
\ . ale#Escape('cppcheck')
\ . ' -q --language=c'
\ . ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}'''
\ . ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
\ . ' --project=' . ale#Escape(ale#path#Simplify('build/compile_commands.json'))
\ . ' --enable=style %t'

Expand All @@ -47,7 +47,7 @@ Execute(cppcheck for C should include file dir if compile_commands.json file is
AssertLinter 'cppcheck',
\ ale#Escape('cppcheck')
\ . ' -q --language=c'
\ . ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}'''
\ . ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
\ . ' --enable=style'
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/cppcheck_paths'))
\ . ' %t'
Expand All @@ -62,7 +62,7 @@ Execute(cppcheck for C should ignore compile_commands.json file if buffer is mod
\ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/one'))
\ . ale#Escape('cppcheck')
\ . ' -q --language=c'
\ . ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}'''
\ . ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
\ . ' --enable=style'
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/cppcheck_paths/one'))
\ . ' %t'
10 changes: 5 additions & 5 deletions test/command_callback/test_cpp_cppcheck_command_callbacks.vader
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Before:
call ale#assert#SetUpLinterTest('cpp', 'cppcheck')
let b:command_tail = ' -q --language=c++ --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}'' --enable=style -I' . ale#Escape(ale#path#Simplify(g:dir)) .' %t'
let b:command_tail = ' -q --language=c++ --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}') . ' --enable=style -I' . ale#Escape(ale#path#Simplify(g:dir)) .' %t'

After:
" Remove a test file we might open for some tests.
Expand All @@ -26,7 +26,7 @@ Execute(cppcheck for C++ should detect compile_commands.json files):
\ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/one'))
\ . ale#Escape('cppcheck')
\ . ' -q --language=c++'
\ . ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}'''
\ . ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
\ . ' --project=' . ale#Escape('compile_commands.json')
\ . ' --enable=style %t'

Expand All @@ -37,7 +37,7 @@ Execute(cppcheck for C++ should detect compile_commands.json files in build dire
\ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/with_build_dir'))
\ . ale#Escape('cppcheck')
\ . ' -q --language=c++'
\ . ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}'''
\ . ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
\ . ' --project=' . ale#Escape(ale#path#Simplify('build/compile_commands.json'))
\ . ' --enable=style %t'

Expand All @@ -47,7 +47,7 @@ Execute(cppcheck for C++ should include file dir if compile_commands.json file i
AssertLinter 'cppcheck',
\ ale#Escape('cppcheck')
\ . ' -q --language=c++'
\ . ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}'''
\ . ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
\ . ' --enable=style'
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/cppcheck_paths'))
\ . ' %t'
Expand All @@ -62,7 +62,7 @@ Execute(cppcheck for C++ should ignore compile_commands.json file if buffer is m
\ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/one'))
\ . ale#Escape('cppcheck')
\ . ' -q --language=c++'
\ . ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}'''
\ . ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
\ . ' --enable=style'
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/cppcheck_paths/one'))
\ . ' %t'

0 comments on commit 388cf33

Please sign in to comment.