From ac3c0c093a2e3ea05793e57d3e836751ba67052b Mon Sep 17 00:00:00 2001 From: pinicarus Date: Wed, 30 Sep 2020 22:44:19 +0200 Subject: [PATCH 1/4] feat(erlang/dialyzer): add custom options passing --- ale_linters/erlang/dialyzer.vim | 18 +++++++++++++----- doc/ale-erlang.txt | 8 ++++++++ ...test_erlang_dialyzer_command_callback.vader | 7 +++++++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/ale_linters/erlang/dialyzer.vim b/ale_linters/erlang/dialyzer.vim index 395647a0..e27f8127 100644 --- a/ale_linters/erlang/dialyzer.vim +++ b/ale_linters/erlang/dialyzer.vim @@ -3,6 +3,8 @@ let g:ale_erlang_dialyzer_executable = \ get(g:, 'ale_erlang_dialyzer_executable', 'dialyzer') +let g:ale_erlang_dialyzer_options = +\ get(g:, 'ale_erlang_dialyzer_options', '') let g:ale_erlang_dialyzer_plt_file = \ get(g:, 'ale_erlang_dialyzer_plt_file', '') let g:ale_erlang_dialyzer_rebar3_profile = @@ -47,14 +49,20 @@ function! ale_linters#erlang#dialyzer#GetExecutable(buffer) abort endfunction function! ale_linters#erlang#dialyzer#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'erlang_dialyzer_options') + + if len(l:options) == 0 + let l:options = '-Wunmatched_returns' + \ . ' -Werror_handling' + \ . ' -Wrace_conditions' + \ . ' -Wunderspecs' + \ . ' %s' + endif + let l:command = ale#Escape(ale_linters#erlang#dialyzer#GetExecutable(a:buffer)) \ . ' -n' \ . ' --plt ' . ale#Escape(ale_linters#erlang#dialyzer#GetPlt(a:buffer)) - \ . ' -Wunmatched_returns' - \ . ' -Werror_handling' - \ . ' -Wrace_conditions' - \ . ' -Wunderspecs' - \ . ' %s' + \ . ' ' . l:options return l:command endfunction diff --git a/doc/ale-erlang.txt b/doc/ale-erlang.txt index 59993a99..eadcfc42 100644 --- a/doc/ale-erlang.txt +++ b/doc/ale-erlang.txt @@ -13,6 +13,14 @@ g:ale_erlang_dialyzer_executable *g:ale_erlang_dialyzer_executable* This variable can be changed to specify the dialyzer executable. +g:ale_erlang_dialyzer_options *g:ale_erlang_dialyzer_options* + *b:ale_erlang_dialyzer_options* + Type: |String| + Default: `'-Wunmatched_returns -Werror_handling -Wrace_conditions -Wunderspec %s'` + + This variable can be changed to specify the options to the dialyzer + executable. The `%s` marker can be used to denote the current file. + g:ale_erlang_dialyzer_plt_file *g:ale_erlang_dialyzer_plt_file* *b:ale_erlang_dialyzer_plt_file* Type: |String| diff --git a/test/command_callback/test_erlang_dialyzer_command_callback.vader b/test/command_callback/test_erlang_dialyzer_command_callback.vader index 5e21c053..97e0455f 100644 --- a/test/command_callback/test_erlang_dialyzer_command_callback.vader +++ b/test/command_callback/test_erlang_dialyzer_command_callback.vader @@ -25,6 +25,13 @@ Execute(The command should accept configured executable.): \ . ' -Wunderspecs' \ . ' %s' +Execute(The command should accept configured options.): + let b:ale_erlang_dialyzer_options = '-r ' . expand('$HOME') + AssertLinter 'dialyzer', + \ ale#Escape('dialyzer') + \ . ' -n --plt ' . ale#Escape(expand('$HOME/.dialyzer_plt')) + \ . ' -r ' . expand('$HOME') + Execute(The command should accept configured PLT file.): let b:ale_erlang_dialyzer_plt_file = 'custom-plt' AssertLinter 'dialyzer', From ef145bda1c477dc8f95dc81ea2511805eadf4934 Mon Sep 17 00:00:00 2001 From: pinicarus Date: Thu, 1 Oct 2020 19:20:31 +0200 Subject: [PATCH 2/4] docs(erlang/dialyzer): change wording a bit --- doc/ale-erlang.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ale-erlang.txt b/doc/ale-erlang.txt index eadcfc42..66b8831c 100644 --- a/doc/ale-erlang.txt +++ b/doc/ale-erlang.txt @@ -18,7 +18,7 @@ g:ale_erlang_dialyzer_options *g:ale_erlang_dialyzer_options* Type: |String| Default: `'-Wunmatched_returns -Werror_handling -Wrace_conditions -Wunderspec %s'` - This variable can be changed to specify the options to the dialyzer + This variable can be changed to specify the options to pass to the dialyzer executable. The `%s` marker can be used to denote the current file. g:ale_erlang_dialyzer_plt_file *g:ale_erlang_dialyzer_plt_file* From d7557ef9be6ce680e811e31e217db5624d9e2897 Mon Sep 17 00:00:00 2001 From: pinicarus Date: Sat, 3 Oct 2020 10:16:04 +0200 Subject: [PATCH 3/4] refactor(erlang/dialyzer): simplify option handling --- ale_linters/erlang/dialyzer.vim | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/ale_linters/erlang/dialyzer.vim b/ale_linters/erlang/dialyzer.vim index e27f8127..41898d9c 100644 --- a/ale_linters/erlang/dialyzer.vim +++ b/ale_linters/erlang/dialyzer.vim @@ -4,7 +4,11 @@ let g:ale_erlang_dialyzer_executable = \ get(g:, 'ale_erlang_dialyzer_executable', 'dialyzer') let g:ale_erlang_dialyzer_options = -\ get(g:, 'ale_erlang_dialyzer_options', '') +\ get(g:, 'ale_erlang_dialyzer_options', '-Wunmatched_returns' +\ . ' -Werror_handling' +\ . ' -Wrace_conditions' +\ . ' -Wunderspecs' +\ . ' %s') let g:ale_erlang_dialyzer_plt_file = \ get(g:, 'ale_erlang_dialyzer_plt_file', '') let g:ale_erlang_dialyzer_rebar3_profile = @@ -51,14 +55,6 @@ endfunction function! ale_linters#erlang#dialyzer#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'erlang_dialyzer_options') - if len(l:options) == 0 - let l:options = '-Wunmatched_returns' - \ . ' -Werror_handling' - \ . ' -Wrace_conditions' - \ . ' -Wunderspecs' - \ . ' %s' - endif - let l:command = ale#Escape(ale_linters#erlang#dialyzer#GetExecutable(a:buffer)) \ . ' -n' \ . ' --plt ' . ale#Escape(ale_linters#erlang#dialyzer#GetPlt(a:buffer)) From 105bc5569550925af3b5f679145e1a13e0840344 Mon Sep 17 00:00:00 2001 From: Pierre-Nicolas Clauss Date: Sun, 17 Jan 2021 14:10:11 +0100 Subject: [PATCH 4/4] refactor(erlang/dialyzer): remove file placeholder from options Signed-off-by: Pierre-Nicolas Clauss --- ale_linters/erlang/dialyzer.vim | 4 ++-- doc/ale-erlang.txt | 4 ++-- .../test_erlang_dialyzer_command_callback.vader | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ale_linters/erlang/dialyzer.vim b/ale_linters/erlang/dialyzer.vim index 41898d9c..a97c9520 100644 --- a/ale_linters/erlang/dialyzer.vim +++ b/ale_linters/erlang/dialyzer.vim @@ -7,8 +7,7 @@ let g:ale_erlang_dialyzer_options = \ get(g:, 'ale_erlang_dialyzer_options', '-Wunmatched_returns' \ . ' -Werror_handling' \ . ' -Wrace_conditions' -\ . ' -Wunderspecs' -\ . ' %s') +\ . ' -Wunderspecs') let g:ale_erlang_dialyzer_plt_file = \ get(g:, 'ale_erlang_dialyzer_plt_file', '') let g:ale_erlang_dialyzer_rebar3_profile = @@ -59,6 +58,7 @@ function! ale_linters#erlang#dialyzer#GetCommand(buffer) abort \ . ' -n' \ . ' --plt ' . ale#Escape(ale_linters#erlang#dialyzer#GetPlt(a:buffer)) \ . ' ' . l:options + \ . ' %s' return l:command endfunction diff --git a/doc/ale-erlang.txt b/doc/ale-erlang.txt index 47524e05..93ac7915 100644 --- a/doc/ale-erlang.txt +++ b/doc/ale-erlang.txt @@ -16,10 +16,10 @@ g:ale_erlang_dialyzer_executable *g:ale_erlang_dialyzer_executable* g:ale_erlang_dialyzer_options *g:ale_erlang_dialyzer_options* *b:ale_erlang_dialyzer_options* Type: |String| - Default: `'-Wunmatched_returns -Werror_handling -Wrace_conditions -Wunderspec %s'` + Default: `'-Wunmatched_returns -Werror_handling -Wrace_conditions -Wunderspec'` This variable can be changed to specify the options to pass to the dialyzer - executable. The `%s` marker can be used to denote the current file. + executable. g:ale_erlang_dialyzer_plt_file *g:ale_erlang_dialyzer_plt_file* *b:ale_erlang_dialyzer_plt_file* diff --git a/test/command_callback/test_erlang_dialyzer_command_callback.vader b/test/command_callback/test_erlang_dialyzer_command_callback.vader index 97e0455f..5e818d7f 100644 --- a/test/command_callback/test_erlang_dialyzer_command_callback.vader +++ b/test/command_callback/test_erlang_dialyzer_command_callback.vader @@ -31,6 +31,7 @@ Execute(The command should accept configured options.): \ ale#Escape('dialyzer') \ . ' -n --plt ' . ale#Escape(expand('$HOME/.dialyzer_plt')) \ . ' -r ' . expand('$HOME') + \ . ' %s' Execute(The command should accept configured PLT file.): let b:ale_erlang_dialyzer_plt_file = 'custom-plt'