#810 Ignore output which isn't JSON for brakeman

This commit is contained in:
w0rp 2017-07-26 23:17:46 +01:00
parent 810e884dbe
commit ded1bc14df
2 changed files with 19 additions and 12 deletions

View File

@ -9,7 +9,12 @@ function! ale_linters#ruby#brakeman#Handle(buffer, lines) abort
return [] return []
endif endif
try
let l:result = json_decode(join(a:lines, '')) let l:result = json_decode(join(a:lines, ''))
catch /E474/
" Ignore invalid JSON
return []
endtry
let l:output = [] let l:output = []

View File

@ -1,20 +1,15 @@
Before: Before:
" Switch to the test rails directory. call ale#test#SetDirectory('/testplugin/test/handler')
let b:path = getcwd() cd ..
silent! cd /testplugin/test/handler
cd ../ruby_fixtures/valid_rails_app/app/models
runtime ale_linters/ruby/brakeman.vim runtime ale_linters/ruby/brakeman.vim
After: After:
" Switch back to whatever directory it was that we started on. call ale#test#RestoreDirectory()
silent! 'cd ' . fnameescape(b:path)
unlet! b:path
call ale#linter#Reset() call ale#linter#Reset()
Execute(The brakeman handler should parse JSON correctly): Execute(The brakeman handler should parse JSON correctly):
silent file! thing.rb call ale#test#SetFilename('ruby_fixtures/valid_rails_app/app/models/thing.rb')
AssertEqual AssertEqual
\ [ \ [
@ -78,3 +73,10 @@ Execute(The brakeman handler should parse JSON correctly when there is no output
\ [], \ [],
\ ale_linters#ruby#brakeman#Handle(347, [ \ ale_linters#ruby#brakeman#Handle(347, [
\ ]) \ ])
\
Execute(The brakeman handler should handle garbage output):
AssertEqual
\ [],
\ ale_linters#ruby#brakeman#Handle(347, [
\ 'No such command in 2.4.1 of ruby',
\ ])