diff options
Diffstat (limited to 'ale_linters/sh/shellcheck.vim')
-rw-r--r-- | ale_linters/sh/shellcheck.vim | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/ale_linters/sh/shellcheck.vim b/ale_linters/sh/shellcheck.vim index 1f6bdf81..e79b3b88 100644 --- a/ale_linters/sh/shellcheck.vim +++ b/ale_linters/sh/shellcheck.vim @@ -15,8 +15,6 @@ let g:ale_sh_shellcheck_executable = let g:ale_sh_shellcheck_options = \ get(g:, 'ale_sh_shellcheck_options', '') -let s:version_cache = {} - function! ale_linters#sh#shellcheck#GetExecutable(buffer) abort return ale#Var(a:buffer, 'sh_shellcheck_executable') endfunction @@ -49,38 +47,19 @@ function! ale_linters#sh#shellcheck#VersionCheck(buffer) abort let l:executable = ale_linters#sh#shellcheck#GetExecutable(a:buffer) " Don't check the version again if we've already cached it. - if has_key(s:version_cache, l:executable) - return '' - endif - - return ale#Escape(l:executable) . ' --version' -endfunction - -" Get the shellcheck version from the cache, or parse it and cache it. -function! s:GetVersion(executable, output) abort - let l:version = get(s:version_cache, a:executable, []) - - for l:match in ale#util#GetMatches(a:output, '\v\d+\.\d+\.\d+') - let l:version = ale#semver#Parse(l:match[0]) - let s:version_cache[a:executable] = l:version - endfor - - return l:version -endfunction - -function! s:CanUseExternalOption(version) abort - return !empty(a:version) - \ && ale#semver#GreaterOrEqual(a:version, [0, 4, 0]) + return !ale#semver#HasVersion(l:executable) + \ ? ale#Escape(l:executable) . ' --version' + \ : '' endfunction function! ale_linters#sh#shellcheck#GetCommand(buffer, version_output) abort let l:executable = ale_linters#sh#shellcheck#GetExecutable(a:buffer) - let l:version = s:GetVersion(l:executable, a:version_output) + let l:version = ale#semver#GetVersion(l:executable, a:version_output) let l:options = ale#Var(a:buffer, 'sh_shellcheck_options') let l:exclude_option = ale#Var(a:buffer, 'sh_shellcheck_exclusions') let l:dialect = ale_linters#sh#shellcheck#GetDialectArgument(a:buffer) - let l:external_option = s:CanUseExternalOption(l:version) ? ' -x' : '' + let l:external_option = ale#semver#GTE(l:version, [0, 4, 0]) ? ' -x' : '' return ale#path#BufferCdString(a:buffer) \ . ale#Escape(l:executable) |