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: ymap - https://github.com/ymap
2 " Description: Packwerk, a static analyzer used to enforce boundaries and modularize Rails applications.
4 call ale#Set('ruby_packwerk_executable', 'packwerk')
5 call ale#Set('ruby_packwerk_options', '')
7 function! ale_linters#ruby#packwerk#Handle(buffer, lines) abort
8 let l:pattern = '\v^[^:]+:(\d+):(\d+)$'
12 while l:index < len(a:lines) - 1
13 let l:cleaned_line = substitute(a:lines[l:index], '\v\e\[[0-9;]*m', '', 'g')
14 let l:match = matchlist(l:cleaned_line, l:pattern)
18 \ 'lnum': l:match[1] + 0,
19 \ 'col': l:match[2] + 0,
20 \ 'text': a:lines[l:index + 1],
30 function! ale_linters#ruby#packwerk#GetCommand(buffer) abort
31 let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
33 if l:rails_root is? ''
37 let l:executable = ale#Var(a:buffer, 'ruby_packwerk_executable')
38 let l:sep = has('win32') ? '\' : '/'
39 let l:abs_path = expand('#' . a:buffer . ':p')
40 let l:rel_path = substitute(l:abs_path, escape(l:rails_root . l:sep, '\'), '', '')
42 return ale#ruby#EscapeExecutable(l:executable, 'packwerk')
44 \ . ale#Pad(ale#Var(a:buffer, 'ruby_packwerk_options'))
46 \ . ale#Escape(rel_path)
49 call ale#linter#Define('ruby', {
51 \ 'executable': {b -> ale#Var(b, 'ruby_packwerk_executable')},
52 \ 'command': function('ale_linters#ruby#packwerk#GetCommand'),
53 \ 'callback': 'ale_linters#ruby#packwerk#Handle',