summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinfokiller <infokiller@users.noreply.github.com>2021-04-10 15:17:55 +0300
committerGitHub <noreply@github.com>2021-04-10 21:17:55 +0900
commit686c8c5e0acbf3cbf50f1b11eafadd759b017f4a (patch)
treeda49bf99209ff3c1996260b609c5d8210440fc2f
parentcec9954d016e4d388cd6a9abed798de7f330d185 (diff)
downloadale-686c8c5e0acbf3cbf50f1b11eafadd759b017f4a.zip
hadolint: fix color output and stdin shown as "-" (#3680)
-rw-r--r--ale_linters/dockerfile/hadolint.vim9
-rw-r--r--test/test_dockerfile_hadolint_linter.vader4
2 files changed, 8 insertions, 5 deletions
diff --git a/ale_linters/dockerfile/hadolint.vim b/ale_linters/dockerfile/hadolint.vim
index bed87642..e83cfdfd 100644
--- a/ale_linters/dockerfile/hadolint.vim
+++ b/ale_linters/dockerfile/hadolint.vim
@@ -9,7 +9,7 @@ function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort
"
" /dev/stdin:19 DL3001 Pipe chain should start with a raw value.
" /dev/stdin:19:3 unexpected thing
- let l:pattern = '\v^/dev/stdin:(\d+):?(\d+)? ((DL|SC)(\d+) )?((.+)?: )?(.+)$'
+ let l:pattern = '\v^%(/dev/stdin|-):(\d+):?(\d+)? ((DL|SC)(\d+) )?((.+)?: )?(.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
@@ -92,12 +92,15 @@ endfunction
function! ale_linters#dockerfile#hadolint#GetCommand(buffer) abort
let l:command = ale_linters#dockerfile#hadolint#GetExecutable(a:buffer)
+ let l:opts = '--no-color -'
if l:command is# 'docker'
- return 'docker run --rm -i ' . ale#Var(a:buffer, 'dockerfile_hadolint_docker_image')
+ return printf('docker run --rm -i %s hadolint %s',
+ \ ale#Var(a:buffer, 'dockerfile_hadolint_docker_image'),
+ \ l:opts)
endif
- return 'hadolint -'
+ return 'hadolint ' . l:opts
endfunction
diff --git a/test/test_dockerfile_hadolint_linter.vader b/test/test_dockerfile_hadolint_linter.vader
index 882e1a6c..c568f61f 100644
--- a/test/test_dockerfile_hadolint_linter.vader
+++ b/test/test_dockerfile_hadolint_linter.vader
@@ -55,7 +55,7 @@ Execute(command is correct when using docker):
let b:ale_dockerfile_hadolint_use_docker = 'always'
AssertEqual
- \ "docker run --rm -i hadolint/hadolint",
+ \ "docker run --rm -i hadolint/hadolint hadolint --no-color -",
\ ale_linters#dockerfile#hadolint#GetCommand(bufnr(''))
@@ -63,7 +63,7 @@ Execute(command is correct when not docker):
let b:ale_dockerfile_hadolint_use_docker = 'never'
AssertEqual
- \ "hadolint -",
+ \ "hadolint --no-color -",
\ ale_linters#dockerfile#hadolint#GetCommand(bufnr(''))
Execute(test warnings from hadolint):