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: Raphael Hoegger - https://github.com/pfuender
2 " Description: Cookstyle (RuboCop based), a code style analyzer for Ruby files
4 call ale#Set('chef_cookstyle_executable', 'cookstyle')
5 call ale#Set('chef_cookstyle_options', '')
7 function! ale_linters#chef#cookstyle#GetCommand(buffer) abort
8 let l:options = ale#Var(a:buffer, 'chef_cookstyle_options')
10 return '%e' . ale#Pad(escape(l:options, '~')) . ' --force-exclusion --format json --stdin ' . ' %s'
13 function! ale_linters#chef#cookstyle#Handle(buffer, lines) abort
18 let l:errors = ale#util#FuzzyJSONDecode(a:lines[0], {})
20 if !has_key(l:errors, 'summary')
21 \|| l:errors['summary']['offense_count'] == 0
22 \|| empty(l:errors['files'])
28 for l:error in l:errors['files'][0]['offenses']
29 let l:start_col = str2nr(l:error['location']['start_column'])
30 let l:end_col = str2nr(l:error['location']['last_column'])
33 let l:end_col = l:start_col + 1
37 \ 'lnum': str2nr(l:error['location']['line']),
39 \ 'end_col': l:end_col,
40 \ 'code': l:error['cop_name'],
41 \ 'text': l:error['message'],
42 \ 'type': l:error['severity'] is? 'convention' ? 'W' : 'E',
49 call ale#linter#Define('chef', {
50 \ 'name': 'cookstyle',
51 \ 'executable': {b -> ale#Var(b, 'chef_cookstyle_executable')},
52 \ 'command': function('ale_linters#chef#cookstyle#GetCommand'),
53 \ 'callback': 'ale_linters#chef#cookstyle#Handle',