Skip to content
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

Merged

Conversation

AntoineGagne
Copy link
Contributor

This PR adds support for the Erlang tool dialyzer which type check Erlang modules.

@@ -3,6 +3,27 @@ ALE Erlang Integration *ale-erlang-options*


===============================================================================
dialyzer *ale-erlang-dialyzer*

g:ale_erlang_syntaxerl_executable *g:ale_erlang_dialyzer_executable*
Copy link
Member

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.

" 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.

Copy link
Contributor Author

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.

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.

\ 'lnum': str2nr(l:match[1]),
\ 'lcol': 0,
\ 'text': l:code,
\ 'type': 'W'

This comment was marked as resolved.

Copy link
Contributor Author

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.
Copy link
Member

@w0rp w0rp left a 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.

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))
Copy link
Member

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.

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')
Copy link
Member

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.

@w0rp w0rp merged commit 3b7c86e into dense-analysis:master May 19, 2019
@w0rp
Copy link
Member

w0rp commented May 19, 2019

Cheers! 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants