summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2019-04-07 14:58:06 +0100
committerw0rp <devw0rp@gmail.com>2019-04-07 14:58:06 +0100
commit3bebcb5d48a7150f5a318952ee309acb67fb376d (patch)
tree97edd84badca566894fd4c4f10c2a786df2fe079 /ale_linters
parentcdf89f8269aec31d0dfddf3a2769027d72d38155 (diff)
downloadale-3bebcb5d48a7150f5a318952ee309acb67fb376d.zip
#2132 - Replace command_chain and chain_with with ale#command#Run
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/c/clang.vim5
-rw-r--r--ale_linters/c/gcc.vim5
-rw-r--r--ale_linters/cpp/clang.vim5
-rw-r--r--ale_linters/cpp/gcc.vim5
-rw-r--r--ale_linters/d/dmd.vim21
-rw-r--r--ale_linters/erlang/syntaxerl.vim17
-rw-r--r--ale_linters/eruby/erubi.vim17
-rw-r--r--ale_linters/java/javac.vim28
-rwxr-xr-xale_linters/javascript/flow.vim36
-rw-r--r--ale_linters/kotlin/kotlinc.vim41
-rw-r--r--ale_linters/php/phpstan.vim37
-rw-r--r--ale_linters/python/flake8.vim30
-rw-r--r--ale_linters/ruby/reek.vim29
-rw-r--r--ale_linters/rust/cargo.vim28
-rw-r--r--ale_linters/sh/shellcheck.vim34
-rw-r--r--ale_linters/vim/vint.vim36
16 files changed, 147 insertions, 227 deletions
diff --git a/ale_linters/c/clang.vim b/ale_linters/c/clang.vim
index 5b243bfe..681101fc 100644
--- a/ale_linters/c/clang.vim
+++ b/ale_linters/c/clang.vim
@@ -19,9 +19,6 @@ call ale#linter#Define('c', {
\ 'name': 'clang',
\ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'c_clang_executable')},
-\ 'command_chain': [
-\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
-\ {'callback': 'ale_linters#c#clang#GetCommand'}
-\ ],
+\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#clang#GetCommand'))},
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})
diff --git a/ale_linters/c/gcc.vim b/ale_linters/c/gcc.vim
index ccb1912b..d965965d 100644
--- a/ale_linters/c/gcc.vim
+++ b/ale_linters/c/gcc.vim
@@ -19,9 +19,6 @@ call ale#linter#Define('c', {
\ 'name': 'gcc',
\ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'c_gcc_executable')},
-\ 'command_chain': [
-\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
-\ {'callback': 'ale_linters#c#gcc#GetCommand'}
-\ ],
+\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#gcc#GetCommand'))},
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})
diff --git a/ale_linters/cpp/clang.vim b/ale_linters/cpp/clang.vim
index 5a465812..e48291eb 100644
--- a/ale_linters/cpp/clang.vim
+++ b/ale_linters/cpp/clang.vim
@@ -19,9 +19,6 @@ call ale#linter#Define('cpp', {
\ 'name': 'clang',
\ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'cpp_clang_executable')},
-\ 'command_chain': [
-\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
-\ {'callback': 'ale_linters#cpp#clang#GetCommand'},
-\ ],
+\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#clang#GetCommand'))},
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})
diff --git a/ale_linters/cpp/gcc.vim b/ale_linters/cpp/gcc.vim
index 831620d5..c427020b 100644
--- a/ale_linters/cpp/gcc.vim
+++ b/ale_linters/cpp/gcc.vim
@@ -20,9 +20,6 @@ call ale#linter#Define('cpp', {
\ 'aliases': ['g++'],
\ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'cpp_gcc_executable')},
-\ 'command_chain': [
-\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
-\ {'callback': 'ale_linters#cpp#gcc#GetCommand'},
-\ ],
+\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#gcc#GetCommand'))},
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})
diff --git a/ale_linters/d/dmd.vim b/ale_linters/d/dmd.vim
index c816d592..14461ae6 100644
--- a/ale_linters/d/dmd.vim
+++ b/ale_linters/d/dmd.vim
@@ -1,7 +1,7 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: "dmd for D files"
-function! ale_linters#d#dmd#DUBCommand(buffer) abort
+function! ale_linters#d#dmd#GetDUBCommand(buffer) abort
" If we can't run dub, then skip this command.
if !executable('dub')
" Returning an empty string skips to the DMD command.
@@ -21,7 +21,18 @@ function! ale_linters#d#dmd#DUBCommand(buffer) abort
\ . ' && dub describe --import-paths'
endfunction
-function! ale_linters#d#dmd#DMDCommand(buffer, dub_output) abort
+function! ale_linters#d#dmd#RunDUBCommand(buffer) abort
+ let l:command = ale_linters#d#dmd#GetDUBCommand(a:buffer)
+
+ if empty(l:command)
+ " If we can't run DUB, just run DMD.
+ return ale_linters#d#dmd#DMDCommand(a:buffer, [], {})
+ endif
+
+ return ale#command#Run(a:buffer, l:command, function('ale_linters#d#dmd#DMDCommand'))
+endfunction
+
+function! ale_linters#d#dmd#DMDCommand(buffer, dub_output, meta) abort
let l:import_list = []
" Build a list of import paths generated from DUB, if available.
@@ -57,9 +68,7 @@ endfunction
call ale#linter#Define('d', {
\ 'name': 'dmd',
\ 'executable': 'dmd',
-\ 'command_chain': [
-\ {'callback': 'ale_linters#d#dmd#DUBCommand', 'output_stream': 'stdout'},
-\ {'callback': 'ale_linters#d#dmd#DMDCommand', 'output_stream': 'stderr'},
-\ ],
+\ 'command': function('ale_linters#d#dmd#RunDUBCommand'),
\ 'callback': 'ale_linters#d#dmd#Handle',
+\ 'output_stream': 'stderr',
\})
diff --git a/ale_linters/erlang/syntaxerl.vim b/ale_linters/erlang/syntaxerl.vim
index 2b7276a1..5d555a8d 100644
--- a/ale_linters/erlang/syntaxerl.vim
+++ b/ale_linters/erlang/syntaxerl.vim
@@ -3,7 +3,17 @@
call ale#Set('erlang_syntaxerl_executable', 'syntaxerl')
-function! ale_linters#erlang#syntaxerl#GetCommand(buffer, output) abort
+function! ale_linters#erlang#syntaxerl#RunHelpCommand(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'erlang_syntaxerl_executable')
+
+ return ale#command#Run(
+ \ a:buffer,
+ \ ale#Escape(l:executable) . ' -h',
+ \ function('ale_linters#erlang#syntaxerl#GetCommand'),
+ \)
+endfunction
+
+function! ale_linters#erlang#syntaxerl#GetCommand(buffer, output, meta) abort
let l:use_b_option = match(a:output, '\C\V-b, --base\>') > -1
return '%e' . (l:use_b_option ? ' -b %s %t' : ' %t')
@@ -27,9 +37,6 @@ endfunction
call ale#linter#Define('erlang', {
\ 'name': 'syntaxerl',
\ 'executable': {b -> ale#Var(b, 'erlang_syntaxerl_executable')},
-\ 'command_chain': [
-\ {'callback': {-> '%e -h'}},
-\ {'callback': 'ale_linters#erlang#syntaxerl#GetCommand'},
-\ ],
+\ 'command': {b -> ale_linters#erlang#syntaxerl#RunHelpCommand(b)},
\ 'callback': 'ale_linters#erlang#syntaxerl#Handle',
\})
diff --git a/ale_linters/eruby/erubi.vim b/ale_linters/eruby/erubi.vim
index 6f2d3ac6..ddca3f61 100644
--- a/ale_linters/eruby/erubi.vim
+++ b/ale_linters/eruby/erubi.vim
@@ -1,14 +1,10 @@
" Author: Eddie Lebow https://github.com/elebow
" Description: eruby checker using `erubi`
-function! ale_linters#eruby#erubi#CheckErubi(buffer) abort
- return 'ruby -r erubi/capture_end -e ' . ale#Escape('""')
-endfunction
-
-function! ale_linters#eruby#erubi#GetCommand(buffer, check_erubi_output) abort
+function! ale_linters#eruby#erubi#GetCommand(buffer, output, meta) abort
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
- if (!empty(a:check_erubi_output))
+ if !empty(a:output)
" The empty command in CheckErubi returns nothing if erubi runs and
" emits an error if erubi is not present
return ''
@@ -27,9 +23,10 @@ endfunction
call ale#linter#Define('eruby', {
\ 'name': 'erubi',
\ 'executable': 'ruby',
-\ 'command_chain': [
-\ {'callback': 'ale_linters#eruby#erubi#CheckErubi'},
-\ {'callback': 'ale_linters#eruby#erubi#GetCommand', 'output_stream': 'stderr'},
-\ ],
+\ 'command': {buffer -> ale#command#Run(
+\ buffer,
+\ 'ruby -r erubi/capture_end -e ' . ale#Escape('""'),
+\ function('ale_linters#eruby#erubi#GetCommand'),
+\ )},
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
\})
diff --git a/ale_linters/java/javac.vim b/ale_linters/java/javac.vim
index 50cabacd..7ca95ba5 100644
--- a/ale_linters/java/javac.vim
+++ b/ale_linters/java/javac.vim
@@ -7,21 +7,29 @@ call ale#Set('java_javac_executable', 'javac')
call ale#Set('java_javac_options', '')
call ale#Set('java_javac_classpath', '')
-function! ale_linters#java#javac#GetImportPaths(buffer) abort
+function! ale_linters#java#javac#RunWithImportPaths(buffer) abort
+ let l:command = ''
let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml')
if !empty(l:pom_path) && executable('mvn')
- return ale#path#CdString(fnamemodify(l:pom_path, ':h'))
+ let l:command = ale#path#CdString(fnamemodify(l:pom_path, ':h'))
\ . 'mvn dependency:build-classpath'
endif
- let l:classpath_command = ale#gradle#BuildClasspathCommand(a:buffer)
+ " Try to use Gradle if Maven isn't available.
+ if empty(l:command)
+ let l:command = ale#gradle#BuildClasspathCommand(a:buffer)
+ endif
- if !empty(l:classpath_command)
- return l:classpath_command
+ if empty(l:command)
+ return ale_linters#java#javac#GetCommand(a:buffer, [], {})
endif
- return ''
+ return ale#command#Run(
+ \ a:buffer,
+ \ l:command,
+ \ function('ale_linters#java#javac#GetCommand')
+ \)
endfunction
function! s:BuildClassPathOption(buffer, import_paths) abort
@@ -37,7 +45,7 @@ function! s:BuildClassPathOption(buffer, import_paths) abort
\ : ''
endfunction
-function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort
+function! ale_linters#java#javac#GetCommand(buffer, import_paths, meta) abort
let l:cp_option = s:BuildClassPathOption(a:buffer, a:import_paths)
let l:sp_option = ''
@@ -120,9 +128,7 @@ endfunction
call ale#linter#Define('java', {
\ 'name': 'javac',
\ 'executable': {b -> ale#Var(b, 'java_javac_executable')},
-\ 'command_chain': [
-\ {'callback': 'ale_linters#java#javac#GetImportPaths', 'output_stream': 'stdout'},
-\ {'callback': 'ale_linters#java#javac#GetCommand', 'output_stream': 'stderr'},
-\ ],
+\ 'command': function('ale_linters#java#javac#RunWithImportPaths'),
+\ 'output_stream': 'stderr',
\ 'callback': 'ale_linters#java#javac#Handle',
\})
diff --git a/ale_linters/javascript/flow.vim b/ale_linters/javascript/flow.vim
index 05aae030..3135e2e9 100755
--- a/ale_linters/javascript/flow.vim
+++ b/ale_linters/javascript/flow.vim
@@ -27,32 +27,13 @@ function! ale_linters#javascript#flow#GetExecutable(buffer) abort
\])
endfunction
-function! ale_linters#javascript#flow#VersionCheck(buffer) abort
- let l:executable = ale_linters#javascript#flow#GetExecutable(a:buffer)
-
- if empty(l:executable)
- return ''
- endif
-
- return ale#Escape(l:executable) . ' --version'
-endfunction
-
-function! ale_linters#javascript#flow#GetCommand(buffer, version_lines) abort
- let l:executable = ale_linters#javascript#flow#GetExecutable(a:buffer)
-
- if empty(l:executable)
- return ''
- endif
-
- let l:version = ale#semver#GetVersion(l:executable, a:version_lines)
-
+function! ale_linters#javascript#flow#GetCommand(buffer, version) abort
" If we can parse the version number, then only use --respect-pragma
" if the version is >= 0.36.0, which added the argument.
let l:use_respect_pragma = ale#Var(a:buffer, 'javascript_flow_use_respect_pragma')
- \ && (empty(l:version) || ale#semver#GTE(l:version, [0, 36]))
+ \ && (empty(a:version) || ale#semver#GTE(a:version, [0, 36]))
- return ale#Escape(l:executable)
- \ . ' check-contents'
+ return '%e check-contents'
\ . (l:use_respect_pragma ? ' --respect-pragma': '')
\ . ' --json --from ale %s < %t'
\ . (!has('win32') ? '; echo' : '')
@@ -87,7 +68,6 @@ function! s:ExtraErrorMsg(current, new) abort
return l:newMsg
endfunction
-
function! s:GetDetails(error) abort
let l:detail = ''
@@ -169,10 +149,12 @@ endfunction
call ale#linter#Define('javascript', {
\ 'name': 'flow',
\ 'executable': function('ale_linters#javascript#flow#GetExecutable'),
-\ 'command_chain': [
-\ {'callback': 'ale_linters#javascript#flow#VersionCheck'},
-\ {'callback': 'ale_linters#javascript#flow#GetCommand'},
-\ ],
+\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
+\ buffer,
+\ ale_linters#javascript#flow#GetExecutable(buffer),
+\ '%e --version',
+\ function('ale_linters#javascript#flow#GetCommand'),
+\ )},
\ 'callback': 'ale_linters#javascript#flow#Handle',
\ 'read_buffer': 0,
\})
diff --git a/ale_linters/kotlin/kotlinc.vim b/ale_linters/kotlin/kotlinc.vim
index 32dcc6d1..fddd6625 100644
--- a/ale_linters/kotlin/kotlinc.vim
+++ b/ale_linters/kotlin/kotlinc.vim
@@ -11,26 +11,33 @@ let g:ale_kotlin_kotlinc_module_filename = get(g:, 'ale_kotlin_kotlinc_module_fi
let s:classpath_sep = has('unix') ? ':' : ';'
-function! ale_linters#kotlin#kotlinc#GetImportPaths(buffer) abort
+function! ale_linters#kotlin#kotlinc#RunWithImportPaths(buffer) abort
" exec maven/gradle only if classpath is not set
if ale#Var(a:buffer, 'kotlin_kotlinc_classpath') isnot# ''
- return ''
- else
- let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml')
+ return ale_linters#kotlin#kotlinc#GetCommand(a:buffer, [], {})
+ endif
- if !empty(l:pom_path) && executable('mvn')
- return ale#path#CdString(fnamemodify(l:pom_path, ':h'))
- \ . 'mvn dependency:build-classpath'
- endif
+ let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml')
- let l:classpath_command = ale#gradle#BuildClasspathCommand(a:buffer)
+ if !empty(l:pom_path) && executable('mvn')
+ let l:command = ale#path#CdString(fnamemodify(l:pom_path, ':h'))
+ \ . 'mvn dependency:build-classpath'
+ endif
- if !empty(l:classpath_command)
- return l:classpath_command
- endif
+ " Try to use Gradle if Maven isn't available.
+ if empty(l:command)
+ let l:command = ale#gradle#BuildClasspathCommand(a:buffer)
+ endif
- return ''
+ if empty(l:command)
+ return ale_linters#kotlin#kotlinc#GetCommand(a:buffer, [], {})
endif
+
+ return ale#command#Run(
+ \ a:buffer,
+ \ l:command,
+ \ function('ale_linters#kotlin#kotlinc#GetCommand')
+ \)
endfunction
function! s:BuildClassPathOption(buffer, import_paths) abort
@@ -46,7 +53,7 @@ function! s:BuildClassPathOption(buffer, import_paths) abort
\ : ''
endfunction
-function! ale_linters#kotlin#kotlinc#GetCommand(buffer, import_paths) abort
+function! ale_linters#kotlin#kotlinc#GetCommand(buffer, import_paths, meta) abort
let l:kotlinc_opts = ale#Var(a:buffer, 'kotlin_kotlinc_options')
let l:command = 'kotlinc '
@@ -165,11 +172,7 @@ endfunction
call ale#linter#Define('kotlin', {
\ 'name': 'kotlinc',
\ 'executable': 'kotlinc',
-\ 'command_chain': [
-\ {'callback': 'ale_linters#kotlin#kotlinc#GetImportPaths', 'output_stream': 'stdout'},
-\ {'callback': 'ale_linters#kotlin#kotlinc#GetCommand', 'output_stream': 'stderr'},
-\ ],
+\ 'command': function('ale_linters#kotlin#kotlinc#RunWithImportPaths'),
\ 'callback': 'ale_linters#kotlin#kotlinc#Handle',
\ 'lint_file': 1,
\})
-
diff --git a/ale_linters/php/phpstan.vim b/ale_linters/php/phpstan.vim
index 34d4e799..ecd80a83 100644
--- a/ale_linters/php/phpstan.vim
+++ b/ale_linters/php/phpstan.vim
@@ -6,34 +6,13 @@ let g:ale_php_phpstan_executable = get(g:, 'ale_php_phpstan_executable', 'phpsta
let g:ale_php_phpstan_level = get(g:, 'ale_php_phpstan_level', '4')
let g:ale_php_phpstan_configuration = get(g:, 'ale_php_phpstan_configuration', '')
-function! ale_linters#php#phpstan#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'php_phpstan_executable')
-endfunction
-
-function! ale_linters#php#phpstan#VersionCheck(buffer) abort
- let l:executable = ale_linters#php#phpstan#GetExecutable(a:buffer)
-
- " If we have previously stored the version number in a cache, then
- " don't look it up again.
- if ale#semver#HasVersion(l:executable)
- " Returning an empty string skips this command.
- return ''
- endif
-
- let l:executable = ale#Escape(l:executable)
-
- return l:executable . ' --version'
-endfunction
-
-function! ale_linters#php#phpstan#GetCommand(buffer, version_output) abort
+function! ale_linters#php#phpstan#GetCommand(buffer, version) abort
let l:configuration = ale#Var(a:buffer, 'php_phpstan_configuration')
let l:configuration_option = !empty(l:configuration)
\ ? ' -c ' . l:configuration
\ : ''
- let l:executable = ale_linters#php#phpstan#GetExecutable(a:buffer)
- let l:version = ale#semver#GetVersion(l:executable, a:version_output)
- let l:error_format = ale#semver#GTE(l:version, [0, 10, 3])
+ let l:error_format = ale#semver#GTE(a:version, [0, 10, 3])
\ ? ' --error-format raw'
\ : ' --errorFormat raw'
@@ -65,10 +44,12 @@ endfunction
call ale#linter#Define('php', {
\ 'name': 'phpstan',
-\ 'executable': function('ale_linters#php#phpstan#GetExecutable'),
-\ 'command_chain': [
-\ {'callback': 'ale_linters#php#phpstan#VersionCheck'},
-\ {'callback': 'ale_linters#php#phpstan#GetCommand'},
-\ ],
+\ 'executable': {b -> ale#Var(b, 'php_phpstan_executable')},
+\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
+\ buffer,
+\ ale#Var(buffer, 'php_phpstan_executable'),
+\ '%e --version',
+\ function('ale_linters#php#phpstan#GetCommand'),
+\ )},
\ 'callback': 'ale_linters#php#phpstan#Handle',
\})
diff --git a/ale_linters/python/flake8.vim b/ale_linters/python/flake8.vim
index 993d7adb..e2e7b743 100644
--- a/ale_linters/python/flake8.vim
+++ b/ale_linters/python/flake8.vim
@@ -24,28 +24,25 @@ function! ale_linters#python#flake8#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'python_flake8_executable')
endfunction
-function! ale_linters#python#flake8#VersionCheck(buffer) abort
+function! ale_linters#python#flake8#RunWithVersionCheck(buffer) abort
let l:executable = ale_linters#python#flake8#GetExecutable(a:buffer)
- " If we have previously stored the version number in a cache, then
- " don't look it up again.
- if ale#semver#HasVersion(l:executable)
- " Returning an empty string skips this command.
- return ''
- endif
-
- let l:executable = ale#Escape(l:executable)
let l:module_string = s:UsingModule(a:buffer) ? ' -m flake8' : ''
-
- return l:executable . l:module_string . ' --version'
+ let l:command = ale#Escape(l:executable) . l:module_string . ' --version'
+
+ return ale#semver#RunWithVersionCheck(
+ \ a:buffer,
+ \ l:executable,
+ \ l:command,
+ \ function('ale_linters#python#flake8#GetCommand'),
+ \)
endfunction
-function! ale_linters#python#flake8#GetCommand(buffer, version_output) abort
+function! ale_linters#python#flake8#GetCommand(buffer, version) abort
let l:cd_string = ale#Var(a:buffer, 'python_flake8_change_directory')
\ ? ale#path#BufferCdString(a:buffer)
\ : ''
let l:executable = ale_linters#python#flake8#GetExecutable(a:buffer)
- let l:version = ale#semver#GetVersion(l:executable, a:version_output)
let l:exec_args = l:executable =~? 'pipenv$'
\ ? ' run flake8'
@@ -53,7 +50,7 @@ function! ale_linters#python#flake8#GetCommand(buffer, version_output) abort
" Only include the --stdin-display-name argument if we can parse the
" flake8 version, and it is recent enough to support it.
- let l:display_name_args = ale#semver#GTE(l:version, [3, 0, 0])
+ let l:display_name_args = ale#semver#GTE(a:version, [3, 0, 0])
\ ? ' --stdin-display-name %s'
\ : ''
@@ -144,9 +141,6 @@ endfunction
call ale#linter#Define('python', {
\ 'name': 'flake8',
\ 'executable': function('ale_linters#python#flake8#GetExecutable'),
-\ 'command_chain': [
-\ {'callback': 'ale_linters#python#flake8#VersionCheck'},
-\ {'callback': 'ale_linters#python#flake8#GetCommand', 'output_stream': 'both'},
-\ ],
+\ 'command': function('ale_linters#python#flake8#RunWithVersionCheck'),
\ 'callback': 'ale_linters#python#flake8#Handle',
\})
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',
\})
diff --git a/ale_linters/rust/cargo.vim b/ale_linters/rust/cargo.vim
index b4eabfae..f98dee9b 100644
--- a/ale_linters/rust/cargo.vim
+++ b/ale_linters/rust/cargo.vim
@@ -22,26 +22,18 @@ function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort
endif
endfunction
-function! ale_linters#rust#cargo#VersionCheck(buffer) abort
- return !ale#semver#HasVersion('cargo')
- \ ? 'cargo --version'
- \ : ''
-endfunction
-
-function! ale_linters#rust#cargo#GetCommand(buffer, version_output) abort
- let l:version = ale#semver#GetVersion('cargo', a:version_output)
-
+function! ale_linters#rust#cargo#GetCommand(buffer, version) abort
let l:use_check = ale#Var(a:buffer, 'rust_cargo_use_check')
- \ && ale#semver#GTE(l:version, [0, 17, 0])
+ \ && ale#semver#GTE(a:version, [0, 17, 0])
let l:use_all_targets = l:use_check
\ && ale#Var(a:buffer, 'rust_cargo_check_all_targets')
- \ && ale#semver#GTE(l:version, [0, 22, 0])
+ \ && ale#semver#GTE(a:version, [0, 22, 0])
let l:use_examples = l:use_check
\ && ale#Var(a:buffer, 'rust_cargo_check_examples')
- \ && ale#semver#GTE(l:version, [0, 22, 0])
+ \ && ale#semver#GTE(a:version, [0, 22, 0])
let l:use_tests = l:use_check
\ && ale#Var(a:buffer, 'rust_cargo_check_tests')
- \ && ale#semver#GTE(l:version, [0, 22, 0])
+ \ && ale#semver#GTE(a:version, [0, 22, 0])
let l:include_features = ale#Var(a:buffer, 'rust_cargo_include_features')
@@ -94,10 +86,12 @@ endfunction
call ale#linter#Define('rust', {
\ 'name': 'cargo',
\ 'executable': function('ale_linters#rust#cargo#GetCargoExecutable'),
-\ 'command_chain': [
-\ {'callback': 'ale_linters#rust#cargo#VersionCheck'},
-\ {'callback': 'ale_linters#rust#cargo#GetCommand'},
-\ ],
+\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
+\ buffer,
+\ ale_linters#rust#cargo#GetCargoExecutable(buffer),
+\ '%e --version',
+\ function('ale_linters#rust#cargo#GetCommand'),
+\ )},
\ 'callback': 'ale#handlers#rust#HandleRustErrors',
\ 'output_stream': 'both',
\ 'lint_file': 1,
diff --git a/ale_linters/sh/shellcheck.vim b/ale_linters/sh/shellcheck.vim
index bb7048cd..3920cab8 100644
--- a/ale_linters/sh/shellcheck.vim
+++ b/ale_linters/sh/shellcheck.vim
@@ -11,10 +11,6 @@ call ale#Set('sh_shellcheck_executable', 'shellcheck')
call ale#Set('sh_shellcheck_dialect', 'auto')
call ale#Set('sh_shellcheck_options', '')
-function! ale_linters#sh#shellcheck#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'sh_shellcheck_executable')
-endfunction
-
function! ale_linters#sh#shellcheck#GetDialectArgument(buffer) abort
let l:shell_type = ale#handlers#sh#GetShellType(a:buffer)
@@ -39,30 +35,18 @@ function! ale_linters#sh#shellcheck#GetDialectArgument(buffer) abort
return ''
endfunction
-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.
- 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 = ale#semver#GetVersion(l:executable, a:version_output)
-
+function! ale_linters#sh#shellcheck#GetCommand(buffer, version) abort
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#Var(a:buffer, 'sh_shellcheck_dialect')
- let l:external_option = ale#semver#GTE(l:version, [0, 4, 0]) ? ' -x' : ''
+ let l:external_option = ale#semver#GTE(a:version, [0, 4, 0]) ? ' -x' : ''
if l:dialect is# 'auto'
let l:dialect = ale_linters#sh#shellcheck#GetDialectArgument(a:buffer)
endif
return ale#path#BufferCdString(a:buffer)
- \ . ale#Escape(l:executable)
+ \ . '%e'
\ . (!empty(l:dialect) ? ' -s ' . l:dialect : '')
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . (!empty(l:exclude_option) ? ' -e ' . l:exclude_option : '')
@@ -108,10 +92,12 @@ endfunction
call ale#linter#Define('sh', {
\ 'name': 'shellcheck',
-\ 'executable': function('ale_linters#sh#shellcheck#GetExecutable'),
-\ 'command_chain': [
-\ {'callback': 'ale_linters#sh#shellcheck#VersionCheck'},
-\ {'callback': 'ale_linters#sh#shellcheck#GetCommand'},
-\ ],
+\ 'executable': {buffer -> ale#Var(buffer, 'sh_shellcheck_executable')},
+\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
+\ buffer,
+\ ale#Var(buffer, 'sh_shellcheck_executable'),
+\ '%e --version',
+\ function('ale_linters#sh#shellcheck#GetCommand'),
+\ )},
\ 'callback': 'ale_linters#sh#shellcheck#Handle',
\})
diff --git a/ale_linters/vim/vint.vim b/ale_linters/vim/vint.vim
index 3808c47e..65e19126 100644
--- a/ale_linters/vim/vint.vim
+++ b/ale_linters/vim/vint.vim
@@ -7,29 +7,13 @@ call ale#Set('vim_vint_executable', 'vint')
let s:enable_neovim = has('nvim') ? ' --enable-neovim' : ''
let s:format = '-f "{file_path}:{line_number}:{column_number}: {severity}: {description} (see {reference})"'
-function! ale_linters#vim#vint#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'vim_vint_executable')
-endfunction
-
-function! ale_linters#vim#vint#VersionCommand(buffer) abort
- let l:executable = ale_linters#vim#vint#GetExecutable(a:buffer)
-
- " Check the Vint version if we haven't checked it already.
- return !ale#semver#HasVersion(l:executable)
- \ ? ale#Escape(l:executable) . ' --version'
- \ : ''
-endfunction
-
-function! ale_linters#vim#vint#GetCommand(buffer, version_output) abort
- let l:executable = ale_linters#vim#vint#GetExecutable(a:buffer)
- let l:version = ale#semver#GetVersion(l:executable, a:version_output)
-
- let l:can_use_no_color_flag = empty(l:version)
- \ || ale#semver#GTE(l:version, [0, 3, 7])
+function! ale_linters#vim#vint#GetCommand(buffer, version) abort
+ let l:can_use_no_color_flag = empty(a:version)
+ \ || ale#semver#GTE(a:version, [0, 3, 7])
let l:warning_flag = ale#Var(a:buffer, 'vim_vint_show_style_issues') ? '-s' : '-w'
- return ale#Escape(l:executable)
+ return '%e'
\ . ' ' . l:warning_flag
\ . (l:can_use_no_color_flag ? ' --no-color' : '')
\ . s:enable_neovim
@@ -65,10 +49,12 @@ endfunction
call ale#linter#Define('vim', {
\ 'name': 'vint',
-\ 'executable': function('ale_linters#vim#vint#GetExecutable'),
-\ 'command_chain': [
-\ {'callback': 'ale_linters#vim#vint#VersionCommand', 'output_stream': 'stderr'},
-\ {'callback': 'ale_linters#vim#vint#GetCommand', 'output_stream': 'stdout'},
-\ ],
+\ 'executable': {buffer -> ale#Var(buffer, 'vim_vint_executable')},
+\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
+\ buffer,
+\ ale#Var(buffer, 'vim_vint_executable'),
+\ '%e --version',
+\ function('ale_linters#vim#vint#GetCommand'),
+\ )},
\ 'callback': 'ale_linters#vim#vint#Handle',
\})