]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/cloudformation/cfn_python_lint.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / ale_linters / cloudformation / cfn_python_lint.vim
1 " Author: Yasuhiro Kiyota <yasuhiroki.duck@gmail.com>
2 " Description: Support cfn-python-lint for AWS Cloudformation template file
3
4 function! ale_linters#cloudformation#cfn_python_lint#Handle(buffer, lines) abort
5     " Matches patterns line the following:
6     "
7     " sample.template.yaml:96:7:96:15:E3012:Property Resources/Sample/Properties/FromPort should be of type Integer
8     let l:pattern = '\v^(.*):(\d+):(\d+):(\d+):(\d+):([[:alnum:]]+):(.*)$'
9     let l:output = []
10
11     for l:match in ale#util#GetMatches(a:lines, l:pattern)
12         let l:code = l:match[6]
13
14         if ale#path#IsBufferPath(a:buffer, l:match[1])
15             call add(l:output, {
16             \   'lnum': l:match[2],
17             \   'col': l:match[3],
18             \   'end_lnum': l:match[4],
19             \   'end_col': l:match[5],
20             \   'code': l:code,
21             \   'type': l:code[:0] is# 'E' ? 'E' : 'W',
22             \   'text': l:match[7]
23             \})
24         endif
25     endfor
26
27     return l:output
28 endfunction
29
30 call ale#linter#Define('cloudformation', {
31 \   'name': 'cloudformation',
32 \   'aliases': ['cfn-lint'],
33 \   'executable': 'cfn-lint',
34 \   'command': 'cfn-lint --template %t --format parseable',
35 \   'callback': 'ale_linters#cloudformation#cfn_python_lint#Handle',
36 \})