diff options
author | Eddie Lebow <elebow@users.noreply.github.com> | 2017-04-20 02:37:08 -0400 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2017-04-20 07:37:08 +0100 |
commit | 0384cabd77e38f9a04ff1c8832f6b755855e909e (patch) | |
tree | 502e93f9a0f30dc47a932ac316a4879d464272c0 /ale_linters/ruby | |
parent | c6ef9e28a50f2378568c4c35a5346b495cb15c34 (diff) | |
download | ale-0384cabd77e38f9a04ff1c8832f6b755855e909e.zip |
Add the Reek checker for Ruby. (#490)
Add the Reek checker for Ruby.
Diffstat (limited to 'ale_linters/ruby')
-rw-r--r-- | ale_linters/ruby/reek.vim | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/ale_linters/ruby/reek.vim b/ale_linters/ruby/reek.vim new file mode 100644 index 00000000..5f476fb1 --- /dev/null +++ b/ale_linters/ruby/reek.vim @@ -0,0 +1,53 @@ +" Author: Eddie Lebow https://github.com/elebow +" Description: Reek, a code smell detector for Ruby files + +let g:ale_ruby_reek_show_context = +\ get(g:, 'ale_ruby_reek_show_context', 0) + +let g:ale_ruby_reek_show_wiki_link = +\ get(g:, 'ale_ruby_reek_show_wiki_link', 0) + +function! ale_linters#ruby#reek#Handle(buffer, lines) abort + if len(a:lines) == 0 + return [] + endif + + let l:errors = json_decode(a:lines[0]) + + let l:output = [] + + for l:error in l:errors + for l:location in l:error.lines + call add(l:output, { + \ 'lnum': l:location, + \ 'type': 'W', + \ 'text': s:BuildText(a:buffer, l:error), + \}) + endfor + endfor + + return l:output +endfunction + +function! s:BuildText(buffer, error) abort + let l:text = a:error.smell_type . ':' + + if ale#Var(a:buffer, 'ruby_reek_show_context') + let l:text .= ' ' . a:error.context + endif + + let l:text .= ' ' . a:error.message + + if ale#Var(a:buffer, 'ruby_reek_show_wiki_link') + let l:text .= ' [' . a:error.wiki_link . ']' + endif + + return l:text +endfunction + +call ale#linter#Define('ruby', { +\ 'name': 'reek', +\ 'executable': 'reek', +\ 'command': 'reek -f json --no-progress --no-color', +\ 'callback': 'ale_linters#ruby#reek#Handle', +\}) |