diff options
author | w0rp <devw0rp@gmail.com> | 2017-07-27 00:45:25 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-07-27 00:45:25 +0100 |
commit | fa33faad9ed6da220394bd2abec2e1bdcd19edba (patch) | |
tree | 288fa6a1f8d2231d3e7b3b8e2915730906d6920e /ale_linters/ruby | |
parent | db4d68eae75c071b2a6521fe8587102f5b781efe (diff) | |
download | ale-fa33faad9ed6da220394bd2abec2e1bdcd19edba.zip |
#810 - Handle output which is not JSON in many linters
Diffstat (limited to 'ale_linters/ruby')
-rw-r--r-- | ale_linters/ruby/brakeman.vim | 14 | ||||
-rw-r--r-- | ale_linters/ruby/rails_best_practices.vim | 10 | ||||
-rw-r--r-- | ale_linters/ruby/reek.vim | 15 |
3 files changed, 7 insertions, 32 deletions
diff --git a/ale_linters/ruby/brakeman.vim b/ale_linters/ruby/brakeman.vim index 565c8c70..0070c15c 100644 --- a/ale_linters/ruby/brakeman.vim +++ b/ale_linters/ruby/brakeman.vim @@ -5,20 +5,10 @@ let g:ale_ruby_brakeman_options = \ get(g:, 'ale_ruby_brakeman_options', '') function! ale_linters#ruby#brakeman#Handle(buffer, lines) abort - if len(a:lines) == 0 - return [] - endif - - try - let l:result = json_decode(join(a:lines, '')) - catch /E474/ - " Ignore invalid JSON - return [] - endtry - let l:output = [] + let l:json = ale#util#FuzzyJSONDecode(a:lines, {}) - for l:warning in l:result.warnings + for l:warning in get(l:json, 'warnings', []) " Brakeman always outputs paths relative to the Rails app root let l:rails_root = ale#ruby#FindRailsRoot(a:buffer) let l:warning_file = l:rails_root . '/' . l:warning.file diff --git a/ale_linters/ruby/rails_best_practices.vim b/ale_linters/ruby/rails_best_practices.vim index a3d9f7a2..503a115c 100644 --- a/ale_linters/ruby/rails_best_practices.vim +++ b/ale_linters/ruby/rails_best_practices.vim @@ -5,17 +5,11 @@ let g:ale_ruby_rails_best_practices_options = \ get(g:, 'ale_ruby_rails_best_practices_options', '') function! ale_linters#ruby#rails_best_practices#Handle(buffer, lines) abort - if len(a:lines) == 0 - return [] - endif - - let l:result = json_decode(join(a:lines, '')) - let l:output = [] - for l:warning in l:result + for l:warning in ale#util#FuzzyJSONDecode(a:lines, []) if !ale#path#IsBufferPath(a:buffer, l:warning.filename) - continue + continue endif call add(l:output, { diff --git a/ale_linters/ruby/reek.vim b/ale_linters/ruby/reek.vim index 5f476fb1..10bc9a84 100644 --- a/ale_linters/ruby/reek.vim +++ b/ale_linters/ruby/reek.vim @@ -1,22 +1,13 @@ " Author: Eddie Lebow https://github.com/elebow " Description: Reek, a code smell detector for Ruby files -let g:ale_ruby_reek_show_context = -\ get(g:, 'ale_ruby_reek_show_context', 0) - -let g:ale_ruby_reek_show_wiki_link = -\ get(g:, 'ale_ruby_reek_show_wiki_link', 0) +call ale#Set('ruby_reek_show_context', 0) +call ale#Set('ruby_reek_show_wiki_link', 0) function! ale_linters#ruby#reek#Handle(buffer, lines) abort - if len(a:lines) == 0 - return [] - endif - - let l:errors = json_decode(a:lines[0]) - let l:output = [] - for l:error in l:errors + for l:error in ale#util#FuzzyJSONDecode(a:lines, []) for l:location in l:error.lines call add(l:output, { \ 'lnum': l:location, |