diff options
-rw-r--r-- | autoload/ale/fixers/rubocop.vim | 5 | ||||
-rw-r--r-- | doc/ale-ruby.txt | 8 | ||||
-rw-r--r-- | test/fixers/test_rubocop_fixer_callback.vader | 13 |
3 files changed, 25 insertions, 1 deletions
diff --git a/autoload/ale/fixers/rubocop.vim b/autoload/ale/fixers/rubocop.vim index 0c7441e4..a4baa6e7 100644 --- a/autoload/ale/fixers/rubocop.vim +++ b/autoload/ale/fixers/rubocop.vim @@ -1,15 +1,18 @@ call ale#Set('ruby_rubocop_options', '') +call ale#Set('ruby_rubocop_auto_correct_all', 0) call ale#Set('ruby_rubocop_executable', 'rubocop') function! ale#fixers#rubocop#GetCommand(buffer) abort 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') + let l:auto_correct_all = ale#Var(a:buffer, 'ruby_rubocop_auto_correct_all') return ale#ruby#EscapeExecutable(l:executable, 'rubocop') \ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '') \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' --auto-correct --force-exclusion %t' + \ . (l:auto_correct_all ? ' --auto-correct-all' : ' --auto-correct') + \ . ' --force-exclusion %t' endfunction function! ale#fixers#rubocop#Fix(buffer) abort diff --git a/doc/ale-ruby.txt b/doc/ale-ruby.txt index a27a20b2..142bb6b8 100644 --- a/doc/ale-ruby.txt +++ b/doc/ale-ruby.txt @@ -114,6 +114,14 @@ g:ale_ruby_rubocop_options *g:ale_ruby_rubocop_options* This variable can be changed to modify flags given to rubocop. +g:ale_ruby_rubocop_auto_correct_all *g:ale_ruby_rubocop_options* + *b:ale_ruby_rubocop_options* + Type: Number + Default: `0` + + This variable can be changed to make rubocop to correct all offenses (unsafe). + + =============================================================================== ruby *ale-ruby-ruby* diff --git a/test/fixers/test_rubocop_fixer_callback.vader b/test/fixers/test_rubocop_fixer_callback.vader index 866326bf..b1925000 100644 --- a/test/fixers/test_rubocop_fixer_callback.vader +++ b/test/fixers/test_rubocop_fixer_callback.vader @@ -52,3 +52,16 @@ Execute(The rubocop callback should include custom rubocop options): \ . ' --auto-correct --force-exclusion %t', \ }, \ ale#fixers#rubocop#Fix(bufnr('')) + +Execute(The rubocop callback should use auto-correct-all option when set): + let g:ale_ruby_rubocop_auto_correct_all = 1 + call ale#test#SetFilename('ruby_paths/with_config/dummy.rb') + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape(g:ale_ruby_rubocop_executable) + \ . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/ruby_paths/with_config/.rubocop.yml')) + \ . ' --auto-correct-all --force-exclusion %t', + \ }, + \ ale#fixers#rubocop#Fix(bufnr('')) |