2cfa09e02d
See: https://github.com/testdouble/standard StandardRB is to RuboCop what StandardJS is to ESLint. This commit naively copies the RuboCop linter and fixer to point at the standardrb executable. Any other adjustments are very minor (the only I can think of is that standardrb takes a `--fix` option instead of `--auto-correct`). This raises a confusing point to me as both developer and a user: since ale enables all linters by default, won't this run both RuboCop and StandardRB (the results of which will almost always be in conflict with one another)? How does ale already solve for this for the similar case of StandardJS and ESLint?
32 lines
1.0 KiB
VimL
32 lines
1.0 KiB
VimL
" 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', '')
|
|
|
|
function! ale_linters#ruby#rubocop#GetCommand(buffer) abort
|
|
let l:executable = ale#Var(a:buffer, 'ruby_rubocop_executable')
|
|
|
|
return ale#handlers#ruby#EscapeExecutable(l:executable, 'rubocop')
|
|
\ . ' --format json --force-exclusion '
|
|
\ . ale#Var(a:buffer, 'ruby_rubocop_options')
|
|
\ . ' --stdin ' . ale#Escape(expand('#' . a:buffer . ':p'))
|
|
endfunction
|
|
|
|
function! ale_linters#ruby#rubocop#GetType(severity) abort
|
|
if a:severity is? 'convention'
|
|
\|| a:severity is? 'warning'
|
|
\|| a:severity is? 'refactor'
|
|
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',
|
|
\})
|