#810 - Handle output which is not JSON in many linters

This commit is contained in:
w0rp
2017-07-27 00:45:25 +01:00
parent db4d68eae7
commit fa33faad9e
11 changed files with 101 additions and 143 deletions

View File

@@ -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

View File

@@ -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, {

View File

@@ -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,