mirror of
https://github.com/dense-analysis/ale.git
synced 2026-05-11 09:08:32 +08:00
Fix error from ansible-lint versions >=6.11.0. (#4492)
* Fix error from ansible-lint versions >=6.11.0. The JSON output format of ansible-lint has changed since 6.11.0. Issue locations can have either a 'positions' or a 'lines' member, rather than just a 'lines' member as it was before. This fix checks which member is present, and passes that member name to subsequent dictionary lookups. The error was caused by the following change: https://github.com/ansible/ansible-lint/pull/2897 * Add ansible-lint test to check each type of ansible-lint issue json. * Change long single-line JSON in ansible test into multiline JSON. * Fix linting errors in ansible_lint.vim.
This commit is contained in:
@@ -29,10 +29,20 @@ function! ale_linters#ansible#ansible_lint#Handle(buffer, version, lines) abort
|
||||
|
||||
for l:issue in l:linter_issues
|
||||
if ale#path#IsBufferPath(a:buffer, l:issue.location.path)
|
||||
if exists('l:issue.location.positions')
|
||||
let l:coord_keyname = 'positions'
|
||||
else
|
||||
let l:coord_keyname = 'lines'
|
||||
endif
|
||||
|
||||
let l:column_member = printf(
|
||||
\ 'l:issue.location.%s.begin.column', l:coord_keyname
|
||||
\)
|
||||
|
||||
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,
|
||||
\ 'lnum': exists(l:column_member) ? l:issue.location[l:coord_keyname].begin.line :
|
||||
\ l:issue.location[l:coord_keyname].begin,
|
||||
\ 'col': exists(l:column_member) ? l:issue.location[l:coord_keyname].begin.column : 0,
|
||||
\ 'text': l:issue.check_name,
|
||||
\ 'detail': l:issue.description,
|
||||
\ 'code': l:issue.severity,
|
||||
|
||||
Reference in New Issue
Block a user