All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Autoine Gagne - https://github.com/AntoineGagne
2 " Description: Define a checker that runs dialyzer on Erlang files.
4 let g:ale_erlang_dialyzer_executable =
5 \ get(g:, 'ale_erlang_dialyzer_executable', 'dialyzer')
6 let g:ale_erlang_dialyzer_options =
7 \ get(g:, 'ale_erlang_dialyzer_options', '-Wunmatched_returns'
8 \ . ' -Werror_handling'
9 \ . ' -Wrace_conditions'
11 let g:ale_erlang_dialyzer_plt_file =
12 \ get(g:, 'ale_erlang_dialyzer_plt_file', '')
13 let g:ale_erlang_dialyzer_rebar3_profile =
14 \ get(g:, 'ale_erlang_dialyzer_rebar3_profile', 'default')
16 function! ale_linters#erlang#dialyzer#GetRebar3Profile(buffer) abort
17 return ale#Var(a:buffer, 'erlang_dialyzer_rebar3_profile')
20 function! ale_linters#erlang#dialyzer#FindPlt(buffer) abort
22 let l:rebar3_profile = ale_linters#erlang#dialyzer#GetRebar3Profile(a:buffer)
23 let l:plt_file_directory = ale#path#FindNearestDirectory(a:buffer, '_build/' . l:rebar3_profile)
25 if !empty(l:plt_file_directory)
26 let l:plt_file = globpath(l:plt_file_directory, '*_plt', 0, 1)
33 if !empty($REBAR_PLT_DIR)
34 return expand('$REBAR_PLT_DIR/dialyzer/plt')
37 return expand('$HOME/.dialyzer_plt')
40 function! ale_linters#erlang#dialyzer#GetPlt(buffer) abort
41 let l:plt_file = ale#Var(a:buffer, 'erlang_dialyzer_plt_file')
47 return ale_linters#erlang#dialyzer#FindPlt(a:buffer)
50 function! ale_linters#erlang#dialyzer#GetExecutable(buffer) abort
51 return ale#Var(a:buffer, 'erlang_dialyzer_executable')
54 function! ale_linters#erlang#dialyzer#GetCommand(buffer) abort
55 let l:options = ale#Var(a:buffer, 'erlang_dialyzer_options')
57 let l:command = ale#Escape(ale_linters#erlang#dialyzer#GetExecutable(a:buffer))
59 \ . ' --plt ' . ale#Escape(ale_linters#erlang#dialyzer#GetPlt(a:buffer))
66 function! ale_linters#erlang#dialyzer#Handle(buffer, lines) abort
67 " Match patterns like the following:
69 " erl_tidy_prv_fmt.erl:3: Callback info about the provider behaviour is not available
70 let l:pattern = '^\S\+:\(\d\+\): \(.\+\)$'
74 let l:match = matchlist(l:line, l:pattern)
77 let l:code = l:match[2]
80 \ 'lnum': str2nr(l:match[1]),
91 call ale#linter#Define('erlang', {
93 \ 'executable': function('ale_linters#erlang#dialyzer#GetExecutable'),
94 \ 'command': function('ale_linters#erlang#dialyzer#GetCommand'),
95 \ 'callback': function('ale_linters#erlang#dialyzer#Handle'),