summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorMatt Perry <matt@mattperry.com>2022-05-09 04:27:21 -0700
committerGitHub <noreply@github.com>2022-05-09 20:27:21 +0900
commit14265e464af0fde49c4c4751bc2f6a9f7b4812dd (patch)
treef8dd6f485751e71c3e23e5880f8d97d52f94c921 /ale_linters
parent9e1351499c6b9a43a5fddd535f82605bde237e5e (diff)
downloadale-14265e464af0fde49c4c4751bc2f6a9f7b4812dd.zip
Add support for ansible-lint 6.0.0 (#4189)
ansible-lint 6.0.0 removed the `--parseable-severity` option. Use the JSON output in its place. Fixes #4188
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/ansible/ansible_lint.vim28
1 files changed, 26 insertions, 2 deletions
diff --git a/ale_linters/ansible/ansible_lint.vim b/ale_linters/ansible/ansible_lint.vim
index 3b443369..d5d98bc4 100644
--- a/ale_linters/ansible/ansible_lint.vim
+++ b/ale_linters/ansible/ansible_lint.vim
@@ -18,9 +18,30 @@ function! ale_linters#ansible#ansible_lint#Handle(buffer, version, lines) abort
endif
endfor
- let l:version_group = ale#semver#GTE(a:version, [5, 0, 0]) ? '>=5.0.0' : '<5.0.0'
+ let l:version_group = ale#semver#GTE(a:version, [6, 0, 0]) ? '>=6.0.0' :
+ \ ale#semver#GTE(a:version, [5, 0, 0]) ? '>=5.0.0' :
+ \ '<5.0.0'
let l:output = []
+ if '>=6.0.0' is# l:version_group
+ let l:error_codes = { 'blocker': 'E', 'critical': 'E', 'major': 'W', 'minor': 'W', 'info': 'I' }
+ let l:linter_issues = json_decode(join(a:lines, ''))
+
+ for l:issue in l:linter_issues
+ if ale#path#IsBufferPath(a:buffer, l:issue.location.path)
+ call add(l:output, {
+ \ 'lnum': exists('l:issue.location.lines.begin.column') ? l:issue.location.lines.begin.line :
+ \ l:issue.location.lines.begin,
+ \ 'col': exists('l:issue.location.lines.begin.column') ? l:issue.location.lines.begin.column : 0,
+ \ 'text': l:issue.check_name,
+ \ 'detail': l:issue.description,
+ \ 'code': l:issue.severity,
+ \ 'type': l:error_codes[l:issue.severity],
+ \})
+ endif
+ endfor
+ endif
+
if '>=5.0.0' is# l:version_group
" Matches patterns line the following:
" test.yml:3:148: syntax-check 'var' is not a valid attribute for a Play
@@ -73,10 +94,13 @@ endfunction
function! ale_linters#ansible#ansible_lint#GetCommand(buffer, version) abort
let l:commands = {
+ \ '>=6.0.0': '%e --nocolor -f json -x yaml %s',
\ '>=5.0.0': '%e --nocolor --parseable-severity -x yaml %s',
\ '<5.0.0': '%e --nocolor -p %t'
\}
- let l:command = ale#semver#GTE(a:version, [5, 0]) ? l:commands['>=5.0.0'] : l:commands['<5.0.0']
+ let l:command = ale#semver#GTE(a:version, [6, 0]) ? l:commands['>=6.0.0'] :
+ \ ale#semver#GTE(a:version, [5, 0]) ? l:commands['>=5.0.0'] :
+ \ l:commands['<5.0.0']
return l:command
endfunction