mirror of
https://github.com/dense-analysis/ale
synced 2024-12-25 07:32:24 +00:00
Fix 3605 - set fallback for error detail (#3606)
* Fix 3605 - set fallback for error detail * Add use case with no detail key Co-authored-by: Horacio Sanson <horacio@allm.inc>
This commit is contained in:
parent
826878c41e
commit
8c5081f631
@ -20,6 +20,10 @@ function! ale_linters#terraform#terraform#GetType(severity) abort
|
|||||||
return 'E'
|
return 'E'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#terraform#terraform#GetDetail(error) abort
|
||||||
|
return get(a:error, 'detail', get(a:error, 'summary', ''))
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#terraform#terraform#Handle(buffer, lines) abort
|
function! ale_linters#terraform#terraform#Handle(buffer, lines) abort
|
||||||
let l:output = []
|
let l:output = []
|
||||||
|
|
||||||
@ -33,7 +37,7 @@ function! ale_linters#terraform#terraform#Handle(buffer, lines) abort
|
|||||||
\ 'filename': ale#path#GetAbsPath(l:dir, l:error['range']['filename']),
|
\ 'filename': ale#path#GetAbsPath(l:dir, l:error['range']['filename']),
|
||||||
\ 'lnum': l:error['range']['start']['line'],
|
\ 'lnum': l:error['range']['start']['line'],
|
||||||
\ 'col': l:error['range']['start']['column'],
|
\ 'col': l:error['range']['start']['column'],
|
||||||
\ 'text': l:error['detail'],
|
\ 'text': ale_linters#terraform#terraform#GetDetail(l:error),
|
||||||
\ 'type': ale_linters#terraform#terraform#GetType(l:error['severity']),
|
\ 'type': ale_linters#terraform#terraform#GetType(l:error['severity']),
|
||||||
\})
|
\})
|
||||||
else
|
else
|
||||||
@ -41,7 +45,7 @@ function! ale_linters#terraform#terraform#Handle(buffer, lines) abort
|
|||||||
\ 'filename': l:file,
|
\ 'filename': l:file,
|
||||||
\ 'lnum': 0,
|
\ 'lnum': 0,
|
||||||
\ 'col': 0,
|
\ 'col': 0,
|
||||||
\ 'text': l:error['detail'],
|
\ 'text': ale_linters#terraform#terraform#GetDetail(l:error),
|
||||||
\ 'type': ale_linters#terraform#terraform#GetType(l:error['severity']),
|
\ 'type': ale_linters#terraform#terraform#GetType(l:error['severity']),
|
||||||
\})
|
\})
|
||||||
endif
|
endif
|
||||||
|
@ -59,3 +59,41 @@ Execute(The output should be correct):
|
|||||||
\ ' ]',
|
\ ' ]',
|
||||||
\ '}',
|
\ '}',
|
||||||
\ ])
|
\ ])
|
||||||
|
|
||||||
|
Execute(Should use summary if detail not available):
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 91,
|
||||||
|
\ 'col': 41,
|
||||||
|
\ 'filename': ale#path#Simplify(g:dir . '/main.tf'),
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ 'text': 'storage_os_disk: required field is not set',
|
||||||
|
\ }
|
||||||
|
\ ],
|
||||||
|
\ ale_linters#terraform#terraform#Handle(bufnr(''), [
|
||||||
|
\ '{',
|
||||||
|
\ ' "valid": false,',
|
||||||
|
\ ' "error_count": 1,',
|
||||||
|
\ ' "warning_count": 0,',
|
||||||
|
\ ' "diagnostics": [',
|
||||||
|
\ ' {',
|
||||||
|
\ ' "severity": "error",',
|
||||||
|
\ ' "summary": "storage_os_disk: required field is not set",',
|
||||||
|
\ ' "range": {',
|
||||||
|
\ ' "filename": "main.tf",',
|
||||||
|
\ ' "start": {',
|
||||||
|
\ ' "line": 91,',
|
||||||
|
\ ' "column": 41,',
|
||||||
|
\ ' "byte": 2381',
|
||||||
|
\ ' },',
|
||||||
|
\ ' "end": {',
|
||||||
|
\ ' "line": 91,',
|
||||||
|
\ ' "column": 41,',
|
||||||
|
\ ' "byte": 2381',
|
||||||
|
\ ' }',
|
||||||
|
\ ' }',
|
||||||
|
\ ' }',
|
||||||
|
\ ' ]',
|
||||||
|
\ '}'
|
||||||
|
\ ])
|
||||||
|
Loading…
Reference in New Issue
Block a user