ale/ale_linters/ruby/rubocop.vim

32 lines
1.0 KiB
VimL
Raw Normal View History

" Author: ynonp - https://github.com/ynonp, Eddie Lebow https://github.com/elebow
" Description: RuboCop, a code style analyzer for Ruby files
call ale#Set('ruby_rubocop_executable', 'rubocop')
call ale#Set('ruby_rubocop_options', '')
2017-05-18 08:22:34 +00:00
function! ale_linters#ruby#rubocop#GetCommand(buffer) abort
let l:executable = ale#Var(a:buffer, 'ruby_rubocop_executable')
2017-05-18 08:22:34 +00:00
return ale#handlers#ruby#EscapeExecutable(l:executable, 'rubocop')
\ . ' --format json --force-exclusion '
2017-05-18 08:22:34 +00:00
\ . ale#Var(a:buffer, 'ruby_rubocop_options')
\ . ' --stdin ' . ale#Escape(expand('#' . a:buffer . ':p'))
2017-05-18 08:22:34 +00:00
endfunction
function! ale_linters#ruby#rubocop#GetType(severity) abort
if a:severity is? 'convention'
\|| a:severity is? 'warning'
\|| a:severity is? 'refactor'
2017-07-09 14:50:36 +00:00
return 'W'
endif
return 'E'
endfunction
call ale#linter#Define('ruby', {
\ 'name': 'rubocop',
\ 'executable_callback': ale#VarFunc('ruby_rubocop_executable'),
\ 'command_callback': 'ale_linters#ruby#rubocop#GetCommand',
\ 'callback': 'ale#ruby#HandleRubocopOutput',
2016-09-15 07:37:53 +00:00
\})