Handle empty answer of ansible-lint (#4373)

* Handle empty answer of ansible-lint

The variable a:lines might be empty if ansible-lint exited early, in
that case json_decode would trow an error.

* Use ales JSON decode function
This commit is contained in:
Michael F. Schönitzer
2022-12-06 13:44:10 +01:00
committed by GitHub
parent cad8f8e683
commit 42a17dec16
2 changed files with 7 additions and 1 deletions

View File

@@ -25,7 +25,7 @@ function! ale_linters#ansible#ansible_lint#Handle(buffer, version, lines) abort
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, ''))
let l:linter_issues = ale#util#FuzzyJSONDecode(a:lines, [])
for l:issue in l:linter_issues
if ale#path#IsBufferPath(a:buffer, l:issue.location.path)

View File

@@ -93,3 +93,9 @@ Execute (The ansible-lint handler should ignore errors from other files):
\ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [5, 1, 2], [
\ '/foo/bar/roles/test_playbook.yml:6: [command-instead-of-module] [VERY_LOW] curl used in place of get_url or uri module',
\ ])
Execute (The ansible-lint handler should work with empty input):
AssertEqual
\ [
\ ],
\ ale_linters#ansible#ansible_lint#Handle(bufnr(''), [6, 0, 0], [])