-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Erlang dialyzer #2509
Add support for Erlang dialyzer #2509
Conversation
doc/ale-erlang.txt
Outdated
@@ -3,6 +3,27 @@ ALE Erlang Integration *ale-erlang-options* | |||
|
|||
|
|||
=============================================================================== | |||
dialyzer *ale-erlang-dialyzer* | |||
|
|||
g:ale_erlang_syntaxerl_executable *g:ale_erlang_dialyzer_executable* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo here.
ale_linters/erlang/dialyzer.vim
Outdated
" Description: Define a checker that runs dialyzer on Erlang files. | ||
|
||
function! ale_linters#erlang#dialyzer#FindPlt() abort | ||
let l:plt_file = split(globpath('_build', '**/*_plt'), '\n') |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The _build
directory is not always present. It is present when the rebar3
build tool is used (it is the most used build system in the ecosystem).
I used the wildcard **
because I didn't know which profile was used when generating the *_plt
file but I changed the code so a profile can be configured thus discarding the need of having to use the wildcard to recursively search.
doc/ale-erlang.txt
Outdated
This variable can be changed to specify the dialyzer executable. | ||
|
||
|
||
g:ale_erlang_plt_file *g:ale_erlang_plt_file* |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
\ 'lnum': str2nr(l:match[1]), | ||
\ 'lcol': 0, | ||
\ 'text': l:code, | ||
\ 'type': 'W' |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tool doesn't provide any information as to whether it is a warning or an error so I chose to make the reported information into warnings.
In doing so, the use of the `**` wildcard becomes unecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking better. 👍
Add some tests for the command string too.
ale_linters/erlang/dialyzer.vim
Outdated
function! ale_linters#erlang#dialyzer#GetCommand(buffer) abort | ||
let l:command = fnameescape(ale_linters#erlang#dialyzer#GetExecutable(a:buffer)) | ||
\ . ' -n' | ||
\ . ' --plt ' . fnameescape(ale_linters#erlang#dialyzer#GetPlt(a:buffer)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ale#Escape()
for escaping command line arguments. fnameescape
is only intended for use with :execute
.
\ . ' -Werror_handling' | ||
\ . ' -Wrace_conditions' | ||
\ . ' -Wunderspecs' | ||
\ . ' %s' |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
ale_linters/erlang/dialyzer.vim
Outdated
function! ale_linters#erlang#dialyzer#FindPlt(buffer) abort | ||
let l:rebar3_profile = ale_linters#erlang#dialyzer#GetRebar3Profile(a:buffer) | ||
let l:plt_file_directory = ale#path#FindNearestDirectory(a:buffer, '_build' . l:rebar3_profile) | ||
let l:plt_file = split(globpath(l:plt_file_directory, '/*_plt'), '\n') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if l:plt_file_directory
is empty before running globpath
.
Cheers! 🍻 |
This PR adds support for the Erlang tool
dialyzer
which type check Erlang modules.