summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorƁukasz Jan Niemier <lukasz@niemier.pl>2017-01-30 16:27:26 +0100
committerw0rp <w0rp@users.noreply.github.com>2017-01-30 15:27:26 +0000
commita1458e9c072e1cfc425591b7616a291e99778753 (patch)
treec9a70ba38175fe59f16c5d277b096bdd9fc97930 /ale_linters
parent03bab835d9799f85613ecd235506c566a20dcd63 (diff)
downloadale-a1458e9c072e1cfc425591b7616a291e99778753.zip
Dockerfile linting via hadolint (#282)
* Add hadolint linter for Dockerfiles * Fix path * Fix typo * Update docs
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/dockerfile/hadolint.vim45
-rw-r--r--ale_linters/elixir/credo.vim2
2 files changed, 46 insertions, 1 deletions
diff --git a/ale_linters/dockerfile/hadolint.vim b/ale_linters/dockerfile/hadolint.vim
new file mode 100644
index 00000000..dc8e642c
--- /dev/null
+++ b/ale_linters/dockerfile/hadolint.vim
@@ -0,0 +1,45 @@
+" Author: hauleth - https://github.com/hauleth
+
+function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort
+ " Matches patterns line the following:
+ "
+ " stdin:19: F: Pipe chain should start with a raw value.
+ let l:pattern = '\v^/dev/stdin:?(\d+)? (\S+) (.+)$'
+ let l:output = []
+
+ for l:line in a:lines
+ let l:match = matchlist(l:line, l:pattern)
+
+ if len(l:match) == 0
+ continue
+ endif
+
+ let l:lnum = 0
+
+ if l:match[1] !=# ''
+ let l:lnum = l:match[1] + 0
+ endif
+
+ let l:type = 'W'
+ let l:text = l:match[3]
+
+ " vcol is Needed to indicate that the column is a character.
+ call add(l:output, {
+ \ 'bufnr': a:buffer,
+ \ 'lnum': l:lnum,
+ \ 'vcol': 0,
+ \ 'col': 0,
+ \ 'type': l:type,
+ \ 'text': l:text,
+ \ 'nr': l:match[2],
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('dockerfile', {
+ \ 'name': 'hadolint',
+ \ 'executable': 'hadolint',
+ \ 'command': 'hadolint -',
+ \ 'callback': 'ale_linters#dockerfile#hadolint#Handle' })
diff --git a/ale_linters/elixir/credo.vim b/ale_linters/elixir/credo.vim
index 4ebecf71..f79106d9 100644
--- a/ale_linters/elixir/credo.vim
+++ b/ale_linters/elixir/credo.vim
@@ -1,4 +1,4 @@
-" Author: hauleth - https://github.com/haulethe
+" Author: hauleth - https://github.com/hauleth
function! ale_linters#elixir#credo#Handle(buffer, lines) abort
" Matches patterns line the following: