summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/terraform/terraform.vim8
-rw-r--r--test/handler/test_terraform_handler.vader39
2 files changed, 46 insertions, 1 deletions
diff --git a/ale_linters/terraform/terraform.vim b/ale_linters/terraform/terraform.vim
index cf134460..1beb8501 100644
--- a/ale_linters/terraform/terraform.vim
+++ b/ale_linters/terraform/terraform.vim
@@ -21,7 +21,13 @@ function! ale_linters#terraform#terraform#GetType(severity) abort
endfunction
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
function! ale_linters#terraform#terraform#Handle(buffer, lines) abort
diff --git a/test/handler/test_terraform_handler.vader b/test/handler/test_terraform_handler.vader
index d054cb3b..4be89cb1 100644
--- a/test/handler/test_terraform_handler.vader
+++ b/test/handler/test_terraform_handler.vader
@@ -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',
+ \ ' }',
+ \ ' }',
+ \ ' }',
+ \ ' ]',
+ \ '}'
+ \ ])