mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-08 05:24:46 +08:00
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:
committed by
GitHub
parent
cad8f8e683
commit
42a17dec16
@@ -25,7 +25,7 @@ function! ale_linters#ansible#ansible_lint#Handle(buffer, version, lines) abort
|
|||||||
|
|
||||||
if '>=6.0.0' is# l:version_group
|
if '>=6.0.0' is# l:version_group
|
||||||
let l:error_codes = { 'blocker': 'E', 'critical': 'E', 'major': 'W', 'minor': 'W', 'info': 'I' }
|
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
|
for l:issue in l:linter_issues
|
||||||
if ale#path#IsBufferPath(a:buffer, l:issue.location.path)
|
if ale#path#IsBufferPath(a:buffer, l:issue.location.path)
|
||||||
|
|||||||
@@ -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], [
|
\ 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',
|
\ '/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], [])
|
||||||
|
|||||||
Reference in New Issue
Block a user