summaryrefslogtreecommitdiff
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
parent03bab835d9799f85613ecd235506c566a20dcd63 (diff)
downloadale-a1458e9c072e1cfc425591b7616a291e99778753.zip
Dockerfile linting via hadolint (#282)
* Add hadolint linter for Dockerfiles * Fix path * Fix typo * Update docs
-rw-r--r--README.md1
-rw-r--r--ale_linters/dockerfile/hadolint.vim45
-rw-r--r--ale_linters/elixir/credo.vim2
-rw-r--r--doc/ale.txt1
4 files changed, 48 insertions, 1 deletions
diff --git a/README.md b/README.md
index b5a6a61f..1b59b632 100644
--- a/README.md
+++ b/README.md
@@ -59,6 +59,7 @@ name. That seems to be the fairest way to arrange this table.
| CSS | [csslint](http://csslint.net/), [stylelint](https://github.com/stylelint/stylelint) |
| Cython (pyrex filetype) | [cython](http://cython.org/) |
| D | [dmd](https://dlang.org/dmd-linux.html)^ |
+| Dockerfile | [hadolint](https://github.com/lukasmartinelli/hadolint) |
| Elixir | [credo](https://github.com/rrrene/credo) |
| Elm | [elm-make](https://github.com/elm-lang/elm-make) |
| Erlang | [erlc](http://erlang.org/doc/man/erlc.html) |
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:
diff --git a/doc/ale.txt b/doc/ale.txt
index 173951c9..4bed2e02 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -77,6 +77,7 @@ The following languages and tools are supported.
* CSS: 'csslint', 'stylelint'
* Cython (pyrex filetype): 'cython'
* D: 'dmd'
+* Dockerfile: 'hadolint'
* Elixir: 'credo'
* Elm: 'elm-make'
* Erlang: 'erlc'