make options for credo configurable (#2337)

* Add credo --strict option

If a user sets 'let g:ale_elixir_credo_strict=1' it will run credo with
--strict instead of suggest.  The default (0) is to run as suggest.

* Added credo docs
This commit is contained in:
Adam Trepanier 2019-03-11 04:12:32 -05:00 committed by w0rp
parent a6012d853c
commit a22ab78dd7
4 changed files with 54 additions and 1 deletions

View File

@ -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', {

View File

@ -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:

View File

@ -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|

View File

@ -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'