mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-26 05:51:08 +08:00
Rubocop: handle empty 'files' array in output
The handler previously assumed there would be at least one entry in the
'files' array in the output JSON. It looks like this in the normal case:
"files":[{"path":"app/models/image.rb","offenses":[]}]
But if RuboCop's config excludes the specified input files, causing no
files to be linted, the output is emptier:
"files":[]
This change causes the handler to treat that case correctly, and also
exit early if the reported offense_count is zero.
This commit is contained in:
@@ -28,6 +28,10 @@ function! ale_linters#ruby#rubocop#Handle(buffer, lines) abort
|
||||
\}]
|
||||
endtry
|
||||
|
||||
if l:errors['summary']['offense_count'] == 0 || empty(l:errors['files'])
|
||||
return []
|
||||
endif
|
||||
|
||||
let l:output = []
|
||||
|
||||
for l:error in l:errors['files'][0]['offenses']
|
||||
|
||||
Reference in New Issue
Block a user