Add Elixir linter for dialyxir (#1257)

* Add Elixir linter for dialyxir

* Update doc/ale.txt with dialyxir

* Keep elixir tools alphabetically ordered in README

* Add a missing entry for dialyxir to the main documentation file.
This commit is contained in:
Fran Casas 2018-01-22 13:21:07 +01:00 committed by w0rp
parent acf9c92ab4
commit 038789f0ed
4 changed files with 52 additions and 2 deletions

View File

@ -94,7 +94,7 @@ formatting.
| Dafny | [dafny](https://rise4fun.com/Dafny) !! | | Dafny | [dafny](https://rise4fun.com/Dafny) !! |
| Dart | [dartanalyzer](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli) !!, [language_server](https://github.com/natebosch/dart_language_server) | | Dart | [dartanalyzer](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli) !!, [language_server](https://github.com/natebosch/dart_language_server) |
| Dockerfile | [hadolint](https://github.com/lukasmartinelli/hadolint) | | Dockerfile | [hadolint](https://github.com/lukasmartinelli/hadolint) |
| Elixir | [credo](https://github.com/rrrene/credo), [dogma](https://github.com/lpil/dogma) !! | | Elixir | [credo](https://github.com/rrrene/credo), [dialyxir](https://github.com/jeremyjh/dialyxir), [dogma](https://github.com/lpil/dogma) !!|
| Elm | [elm-format](https://github.com/avh4/elm-format), [elm-make](https://github.com/elm-lang/elm-make) | | Elm | [elm-format](https://github.com/avh4/elm-format), [elm-make](https://github.com/elm-lang/elm-make) |
| Erb | [erb](https://github.com/jeremyevans/erubi), [erubis](https://github.com/kwatch/erubis) | | Erb | [erb](https://github.com/jeremyevans/erubi), [erubis](https://github.com/kwatch/erubis) |
| Erlang | [erlc](http://erlang.org/doc/man/erlc.html), [SyntaxErl](https://github.com/ten0s/syntaxerl) | | Erlang | [erlc](http://erlang.org/doc/man/erlc.html), [SyntaxErl](https://github.com/ten0s/syntaxerl) |

View File

@ -0,0 +1,34 @@
" Author: Fran C. - https://github.com/franciscoj
" Description: Add dialyzer support for elixir through dialyxir
" https://github.com/jeremyjh/dialyxir
function! ale_linters#elixir#dialyxir#Handle(buffer, lines) abort
" Matches patterns line the following:
"
" lib/filename.ex:19: Function fname/1 has no local return
let l:pattern = '\v(.+):(\d+): (.+)$'
let l:output = []
let l:type = 'W'
for l:match in ale#util#GetMatches(a:lines, l:pattern)
if bufname(a:buffer) == l:match[1]
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[2] + 0,
\ 'col': 0,
\ 'type': l:type,
\ 'text': l:match[3],
\})
endif
endfor
return l:output
endfunction
call ale#linter#Define('elixir', {
\ 'name': 'dialyxir',
\ 'executable': 'mix',
\ 'command': 'mix dialyzer',
\ 'callback': 'ale_linters#elixir#dialyxir#Handle',
\})

View File

@ -13,5 +13,20 @@ g:ale_elixir_mix_options *g:ale_elixir_mix_options*
This variable can be changed to specify the mix executable. This variable can be changed to specify the mix executable.
===============================================================================
dialyxir *ale-elixir-dialyxir*
Dialyzer, a DIscrepancy AnaLYZer for ERlang programs.
http://erlang.org/doc/man/dialyzer.html
It can be used with elixir through dialyxir
https://github.com/jeremyjh/dialyxir
Options for dialyzer are not configurable by ale, but they are instead
configured on your project's `mix.exs`.
See https://github.com/jeremyjh/dialyxir#with-explaining-stuff for more
information.
=============================================================================== ===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View File

@ -57,6 +57,7 @@ CONTENTS *ale-contents*
hadolint............................|ale-dockerfile-hadolint| hadolint............................|ale-dockerfile-hadolint|
elixir................................|ale-elixir-options| elixir................................|ale-elixir-options|
mix.................................|ale-elixir-mix| mix.................................|ale-elixir-mix|
dialyxir............................|ale-elixir-dialyxir|
elm...................................|ale-elm-options| elm...................................|ale-elm-options|
elm-format..........................|ale-elm-elm-format| elm-format..........................|ale-elm-elm-format|
elm-make............................|ale-elm-elm-make| elm-make............................|ale-elm-elm-make|
@ -301,7 +302,7 @@ Notes:
* Dafny: `dafny`!! * Dafny: `dafny`!!
* Dart: `dartanalyzer`!!, `language_server` * Dart: `dartanalyzer`!!, `language_server`
* Dockerfile: `hadolint` * Dockerfile: `hadolint`
* Elixir: `credo`, `dogma`!! * Elixir: `credo`, `dialyxir`, `dogma`!!
* Elm: `elm-format, elm-make` * Elm: `elm-format, elm-make`
* Erb: `erb`, `erubis` * Erb: `erb`, `erubis`
* Erlang: `erlc`, `SyntaxErl` * Erlang: `erlc`, `SyntaxErl`