diff options
author | w0rp <devw0rp@gmail.com> | 2017-10-26 00:48:51 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-10-26 00:48:51 +0100 |
commit | 5917de565d4e89c73e69727848b7fba3e2730c57 (patch) | |
tree | 53d826663a779d33259e7a0e9a5b18755a300ffa | |
parent | 2f5b94e07d3a9a2fbd7ebf26dc15cbe158eb738f (diff) | |
download | ale-5917de565d4e89c73e69727848b7fba3e2730c57.zip |
Fix #491 - Use -x for shellcheck for checking files with sourced files
-rw-r--r-- | ale_linters/sh/shellcheck.vim | 5 | ||||
-rw-r--r-- | test/command_callback/test_shellcheck_command_callback.vader | 22 |
2 files changed, 20 insertions, 7 deletions
diff --git a/ale_linters/sh/shellcheck.vim b/ale_linters/sh/shellcheck.vim index b47ba19f..68844a05 100644 --- a/ale_linters/sh/shellcheck.vim +++ b/ale_linters/sh/shellcheck.vim @@ -43,11 +43,12 @@ function! ale_linters#sh#shellcheck#GetCommand(buffer) abort let l:exclude_option = ale#Var(a:buffer, 'sh_shellcheck_exclusions') let l:dialect = ale_linters#sh#shellcheck#GetDialectArgument(a:buffer) - return ale_linters#sh#shellcheck#GetExecutable(a:buffer) + return ale#path#BufferCdString(a:buffer) + \ . ale#Escape(ale_linters#sh#shellcheck#GetExecutable(a:buffer)) \ . (!empty(l:dialect) ? ' -s ' . l:dialect : '') \ . (!empty(l:options) ? ' ' . l:options : '') \ . (!empty(l:exclude_option) ? ' -e ' . l:exclude_option : '') - \ . ' -f gcc -' + \ . ' -x -f gcc -' endfunction call ale#linter#Define('sh', { diff --git a/test/command_callback/test_shellcheck_command_callback.vader b/test/command_callback/test_shellcheck_command_callback.vader index 8e229056..13e9a2c1 100644 --- a/test/command_callback/test_shellcheck_command_callback.vader +++ b/test/command_callback/test_shellcheck_command_callback.vader @@ -9,6 +9,12 @@ Before: runtime ale_linters/sh/shellcheck.vim + call ale#test#SetDirectory('/testplugin/test/command_callback') + call ale#test#SetFilename('test.sh') + + let b:prefix = 'cd ' . ale#Escape(ale#path#Winify(g:dir)) . ' && ' + let b:suffix = ' -x -f gcc -' + After: Restore @@ -16,19 +22,22 @@ After: unlet! b:ale_sh_shellcheck_executable unlet! b:ale_sh_shellcheck_options unlet! b:is_bash + unlet! b:prefix + + call ale#test#RestoreDirectory() call ale#linter#Reset() Execute(The default shellcheck command should be correct): AssertEqual - \ 'shellcheck -f gcc -', + \ b:prefix . ale#Escape('shellcheck') . b:suffix, \ ale_linters#sh#shellcheck#GetCommand(bufnr('')) Execute(The shellcheck command should accept options): let b:ale_sh_shellcheck_options = '--foobar' AssertEqual - \ 'shellcheck --foobar -f gcc -', + \ b:prefix . ale#Escape('shellcheck') . ' --foobar' . b:suffix, \ ale_linters#sh#shellcheck#GetCommand(bufnr('')) Execute(The shellcheck command should accept options and exclusions): @@ -36,14 +45,14 @@ Execute(The shellcheck command should accept options and exclusions): let b:ale_sh_shellcheck_exclusions = 'foo,bar' AssertEqual - \ 'shellcheck --foobar -e foo,bar -f gcc -', + \ b:prefix . ale#Escape('shellcheck') . ' --foobar -e foo,bar' . b:suffix, \ ale_linters#sh#shellcheck#GetCommand(bufnr('')) Execute(The shellcheck command should include the dialect): let b:is_bash = 1 AssertEqual - \ 'shellcheck -s bash -f gcc -', + \ b:prefix . ale#Escape('shellcheck') . ' -s bash' . b:suffix, \ ale_linters#sh#shellcheck#GetCommand(bufnr('')) Execute(The shellcheck command should include the dialect before options and exclusions): @@ -52,5 +61,8 @@ Execute(The shellcheck command should include the dialect before options and exc let b:ale_sh_shellcheck_exclusions = 'foo,bar' AssertEqual - \ 'shellcheck -s bash --foobar -e foo,bar -f gcc -', + \ b:prefix + \ . ale#Escape('shellcheck') + \ . ' -s bash --foobar -e foo,bar' + \ . b:suffix, \ ale_linters#sh#shellcheck#GetCommand(bufnr('')) |