summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/elixir/credo.vim13
-rw-r--r--doc/ale-elixir.txt12
-rw-r--r--doc/ale.txt2
-rw-r--r--test/command_callback/test_elixir_credo.vader28
4 files changed, 54 insertions, 1 deletions
diff --git a/ale_linters/elixir/credo.vim b/ale_linters/elixir/credo.vim
index 8431c0df..317ecab3 100644
--- a/ale_linters/elixir/credo.vim
+++ b/ale_linters/elixir/credo.vim
@@ -37,11 +37,22 @@ function! ale_linters#elixir#credo#Handle(buffer, lines) abort
return l:output
endfunction
+function! ale_linters#elixir#credo#GetMode() abort
+ if get(g:, 'ale_elixir_credo_strict', 0)
+ return '--strict'
+ else
+ return 'suggest'
+ endif
+endfunction
+
function! ale_linters#elixir#credo#GetCommand(buffer) abort
let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer)
+ let l:mode = ale_linters#elixir#credo#GetMode()
return ale#path#CdString(l:project_root)
- \ . ' mix help credo && mix credo suggest --format=flycheck --read-from-stdin %s'
+ \ . 'mix help credo && '
+ \ . 'mix credo ' . ale_linters#elixir#credo#GetMode()
+ \ . ' --format=flycheck --read-from-stdin %s'
endfunction
call ale#linter#Define('elixir', {
diff --git a/doc/ale-elixir.txt b/doc/ale-elixir.txt
index 45c6de1d..5864f728 100644
--- a/doc/ale-elixir.txt
+++ b/doc/ale-elixir.txt
@@ -72,6 +72,18 @@ g:ale_elixir_elixir_ls_config *g:ale_elixir_elixir_ls_config*
\ }
<
Consult the ElixirLS documentation for more information about settings.
+===============================================================================
+credo *ale-elixir-credo*
+
+Credo (https://github.com/rrrene/credo)
+
+g:ale_elixir_credo_strict *g:ale_elixir_credo_strict*
+
+ Type: Integer
+ Default: 0
+
+ Tells credo to run in strict mode or suggest mode. Set variable to 1 to
+ enable --strict mode.
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale.txt b/doc/ale.txt
index 5f98f269..3812c92d 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -119,6 +119,7 @@ ALE supports the following key features for linting:
mix_format..........................|ale-elixir-mix-format|
dialyxir............................|ale-elixir-dialyxir|
elixir-ls...........................|ale-elixir-elixir-ls|
+ credo...............................|ale-elixir-credo|
elm...................................|ale-elm-options|
elm-format..........................|ale-elm-elm-format|
elm-make............................|ale-elm-elm-make|
@@ -2256,6 +2257,7 @@ documented in additional help files.
mix_format............................|ale-elixir-mix-format|
dialyxir..............................|ale-elixir-dialyxir|
elixir-ls.............................|ale-elixir-elixir-ls|
+ credo.................................|ale-elixir-credo|
elm.....................................|ale-elm-options|
elm-format............................|ale-elm-elm-format|
elm-make..............................|ale-elm-elm-make|
diff --git a/test/command_callback/test_elixir_credo.vader b/test/command_callback/test_elixir_credo.vader
new file mode 100644
index 00000000..1a146db8
--- /dev/null
+++ b/test/command_callback/test_elixir_credo.vader
@@ -0,0 +1,28 @@
+Before:
+ call ale#assert#SetUpLinterTest('elixir', 'credo')
+ call ale#test#SetFilename('elixir_paths/mix_project/lib/app.ex')
+
+
+After:
+ unlet! g:ale_elixir_credo_strict
+
+ call ale#assert#TearDownLinterTest()
+
+Execute(Builds credo command with --strict mode when set to 1):
+ let g:ale_elixir_credo_strict = 1
+
+ AssertLinter 'mix',
+ \ ale#path#CdString(ale#path#Simplify(g:dir . '/elixir_paths/mix_project'))
+ \ . 'mix help credo && mix credo --strict --format=flycheck --read-from-stdin %s'
+
+Execute(Builds credo command with suggest mode by default):
+ AssertLinter 'mix',
+ \ ale#path#CdString(ale#path#Simplify(g:dir . '/elixir_paths/mix_project'))
+ \ . 'mix help credo && mix credo suggest --format=flycheck --read-from-stdin %s'
+
+Execute(Builds credo command with suggest mode when set to 0):
+ let g:ale_elixir_credo_strict = 0
+
+ AssertLinter 'mix',
+ \ ale#path#CdString(ale#path#Simplify(g:dir . '/elixir_paths/mix_project'))
+ \ . 'mix help credo && mix credo suggest --format=flycheck --read-from-stdin %s'