#732 - Use the configuration files when fixing files with rubocop
This commit is contained in:
parent
acda19776a
commit
a72c1edfcc
3 changed files with 20 additions and 4 deletions
|
@ -3,8 +3,10 @@ function! ale#fixers#rubocop#GetCommand(buffer) abort
|
|||
let l:exec_args = l:executable =~? 'bundle$'
|
||||
\ ? ' exec rubocop'
|
||||
\ : ''
|
||||
let l:config = ale#path#FindNearestFile(a:buffer, '.rubocop.yml')
|
||||
|
||||
return ale#Escape(l:executable) . l:exec_args
|
||||
\ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '')
|
||||
\ . ' --auto-correct %t'
|
||||
|
||||
endfunction
|
||||
|
|
|
@ -19,10 +19,24 @@ After:
|
|||
unlet! g:dir
|
||||
|
||||
Execute(The rubocop callback should return the correct default values):
|
||||
silent execute 'file ' . fnameescape(g:dir . '/ruby_paths/dummy.rb')
|
||||
call ale#test#SetFilename('ruby_paths/dummy.rb')
|
||||
|
||||
AssertEqual
|
||||
\ {'read_temporary_file': 1,
|
||||
\ 'command': "'" . g:ale_ruby_rubocop_executable . "' "
|
||||
\ . '--auto-correct %t' },
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape(g:ale_ruby_rubocop_executable)
|
||||
\ . ' --auto-correct %t',
|
||||
\ },
|
||||
\ ale#fixers#rubocop#Fix(bufnr(''))
|
||||
|
||||
Execute(The rubocop callback should include configuration files):
|
||||
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(g:dir . '/ruby_paths/with_config/.rubocop.yml')
|
||||
\ . ' --auto-correct %t',
|
||||
\ },
|
||||
\ ale#fixers#rubocop#Fix(bufnr(''))
|
||||
|
|
Reference in a new issue