diff options
author | José Júnior <jose.junior@gmail.com> | 2017-04-05 13:21:47 -0400 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2017-04-05 18:21:47 +0100 |
commit | 4caf273d53e7d90e845cb79d0293b1b410f22138 (patch) | |
tree | b6f134287c0ecec4a800441de659110ac7cb6985 /ale_linters/chef | |
parent | c7bd5cc0ba799abb7e382751cdbea49c1b98a429 (diff) | |
download | ale-4caf273d53e7d90e845cb79d0293b1b410f22138.zip |
Adds options to foodcritic linter (#437)
* Adds options to foodcritic linter
Adds a way to pass command line options to the foodcritic command and
documentation about it.
* Creates a simple test for foodcritic command callback
This test simply runs the GetCommand function for the foodcritic linter
and feeds it with some test variables to assert the command line is
being created/escaped correctly.
* Makes foodcritic linter use a command callback
Following review comments, changes the foodcritic linter to use a
`GetCommand` callback for the `command_callback` linter option.
Makes sure that `~` are escaped: flags on foodcritic command line are
negated by adding a `~` in front of the specific cop name:
```
foodcritic -t ~FC011
```
But the way the commands are executed cause foodcritic to fail (since
tilde is recognized as home directory).
* Fixes the doc to include new variables
Diffstat (limited to 'ale_linters/chef')
-rw-r--r-- | ale_linters/chef/foodcritic.vim | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/ale_linters/chef/foodcritic.vim b/ale_linters/chef/foodcritic.vim index 0a6807b2..a3a9af2e 100644 --- a/ale_linters/chef/foodcritic.vim +++ b/ale_linters/chef/foodcritic.vim @@ -1,6 +1,11 @@ " Author: Edward Larkey <edwlarkey@mac.com> +" Author: Jose Junior <jose.junior@gmail.com> " Description: This file adds the foodcritic linter for Chef files. +" Support options! +let g:ale_chef_foodcritic_options = get(g:, 'ale_chef_foodcritic_options', '') +let g:ale_chef_foodcritic_executable = get(g:, 'ale_chef_foodcritic_executable', 'foodcritic') + function! ale_linters#chef#foodcritic#Handle(buffer, lines) abort " Matches patterns line the following: " @@ -29,10 +34,18 @@ function! ale_linters#chef#foodcritic#Handle(buffer, lines) abort return l:output endfunction +function! ale_linters#chef#foodcritic#GetCommand(buffer) abort + return printf('%s %s %%t', + \ g:ale_chef_foodcritic_executable, + \ escape(g:ale_chef_foodcritic_options, '~') + \) +endfunction + + call ale#linter#Define('chef', { \ 'name': 'foodcritic', \ 'executable': 'foodcritic', -\ 'command': 'foodcritic %t', +\ 'command_callback': 'ale_linters#chef#foodcritic#GetCommand', \ 'callback': 'ale_linters#chef#foodcritic#Handle', \}) |