forked from github-mirrors/ale
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
This commit is contained in:
parent
9e1351499c
commit
14265e464a
|
@ -18,9 +18,30 @@ function! ale_linters#ansible#ansible_lint#Handle(buffer, version, lines) abort
|
||||||
endif
|
endif
|
||||||
endfor
|
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 = []
|
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
|
if '>=5.0.0' is# l:version_group
|
||||||
" Matches patterns line the following:
|
" Matches patterns line the following:
|
||||||
" test.yml:3:148: syntax-check 'var' is not a valid attribute for a Play
|
" 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
|
function! ale_linters#ansible#ansible_lint#GetCommand(buffer, version) abort
|
||||||
let l:commands = {
|
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 --parseable-severity -x yaml %s',
|
||||||
\ '<5.0.0': '%e --nocolor -p %t'
|
\ '<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
|
return l:command
|
||||||
endfunction
|
endfunction
|
||||||
|
|
|
@ -15,6 +15,10 @@ Execute(The ansible_lint version >=5.0.0 command callback should return default
|
||||||
GivenCommandOutput ['v5.1.2']
|
GivenCommandOutput ['v5.1.2']
|
||||||
AssertLinter 'ansible-lint', ale#Escape('ansible-lint') . ' --nocolor --parseable-severity -x yaml %s'
|
AssertLinter 'ansible-lint', ale#Escape('ansible-lint') . ' --nocolor --parseable-severity -x yaml %s'
|
||||||
|
|
||||||
|
Execute(The ansible_lint version >=6.0.0 command callback should return default string):
|
||||||
|
GivenCommandOutput ['v6.0.2']
|
||||||
|
AssertLinter 'ansible-lint', ale#Escape('ansible-lint') . ' --nocolor -f json -x yaml %s'
|
||||||
|
|
||||||
Execute(The ansible_lint executable should be configurable):
|
Execute(The ansible_lint executable should be configurable):
|
||||||
let g:ale_ansible_ansible_lint_executable = '~/.local/bin/ansible-lint'
|
let g:ale_ansible_ansible_lint_executable = '~/.local/bin/ansible-lint'
|
||||||
GivenCommandOutput ['v4.1.2']
|
GivenCommandOutput ['v4.1.2']
|
||||||
|
|
Loading…
Reference in New Issue