summaryrefslogtreecommitdiff
path: root/ale_linters/cloudformation
diff options
context:
space:
mode:
authoryasuhiroki <yasuhiroki.duck@gmail.com>2018-06-05 01:23:25 +0900
committeryasuhiroki <yasuhiroki.duck@gmail.com>2018-06-12 15:11:53 +0900
commitae25d71fa846df0383232d31768ff934192fe313 (patch)
treecb28acfbb280d31eb42fe6c1405b3a28edc982f1 /ale_linters/cloudformation
parent22a9dcd03e3585851c48717c70c7ae7363b6e70c (diff)
downloadale-ae25d71fa846df0383232d31768ff934192fe313.zip
Add linter for AWS CloudFormation template file
Diffstat (limited to 'ale_linters/cloudformation')
-rw-r--r--ale_linters/cloudformation/cfn_python_lint.vim33
1 files changed, 33 insertions, 0 deletions
diff --git a/ale_linters/cloudformation/cfn_python_lint.vim b/ale_linters/cloudformation/cfn_python_lint.vim
new file mode 100644
index 00000000..a401f224
--- /dev/null
+++ b/ale_linters/cloudformation/cfn_python_lint.vim
@@ -0,0 +1,33 @@
+" Author: Yasuhiro Kiyota <yasuhiroki.duck@gmail.com>
+" Description: Support cfn-python-lint for AWS Cloudformation template file
+
+function! ale_linters#cloudformation#cfn_python_lint#Handle(buffer, lines) abort
+ " Matches patterns line the following:
+ "
+ " sample.template.yaml:96:7:96:15: [E3012] Property Resources/Sample/Properties/FromPort should be of type Integer
+ let l:pattern = '\v^(.*):(\d+):(\d+):(\d+):(\d+): \[([[:alnum:]]+)\] (.*)$'
+ let l:output = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ let l:code = l:match[6]
+
+ if ale#path#IsBufferPath(a:buffer, l:match[1])
+ call add(l:output, {
+ \ 'lnum': l:match[2] + 0,
+ \ 'col': l:match[3] + 0,
+ \ 'text': l:match[7],
+ \ 'code': l:code,
+ \ 'type': l:code[:0] is# 'E' ? 'E' : 'W',
+ \})
+ endif
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('cloudformation', {
+\ 'name': 'cloudformation',
+\ 'executable': 'cfn-lint',
+\ 'command': 'cfn-lint --template %t --format parseable',
+\ 'callback': 'ale_linters#cloudformation#cfn_python_lint#Handle',
+\})