summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2018-09-14 13:24:59 +0100
committerw0rp <devw0rp@gmail.com>2018-09-14 13:24:59 +0100
commit5c86ffd321ee42b2c59e8455710474e3c13d3e09 (patch)
tree8c6702aa0fe866f1e7d289f76f4b5bd806847f89
parent9e09b7ca3559e2c14ed2401bb666b441b22dafff (diff)
downloadale-5c86ffd321ee42b2c59e8455710474e3c13d3e09.zip
Return only the unescaped executables from executable callbacks
-rw-r--r--ale_linters/ruby/brakeman.vim15
-rw-r--r--ale_linters/ruby/rails_best_practices.vim10
-rw-r--r--ale_linters/ruby/reek.vim15
-rw-r--r--ale_linters/ruby/rubocop.vim4
-rw-r--r--autoload/ale/fixers/rubocop.vim7
-rw-r--r--autoload/ale/handlers/rubocop.vim8
-rw-r--r--test/command_callback/test_rubocop_command_callback.vader4
7 files changed, 20 insertions, 43 deletions
diff --git a/ale_linters/ruby/brakeman.vim b/ale_linters/ruby/brakeman.vim
index 099254a9..122e0b5b 100644
--- a/ale_linters/ruby/brakeman.vim
+++ b/ale_linters/ruby/brakeman.vim
@@ -3,15 +3,7 @@
call ale#Set('ruby_brakeman_options', '')
call ale#Set('ruby_brakeman_executable', 'brakeman')
-
-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
+call ale#Set('ruby_brakeman_options', '')
function! ale_linters#ruby#brakeman#Handle(buffer, lines) abort
let l:output = []
@@ -36,14 +28,15 @@ function! ale_linters#ruby#brakeman#Handle(buffer, lines) abort
endfunction
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)
if l:rails_root is? ''
return ''
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 '
\ . ale#Var(a:buffer, 'ruby_brakeman_options')
\ . ' -p ' . ale#Escape(l:rails_root)
diff --git a/ale_linters/ruby/rails_best_practices.vim b/ale_linters/ruby/rails_best_practices.vim
index 9330c03f..20cadca8 100644
--- a/ale_linters/ruby/rails_best_practices.vim
+++ b/ale_linters/ruby/rails_best_practices.vim
@@ -22,24 +22,18 @@ function! ale_linters#ruby#rails_best_practices#Handle(buffer, lines) abort
return l:output
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
- let l:executable = ale_linters#ruby#rails_best_practices#GetExecutable(a:buffer)
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
if l:rails_root is? ''
return ''
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: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
\ . ale#Var(a:buffer, 'ruby_rails_best_practices_options')
\ . ale#Escape(l:rails_root)
diff --git a/ale_linters/ruby/reek.vim b/ale_linters/ruby/reek.vim
index 26a26a13..eefc4ecf 100644
--- a/ale_linters/ruby/reek.vim
+++ b/ale_linters/ruby/reek.vim
@@ -6,12 +6,6 @@ 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#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
" If we have previously stored the version number in a cache, then
" don't look it up again.
@@ -20,21 +14,22 @@ function! ale_linters#ruby#reek#VersionCheck(buffer) abort
return ''
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
function! ale_linters#ruby#reek#GetCommand(buffer, version_output) abort
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.
let l:display_name_args = ale#semver#GTE(l:version, [5, 0, 0])
\ ? ' --stdin-filename %s'
\ : ''
- return l:executable
+ return ale#handlers#ruby#EscapeExecutable(l:executable, 'reek')
\ . ' -f json --no-progress --no-color'
\ . l:display_name_args
endfunction
diff --git a/ale_linters/ruby/rubocop.vim b/ale_linters/ruby/rubocop.vim
index dce27e3c..58d73407 100644
--- a/ale_linters/ruby/rubocop.vim
+++ b/ale_linters/ruby/rubocop.vim
@@ -2,9 +2,9 @@
" Description: RuboCop, a code style analyzer for Ruby files
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 '
\ . ale#Var(a:buffer, 'ruby_rubocop_options')
\ . ' --stdin ' . ale#Escape(expand('#' . a:buffer . ':p'))
diff --git a/autoload/ale/fixers/rubocop.vim b/autoload/ale/fixers/rubocop.vim
index 47a78308..a4613817 100644
--- a/autoload/ale/fixers/rubocop.vim
+++ b/autoload/ale/fixers/rubocop.vim
@@ -1,9 +1,12 @@
+call ale#Set('ruby_rubocop_options', '')
+call ale#Set('ruby_rubocop_executable', 'rubocop')
+
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: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:options) ? ' ' . l:options : '')
\ . ' --auto-correct %t'
diff --git a/autoload/ale/handlers/rubocop.vim b/autoload/ale/handlers/rubocop.vim
deleted file mode 100644
index 09af7085..00000000
--- a/autoload/ale/handlers/rubocop.vim
+++ /dev/null
@@ -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
diff --git a/test/command_callback/test_rubocop_command_callback.vader b/test/command_callback/test_rubocop_command_callback.vader
index b6f4590e..7f42a8c0 100644
--- a/test/command_callback/test_rubocop_command_callback.vader
+++ b/test/command_callback/test_rubocop_command_callback.vader
@@ -21,9 +21,9 @@ Execute(Should be able to set a custom executable):
\ . ale#Escape(ale#path#Simplify(g:dir . '/dummy.rb'))
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'
\ . ' --format json --force-exclusion --stdin '
\ . ale#Escape(ale#path#Simplify(g:dir . '/dummy.rb'))