Created
September 24, 2019 12:47
-
-
Save peteryates/59fbd6ace8f12695ee2fe5d4df25999a to your computer and use it in GitHub Desktop.
A twist on the Rubocop linter customised to work with govuk-ruby-lint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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', 'govuk-lint-ruby') | |
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#ruby#EscapeExecutable(l:executable, 'govuk-lint-ruby') | |
\ . ' --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': 'govuk-lint-ruby', | |
\ 'executable': {b -> ale#Var(b, 'ruby_rubocop_executable')}, | |
\ 'command': function('ale_linters#ruby#rubocop#GetCommand'), | |
\ 'callback': 'ale#ruby#HandleRubocopOutput', | |
\}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment