diff --git a/autoload/ale/fixers/rubocop.vim b/autoload/ale/fixers/rubocop.vim index 557b759..35569b1 100644 --- a/autoload/ale/fixers/rubocop.vim +++ b/autoload/ale/fixers/rubocop.vim @@ -4,11 +4,12 @@ function! ale#fixers#rubocop#GetCommand(buffer) abort \ ? ' exec rubocop' \ : '' let l:config = ale#path#FindNearestFile(a:buffer, '.rubocop.yml') + let l:options = ale#Var(a:buffer, 'ruby_rubocop_options') return ale#Escape(l:executable) . l:exec_args \ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '') - \ . ' --auto-correct %t ' - \ . ale#Var(a:buffer, 'ruby_rubocop_options') + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --auto-correct %t' endfunction diff --git a/test/fixers/test_rubocop_fixer_callback.vader b/test/fixers/test_rubocop_fixer_callback.vader index e9a8739..87d56d0 100644 --- a/test/fixers/test_rubocop_fixer_callback.vader +++ b/test/fixers/test_rubocop_fixer_callback.vader @@ -1,8 +1,10 @@ Before: Save g:ale_ruby_rubocop_executable + Save g:ale_ruby_rubocop_options " Use an invalid global executable, so we don't match it. let g:ale_ruby_rubocop_executable = 'xxxinvalid' + let g:ale_ruby_rubocop_options = '' call ale#test#SetDirectory('/testplugin/test/fixers') silent cd .. @@ -21,7 +23,7 @@ Execute(The rubocop callback should return the correct default values): \ { \ 'read_temporary_file': 1, \ 'command': ale#Escape(g:ale_ruby_rubocop_executable) - \ . ' --auto-correct %t ', + \ . ' --auto-correct %t', \ }, \ ale#fixers#rubocop#Fix(bufnr('')) @@ -33,7 +35,7 @@ Execute(The rubocop callback should include configuration files): \ 'read_temporary_file': 1, \ 'command': ale#Escape(g:ale_ruby_rubocop_executable) \ . ' --config ' . ale#Escape(g:dir . '/ruby_paths/with_config/.rubocop.yml') - \ . ' --auto-correct %t ', + \ . ' --auto-correct %t', \ }, \ ale#fixers#rubocop#Fix(bufnr('')) @@ -46,6 +48,7 @@ Execute(The rubocop callback should include custom rubocop options): \ 'read_temporary_file': 1, \ 'command': ale#Escape(g:ale_ruby_rubocop_executable) \ . ' --config ' . ale#Escape(g:dir . '/ruby_paths/with_config/.rubocop.yml') - \ . ' --auto-correct %t --except Lint/Debugger', + \ . ' --except Lint/Debugger' + \ . ' --auto-correct %t', \ }, \ ale#fixers#rubocop#Fix(bufnr(''))