diff options
author | w0rp <devw0rp@gmail.com> | 2019-03-29 16:09:27 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2019-03-29 16:09:27 +0000 |
commit | 3eb6d7b3db5d76aae1d394f8615a52e1d4bee9fa (patch) | |
tree | 1a63b18cdf6160f279774ab992e58baf70c48b0c | |
parent | e1e8f0dae12fc8603ab2e949f34bce8106fa3263 (diff) | |
download | ale-3eb6d7b3db5d76aae1d394f8615a52e1d4bee9fa.zip |
#2395 - Handle empty output for redpen
-rw-r--r-- | autoload/ale/handlers/redpen.vim | 4 | ||||
-rw-r--r-- | test/command_callback/test_psalm_command_callbacks.vader | 7 | ||||
-rw-r--r-- | test/handler/test_redpen_handler.vader | 7 |
3 files changed, 13 insertions, 5 deletions
diff --git a/autoload/ale/handlers/redpen.vim b/autoload/ale/handlers/redpen.vim index 84e331ed..195057ca 100644 --- a/autoload/ale/handlers/redpen.vim +++ b/autoload/ale/handlers/redpen.vim @@ -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', diff --git a/test/command_callback/test_psalm_command_callbacks.vader b/test/command_callback/test_psalm_command_callbacks.vader index d731054f..33d770c2 100644 --- a/test/command_callback/test_psalm_command_callbacks.vader +++ b/test/command_callback/test_psalm_command_callbacks.vader @@ -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
\ No newline at end of file + if !isdirectory(g:dir . '/.git') + call mkdir(g:dir . '/.git') + endif + + AssertLSPProject g:dir diff --git a/test/handler/test_redpen_handler.vader b/test/handler/test_redpen_handler.vader index 4490bcba..0b030e2d 100644 --- a/test/handler/test_redpen_handler.vader +++ b/test/handler/test_redpen_handler.vader @@ -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(''), []) |