diff options
author | Horacio Sanson <hsanson@gmail.com> | 2020-08-13 19:25:07 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-13 11:25:07 +0100 |
commit | 8e6c7bff9aeeb445649843113b39ee3c79d4a909 (patch) | |
tree | 9bc8e82277a975d9a51e83726a0e5d9b32abeb9b /autoload | |
parent | 34adb997c6d1f41ebc5baa85e58e865da2939791 (diff) | |
download | ale-8e6c7bff9aeeb445649843113b39ee3c79d4a909.zip |
Fix 1695 - Change rubocop fixer to use stdin (#3230)
* Fix 1695 - Change rubocop fixer to use stdin
* Update test_rubocop_fixer_callback.vader
Co-authored-by: Horacio Sanson <horacio@allm.inc>
Co-authored-by: w0rp <w0rp@users.noreply.github.com>
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fixers/rubocop.vim | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/autoload/ale/fixers/rubocop.vim b/autoload/ale/fixers/rubocop.vim index a4baa6e7..d9615256 100644 --- a/autoload/ale/fixers/rubocop.vim +++ b/autoload/ale/fixers/rubocop.vim @@ -2,6 +2,23 @@ call ale#Set('ruby_rubocop_options', '') call ale#Set('ruby_rubocop_auto_correct_all', 0) call ale#Set('ruby_rubocop_executable', 'rubocop') +" Rubocop fixer outputs diagnostics first and then the fixed +" output. These are delimited by a "=======" string that we +" look for to remove everything before it. +function! ale#fixers#rubocop#PostProcess(buffer, output) abort + let l:line = 0 + + for l:output in a:output + let l:line = l:line + 1 + + if l:output =~# "^=\\+$" + break + endif + endfor + + return a:output[l:line :] +endfunction + 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') @@ -12,12 +29,13 @@ function! ale#fixers#rubocop#GetCommand(buffer) abort \ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '') \ . (!empty(l:options) ? ' ' . l:options : '') \ . (l:auto_correct_all ? ' --auto-correct-all' : ' --auto-correct') - \ . ' --force-exclusion %t' + \ . ' --force-exclusion --stdin ' + \ . ale#Escape(expand('#' . a:buffer . ':p')) endfunction function! ale#fixers#rubocop#Fix(buffer) abort return { \ 'command': ale#fixers#rubocop#GetCommand(a:buffer), - \ 'read_temporary_file': 1, + \ 'process_with': 'ale#fixers#rubocop#PostProcess' \} endfunction |