All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Eddie Lebow https://github.com/elebow
2 " Description: Reek, a code smell detector for Ruby files
4 call ale#Set('ruby_reek_show_context', 0)
5 call ale#Set('ruby_reek_show_wiki_link', 0)
6 call ale#Set('ruby_reek_options', '')
7 call ale#Set('ruby_reek_executable', 'reek')
9 function! ale_linters#ruby#reek#GetCommand(buffer, version) abort
10 let l:executable = ale#Var(a:buffer, 'ruby_reek_executable')
12 " Tell reek what the filename is if the version of reek is new enough.
13 let l:display_name_args = ale#semver#GTE(a:version, [5, 0, 0])
14 \ ? ' --stdin-filename %s'
17 return ale#ruby#EscapeExecutable(l:executable, 'reek')
18 \ . ' -f json --no-progress --no-color --force-exclusion'
19 \ . l:display_name_args
22 function! s:GetDocumentationLink(error) abort
23 return get(a:error, 'documentation_link', get(a:error, 'wiki_link', ''))
26 function! s:BuildText(buffer, error) abort
29 if ale#Var(a:buffer, 'ruby_reek_show_context')
30 call add(l:parts, a:error.context)
33 call add(l:parts, a:error.message)
35 if ale#Var(a:buffer, 'ruby_reek_show_wiki_link')
36 call add(l:parts, '[' . s:GetDocumentationLink(a:error) . ']')
39 return join(l:parts, ' ')
42 function! ale_linters#ruby#reek#Handle(buffer, lines) abort
45 for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
46 for l:location in l:error.lines
50 \ 'text': s:BuildText(a:buffer, l:error),
51 \ 'code': l:error.smell_type,
59 call ale#linter#Define('ruby', {
61 \ 'executable': {b -> ale#Var(b, 'ruby_reek_executable')},
62 \ 'command': {buffer -> ale#semver#RunWithVersionCheck(
64 \ ale#Var(buffer, 'ruby_reek_executable'),
66 \ function('ale_linters#ruby#reek#GetCommand'),
68 \ 'callback': 'ale_linters#ruby#reek#Handle',