summaryrefslogtreecommitdiff
path: root/ale_linters/ruby/reek.vim
diff options
context:
space:
mode:
Diffstat (limited to 'ale_linters/ruby/reek.vim')
-rw-r--r--ale_linters/ruby/reek.vim29
1 files changed, 8 insertions, 21 deletions
diff --git a/ale_linters/ruby/reek.vim b/ale_linters/ruby/reek.vim
index 26f6e36c..e39e366f 100644
--- a/ale_linters/ruby/reek.vim
+++ b/ale_linters/ruby/reek.vim
@@ -6,26 +6,11 @@ call ale#Set('ruby_reek_show_wiki_link', 0)
call ale#Set('ruby_reek_options', '')
call ale#Set('ruby_reek_executable', 'reek')
-function! ale_linters#ruby#reek#VersionCheck(buffer) abort
- " If we have previously stored the version number in a cache, then
- " don't look it up again.
- if ale#semver#HasVersion('reek')
- " Returning an empty string skips this command.
- return ''
- endif
-
- let l:executable = ale#Var(a:buffer, 'ruby_reek_executable')
-
- return ale#handlers#ruby#EscapeExecutable(l:executable, 'reek')
- \ . ' --version'
-endfunction
-
-function! ale_linters#ruby#reek#GetCommand(buffer, version_output) abort
- let l:version = ale#semver#GetVersion('reek', a:version_output)
+function! ale_linters#ruby#reek#GetCommand(buffer, version) abort
let l:executable = ale#Var(a:buffer, 'ruby_reek_executable')
" Tell reek what the filename is if the version of reek is new enough.
- let l:display_name_args = ale#semver#GTE(l:version, [5, 0, 0])
+ let l:display_name_args = ale#semver#GTE(a:version, [5, 0, 0])
\ ? ' --stdin-filename %s'
\ : ''
@@ -70,9 +55,11 @@ endfunction
call ale#linter#Define('ruby', {
\ 'name': 'reek',
\ 'executable': {b -> ale#Var(b, 'ruby_reek_executable')},
-\ 'command_chain': [
-\ {'callback': 'ale_linters#ruby#reek#VersionCheck'},
-\ {'callback': 'ale_linters#ruby#reek#GetCommand'},
-\ ],
+\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
+\ buffer,
+\ ale#Var(buffer, 'ruby_reek_executable'),
+\ '%e --version',
+\ function('ale_linters#ruby#reek#GetCommand'),
+\ )},
\ 'callback': 'ale_linters#ruby#reek#Handle',
\})