Return only the unescaped executables from executable callbacks

This commit is contained in:
w0rp
2018-09-14 13:24:59 +01:00
parent 9e09b7ca35
commit 5c86ffd321
7 changed files with 20 additions and 43 deletions

View File

@@ -3,15 +3,7 @@
call ale#Set('ruby_brakeman_options', '') call ale#Set('ruby_brakeman_options', '')
call ale#Set('ruby_brakeman_executable', 'brakeman') call ale#Set('ruby_brakeman_executable', 'brakeman')
call ale#Set('ruby_brakeman_options', '')
let g:ale_ruby_brakeman_options =
\ get(g:, 'ale_ruby_brakeman_options', '')
function! ale_linters#ruby#brakeman#GetExecutable(buffer) abort
let l:executable = ale#Var(a:buffer, 'ruby_brakeman_executable')
return ale#handlers#ruby#EscapeExecutable(l:executable, 'brakeman')
endfunction
function! ale_linters#ruby#brakeman#Handle(buffer, lines) abort function! ale_linters#ruby#brakeman#Handle(buffer, lines) abort
let l:output = [] let l:output = []
@@ -36,14 +28,15 @@ function! ale_linters#ruby#brakeman#Handle(buffer, lines) abort
endfunction endfunction
function! ale_linters#ruby#brakeman#GetCommand(buffer) abort function! ale_linters#ruby#brakeman#GetCommand(buffer) abort
let l:executable = ale_linters#ruby#brakeman#GetExecutable(a:buffer)
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer) let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
if l:rails_root is? '' if l:rails_root is? ''
return '' return ''
endif endif
return l:executable let l:executable = ale#Var(a:buffer, 'ruby_brakeman_executable')
return ale#handlers#ruby#EscapeExecutable(l:executable, 'brakeman')
\ . ' -f json -q ' \ . ' -f json -q '
\ . ale#Var(a:buffer, 'ruby_brakeman_options') \ . ale#Var(a:buffer, 'ruby_brakeman_options')
\ . ' -p ' . ale#Escape(l:rails_root) \ . ' -p ' . ale#Escape(l:rails_root)

View File

@@ -22,24 +22,18 @@ function! ale_linters#ruby#rails_best_practices#Handle(buffer, lines) abort
return l:output return l:output
endfunction endfunction
function! ale_linters#ruby#rails_best_practices#GetExecutable(buffer) abort
let l:executable = ale#Var(a:buffer, 'ruby_rails_best_practices_executable')
return ale#handlers#ruby#EscapeExecutable(l:executable, 'rails_best_practices')
endfunction
function! ale_linters#ruby#rails_best_practices#GetCommand(buffer) abort function! ale_linters#ruby#rails_best_practices#GetCommand(buffer) abort
let l:executable = ale_linters#ruby#rails_best_practices#GetExecutable(a:buffer)
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer) let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
if l:rails_root is? '' if l:rails_root is? ''
return '' return ''
endif endif
let l:executable = ale#Var(a:buffer, 'ruby_rails_best_practices_executable')
let l:output_file = ale#Has('win32') ? '%t ' : '/dev/stdout ' let l:output_file = ale#Has('win32') ? '%t ' : '/dev/stdout '
let l:cat_file = ale#Has('win32') ? '; type %t' : '' let l:cat_file = ale#Has('win32') ? '; type %t' : ''
return l:executable return ale#handlers#ruby#EscapeExecutable(l:executable, 'rails_best_practices')
\ . ' --silent -f json --output-file ' . l:output_file \ . ' --silent -f json --output-file ' . l:output_file
\ . ale#Var(a:buffer, 'ruby_rails_best_practices_options') \ . ale#Var(a:buffer, 'ruby_rails_best_practices_options')
\ . ale#Escape(l:rails_root) \ . ale#Escape(l:rails_root)

View File

@@ -6,12 +6,6 @@ call ale#Set('ruby_reek_show_wiki_link', 0)
call ale#Set('ruby_reek_options', '') call ale#Set('ruby_reek_options', '')
call ale#Set('ruby_reek_executable', 'reek') call ale#Set('ruby_reek_executable', 'reek')
function! ale_linters#ruby#reek#GetExecutable(buffer) abort
let l:executable = ale#Var(a:buffer, 'ruby_reek_executable')
return ale#handlers#ruby#EscapeExecutable(l:executable, 'reek')
endfunction
function! ale_linters#ruby#reek#VersionCheck(buffer) abort function! ale_linters#ruby#reek#VersionCheck(buffer) abort
" If we have previously stored the version number in a cache, then " If we have previously stored the version number in a cache, then
" don't look it up again. " don't look it up again.
@@ -20,21 +14,22 @@ function! ale_linters#ruby#reek#VersionCheck(buffer) abort
return '' return ''
endif endif
let l:executable = ale_linters#ruby#reek#GetExecutable(a:buffer) let l:executable = ale#Var(a:buffer, 'ruby_reek_executable')
return l:executable . ' --version' return ale#handlers#ruby#EscapeExecutable(l:executable, 'reek')
\ . ' --version'
endfunction endfunction
function! ale_linters#ruby#reek#GetCommand(buffer, version_output) abort function! ale_linters#ruby#reek#GetCommand(buffer, version_output) abort
let l:version = ale#semver#GetVersion('reek', a:version_output) let l:version = ale#semver#GetVersion('reek', a:version_output)
let l:executable = ale_linters#ruby#reek#GetExecutable(a:buffer) let l:executable = ale#Var(a:buffer, 'ruby_reek_executable')
" Tell reek what the filename is if the version of reek is new enough. " 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(l:version, [5, 0, 0])
\ ? ' --stdin-filename %s' \ ? ' --stdin-filename %s'
\ : '' \ : ''
return l:executable return ale#handlers#ruby#EscapeExecutable(l:executable, 'reek')
\ . ' -f json --no-progress --no-color' \ . ' -f json --no-progress --no-color'
\ . l:display_name_args \ . l:display_name_args
endfunction endfunction

View File

@@ -2,9 +2,9 @@
" Description: RuboCop, a code style analyzer for Ruby files " Description: RuboCop, a code style analyzer for Ruby files
function! ale_linters#ruby#rubocop#GetCommand(buffer) abort function! ale_linters#ruby#rubocop#GetCommand(buffer) abort
let l:executable = ale#handlers#rubocop#GetExecutable(a:buffer) let l:executable = ale#Var(a:buffer, 'ruby_rubocop_executable')
return l:executable return ale#handlers#ruby#EscapeExecutable(l:executable, 'rubocop')
\ . ' --format json --force-exclusion ' \ . ' --format json --force-exclusion '
\ . ale#Var(a:buffer, 'ruby_rubocop_options') \ . ale#Var(a:buffer, 'ruby_rubocop_options')
\ . ' --stdin ' . ale#Escape(expand('#' . a:buffer . ':p')) \ . ' --stdin ' . ale#Escape(expand('#' . a:buffer . ':p'))

View File

@@ -1,9 +1,12 @@
call ale#Set('ruby_rubocop_options', '')
call ale#Set('ruby_rubocop_executable', 'rubocop')
function! ale#fixers#rubocop#GetCommand(buffer) abort function! ale#fixers#rubocop#GetCommand(buffer) abort
let l:executable = ale#handlers#rubocop#GetExecutable(a:buffer) let l:executable = ale#Var(a:buffer, 'ruby_rubocop_executable')
let l:config = ale#path#FindNearestFile(a:buffer, '.rubocop.yml') let l:config = ale#path#FindNearestFile(a:buffer, '.rubocop.yml')
let l:options = ale#Var(a:buffer, 'ruby_rubocop_options') let l:options = ale#Var(a:buffer, 'ruby_rubocop_options')
return l:executable return ale#handlers#ruby#EscapeExecutable(l:executable, 'rubocop')
\ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '') \ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '')
\ . (!empty(l:options) ? ' ' . l:options : '') \ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' --auto-correct %t' \ . ' --auto-correct %t'

View File

@@ -1,8 +0,0 @@
call ale#Set('ruby_rubocop_options', '')
call ale#Set('ruby_rubocop_executable', 'rubocop')
function! ale#handlers#rubocop#GetExecutable(buffer) abort
let l:executable = ale#Var(a:buffer, 'ruby_rubocop_executable')
return ale#handlers#ruby#EscapeExecutable(l:executable, 'rubocop')
endfunction

View File

@@ -21,9 +21,9 @@ Execute(Should be able to set a custom executable):
\ . ale#Escape(ale#path#Simplify(g:dir . '/dummy.rb')) \ . ale#Escape(ale#path#Simplify(g:dir . '/dummy.rb'))
Execute(Setting bundle appends 'exec rubocop'): Execute(Setting bundle appends 'exec rubocop'):
let g:ale_ruby_rubocop_executable = 'bundle' let g:ale_ruby_rubocop_executable = 'path to/bundle'
AssertLinter 'bundle', ale#Escape('bundle') AssertLinter 'path to/bundle', ale#Escape('path to/bundle')
\ . ' exec rubocop' \ . ' exec rubocop'
\ . ' --format json --force-exclusion --stdin ' \ . ' --format json --force-exclusion --stdin '
\ . ale#Escape(ale#path#Simplify(g:dir . '/dummy.rb')) \ . ale#Escape(ale#path#Simplify(g:dir . '/dummy.rb'))