mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
#810 - Handle output which is not JSON in many linters
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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, {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user