Merge pull request #3158 from ulidtko/improve-dockerfile_lint
Improve :ALEDetail for dockerfile_lint [READY TO REVIEW]
This commit is contained in:
commit
834d6f9c48
2 changed files with 22 additions and 3 deletions
|
@ -32,14 +32,29 @@ function! ale_linters#dockerfile#dockerfile_lint#Handle(buffer, lines) abort
|
||||||
let l:line = get(l:object, 'line', -1)
|
let l:line = get(l:object, 'line', -1)
|
||||||
let l:message = l:object['message']
|
let l:message = l:object['message']
|
||||||
|
|
||||||
if get(l:object, 'description', 'None') isnot# 'None'
|
let l:link = get(l:object, 'reference_url', '')
|
||||||
let l:message = l:message . '. ' . l:object['description']
|
|
||||||
|
if type(l:link) == v:t_list
|
||||||
|
" Somehow, reference_url is returned as two-part list.
|
||||||
|
" Anchor markers in that list are sometimes duplicated.
|
||||||
|
" See https://github.com/projectatomic/dockerfile_lint/issues/134
|
||||||
|
let l:link = join(l:link, '')
|
||||||
|
let l:link = substitute(l:link, '##', '#', '')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let l:detail = l:message
|
||||||
|
|
||||||
|
if get(l:object, 'description', 'None') isnot# 'None'
|
||||||
|
let l:detail .= "\n\n" . l:object['description']
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:detail .= "\n\n" . l:link
|
||||||
|
|
||||||
call add(l:messages, {
|
call add(l:messages, {
|
||||||
\ 'lnum': l:line,
|
\ 'lnum': l:line,
|
||||||
\ 'text': l:message,
|
\ 'text': l:message,
|
||||||
\ 'type': ale_linters#dockerfile#dockerfile_lint#GetType(l:type),
|
\ 'type': ale_linters#dockerfile#dockerfile_lint#GetType(l:type),
|
||||||
|
\ 'detail': l:detail,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
endfor
|
endfor
|
||||||
|
|
|
@ -26,21 +26,25 @@ Execute(The dockerfile_lint handler should handle a normal example):
|
||||||
\ 'lnum': -1,
|
\ 'lnum': -1,
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'text': "Required LABEL name/key 'Name' is not defined",
|
\ 'text': "Required LABEL name/key 'Name' is not defined",
|
||||||
|
\ 'detail': "Required LABEL name/key 'Name' is not defined\n\nhttp://docs.projectatomic.io/container-best-practices/#_recommended_labels_for_your_project",
|
||||||
\ },
|
\ },
|
||||||
\ {
|
\ {
|
||||||
\ 'lnum': -1,
|
\ 'lnum': -1,
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'text': "Required LABEL name/key 'Version' is not defined",
|
\ 'text': "Required LABEL name/key 'Version' is not defined",
|
||||||
|
\ 'detail': "Required LABEL name/key 'Version' is not defined\n\nhttp://docs.projectatomic.io/container-best-practices/#_recommended_labels_for_your_project",
|
||||||
\ },
|
\ },
|
||||||
\ {
|
\ {
|
||||||
\ 'lnum': 3,
|
\ 'lnum': 3,
|
||||||
\ 'type': 'I',
|
\ 'type': 'I',
|
||||||
\ 'text': "the MAINTAINER command is deprecated. MAINTAINER is deprecated in favor of using LABEL since Docker v1.13.0",
|
\ 'text': "the MAINTAINER command is deprecated",
|
||||||
|
\ 'detail': "the MAINTAINER command is deprecated\n\nMAINTAINER is deprecated in favor of using LABEL since Docker v1.13.0\n\nhttps://github.com/docker/cli/blob/master/docs/deprecated.md#maintainer-in-dockerfile",
|
||||||
\ },
|
\ },
|
||||||
\ {
|
\ {
|
||||||
\ 'lnum': -1,
|
\ 'lnum': -1,
|
||||||
\ 'type': 'I',
|
\ 'type': 'I',
|
||||||
\ 'text': "There is no 'CMD' instruction",
|
\ 'text': "There is no 'CMD' instruction",
|
||||||
|
\ 'detail': "There is no 'CMD' instruction\n\nhttps://docs.docker.com/engine/reference/builder/#cmd",
|
||||||
\ },
|
\ },
|
||||||
\ ],
|
\ ],
|
||||||
\ ale_linters#dockerfile#dockerfile_lint#Handle(bufnr(''), [
|
\ ale_linters#dockerfile#dockerfile_lint#Handle(bufnr(''), [
|
||||||
|
|
Reference in a new issue