#769 Ignore stderr output and output without JSON we can read for rubocop
This commit is contained in:
parent
f7f6f6541d
commit
b50ae96413
@ -14,22 +14,16 @@ function! ale_linters#ruby#rubocop#GetCommand(buffer) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#ruby#rubocop#Handle(buffer, lines) abort
|
function! ale_linters#ruby#rubocop#Handle(buffer, lines) abort
|
||||||
if empty(a:lines)
|
|
||||||
return []
|
|
||||||
endif
|
|
||||||
|
|
||||||
try
|
try
|
||||||
let l:errors = json_decode(a:lines[0])
|
let l:errors = json_decode(a:lines[0])
|
||||||
catch
|
catch
|
||||||
return [{
|
return []
|
||||||
\ 'lnum': 1,
|
|
||||||
\ 'text': 'rubocop configuration error (type :ALEDetail for more information)',
|
|
||||||
\ 'detail': join(a:lines, "\n"),
|
|
||||||
\}]
|
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
if l:errors['summary']['offense_count'] == 0 || empty(l:errors['files'])
|
if !has_key(l:errors, 'summary')
|
||||||
return []
|
\|| l:errors['summary']['offense_count'] == 0
|
||||||
|
\|| empty(l:errors['files'])
|
||||||
|
return []
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:output = []
|
let l:output = []
|
||||||
@ -63,5 +57,4 @@ call ale#linter#Define('ruby', {
|
|||||||
\ 'executable_callback': 'ale#handlers#rubocop#GetExecutable',
|
\ 'executable_callback': 'ale#handlers#rubocop#GetExecutable',
|
||||||
\ 'command_callback': 'ale_linters#ruby#rubocop#GetCommand',
|
\ 'command_callback': 'ale_linters#ruby#rubocop#GetCommand',
|
||||||
\ 'callback': 'ale_linters#ruby#rubocop#Handle',
|
\ 'callback': 'ale_linters#ruby#rubocop#Handle',
|
||||||
\ 'output_stream': 'both',
|
|
||||||
\})
|
\})
|
||||||
|
@ -55,19 +55,18 @@ Execute(The rubocop handler should handle when no files are checked):
|
|||||||
\ '{"metadata":{"rubocop_version":"0.47.1","ruby_engine":"ruby","ruby_version":"2.1.5","ruby_patchlevel":"273","ruby_platform":"x86_64-linux-gnu"},"files":[],"summary":{"offense_count":0,"target_file_count":0,"inspected_file_count":0}}'
|
\ '{"metadata":{"rubocop_version":"0.47.1","ruby_engine":"ruby","ruby_version":"2.1.5","ruby_patchlevel":"273","ruby_platform":"x86_64-linux-gnu"},"files":[],"summary":{"offense_count":0,"target_file_count":0,"inspected_file_count":0}}'
|
||||||
\ ])
|
\ ])
|
||||||
|
|
||||||
Execute(Parse errors should be handled for rubocop):
|
Execute(The rubocop handler should handle output without any errors):
|
||||||
let g:lines = [
|
let g:lines = [
|
||||||
\ '/my/project/.rubocop.yml: Layout/MultilineOperationIndentation has the wrong namespace - should be Style',
|
|
||||||
\ '/my/project/.rubocop.yml: Layout/AlignHash has the wrong namespace - should be Style',
|
|
||||||
\ '{"metadata":{"rubocop_version":"0.48.1","ruby_engine":"ruby","ruby_version":"2.4.1","ruby_patchlevel":"111","ruby_platform":"x86_64-darwin16"},"files":[]}',
|
\ '{"metadata":{"rubocop_version":"0.48.1","ruby_engine":"ruby","ruby_version":"2.4.1","ruby_patchlevel":"111","ruby_platform":"x86_64-darwin16"},"files":[]}',
|
||||||
\]
|
\]
|
||||||
|
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ [
|
\ [],
|
||||||
\ {
|
|
||||||
\ 'lnum': 1,
|
|
||||||
\ 'text': 'rubocop configuration error (type :ALEDetail for more information)',
|
|
||||||
\ 'detail': join(g:lines, "\n"),
|
|
||||||
\ },
|
|
||||||
\ ],
|
|
||||||
\ ale_linters#ruby#rubocop#Handle(347, g:lines)
|
\ ale_linters#ruby#rubocop#Handle(347, g:lines)
|
||||||
|
\
|
||||||
|
AssertEqual
|
||||||
|
\ [],
|
||||||
|
\ ale_linters#ruby#rubocop#Handle(347, ['{}'])
|
||||||
|
AssertEqual
|
||||||
|
\ [],
|
||||||
|
\ ale_linters#ruby#rubocop#Handle(347, [])
|
||||||
|
Loading…
Reference in New Issue
Block a user