mirror of https://github.com/dense-analysis/ale
Fallback to summary field if detail exists but is empty in terraform linter (#4157)
* Fallback to summary field if detail exists but is empty in terraform linter * Add test * Update terraform.vim * remove whitespaces
This commit is contained in:
parent
429f5a1447
commit
e343148e80
|
@ -21,7 +21,13 @@ function! ale_linters#terraform#terraform#GetType(severity) abort
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#terraform#terraform#GetDetail(error) abort
|
function! ale_linters#terraform#terraform#GetDetail(error) abort
|
||||||
return get(a:error, 'detail', get(a:error, 'summary', ''))
|
let l:detail = get(a:error, 'detail', '')
|
||||||
|
|
||||||
|
if strlen(l:detail) > 0
|
||||||
|
return l:detail
|
||||||
|
else
|
||||||
|
return get(a:error, 'summary', '')
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#terraform#terraform#Handle(buffer, lines) abort
|
function! ale_linters#terraform#terraform#Handle(buffer, lines) abort
|
||||||
|
|
|
@ -97,3 +97,42 @@ Execute(Should use summary if detail not available):
|
||||||
\ ' ]',
|
\ ' ]',
|
||||||
\ '}'
|
\ '}'
|
||||||
\ ])
|
\ ])
|
||||||
|
|
||||||
|
Execute(Should use summary if detail available but empty):
|
||||||
|
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",',
|
||||||
|
\ ' "detail": "",',
|
||||||
|
\ ' "range": {',
|
||||||
|
\ ' "filename": "main.tf",',
|
||||||
|
\ ' "start": {',
|
||||||
|
\ ' "line": 91,',
|
||||||
|
\ ' "column": 41,',
|
||||||
|
\ ' "byte": 2381',
|
||||||
|
\ ' },',
|
||||||
|
\ ' "end": {',
|
||||||
|
\ ' "line": 91,',
|
||||||
|
\ ' "column": 41,',
|
||||||
|
\ ' "byte": 2381',
|
||||||
|
\ ' }',
|
||||||
|
\ ' }',
|
||||||
|
\ ' }',
|
||||||
|
\ ' ]',
|
||||||
|
\ '}'
|
||||||
|
\ ])
|
||||||
|
|
Loading…
Reference in New Issue