#2395 - Handle empty output for redpen

This commit is contained in:
w0rp 2019-03-29 16:09:27 +00:00
parent e1e8f0dae1
commit 3eb6d7b3db
No known key found for this signature in database
GPG key ID: 0FC1ECAA8C81CD83
3 changed files with 13 additions and 5 deletions

View file

@ -4,10 +4,10 @@
function! ale#handlers#redpen#HandleRedpenOutput(buffer, lines) abort
" Only one file was passed to redpen. So response array has only one
" element.
let l:res = json_decode(join(a:lines))[0]
let l:res = get(ale#util#FuzzyJSONDecode(a:lines, []), 0, {})
let l:output = []
for l:err in l:res.errors
for l:err in get(l:res, 'errors', [])
let l:item = {
\ 'text': l:err.message,
\ 'type': 'W',

View file

@ -24,6 +24,9 @@ Execute(Vendor executables should be detected):
Execute(The project path should be correct for .git directories):
call ale#test#SetFilename('psalm-project/test.php')
call mkdir(g:dir . '/.git')
AssertLSPProject g:dir
if !isdirectory(g:dir . '/.git')
call mkdir(g:dir . '/.git')
endif
AssertLSPProject g:dir

View file

@ -80,7 +80,7 @@ Execute(redpen handler should handle errors output):
\ ']',
\ ])
Execute(redpen handler should no error output):
Execute(The redpen handler should handle an empty error list):
AssertEqual
\ [],
\ ale#handlers#redpen#HandleRedpenOutput(bufnr(''), [
@ -91,3 +91,8 @@ Execute(redpen handler should no error output):
\ ' }',
\ ']',
\ ])
Execute(The redpen handler should handle totally empty output):
AssertEqual
\ [],
\ ale#handlers#redpen#HandleRedpenOutput(bufnr(''), [])