Merge branch 'support-lintr-options'
This commit is contained in:
commit
c2f547b6e3
@ -1,9 +1,14 @@
|
||||
" Author: Michel Lang <michellang@gmail.com>, w0rp <devw0rp@gmail.com>
|
||||
" Description: This file adds support for checking R code with lintr.
|
||||
|
||||
let g:ale_r_lintr_options =
|
||||
\ get(g:, 'ale_r_lintr_options', 'lintr::with_defaults()')
|
||||
" A reasonable alternative default:
|
||||
" \ get(g:, 'ale_r_lintr_options', 'lintr::with_defaults(object_usage_linter = NULL)')
|
||||
|
||||
function! ale_linters#r#lintr#GetCommand(buffer) abort
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . 'Rscript -e ' . ale#Escape('lintr::lint(commandArgs(TRUE))') . ' %t'
|
||||
\ . 'Rscript -e ' . ale#Escape('lintr::lint(commandArgs(TRUE)[1], eval(parse(text = commandArgs(TRUE)[2])))') . ' %t' . ' ' . ale#Escape(ale#Var(a:buffer, 'r_lintr_options'))
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('r', {
|
||||
|
20
doc/ale-r.txt
Normal file
20
doc/ale-r.txt
Normal file
@ -0,0 +1,20 @@
|
||||
===============================================================================
|
||||
ALE R Integration *ale-r-options*
|
||||
|
||||
|
||||
===============================================================================
|
||||
lintr *ale-r-lintr*
|
||||
|
||||
g:ale_r_lintr_options *g:ale_r_lintr_options*
|
||||
*b:ale_r_lintr_options*
|
||||
Type: |String|
|
||||
Default: `'lintr::with_defaults()'`
|
||||
|
||||
This option can be configured to change the options for lintr.
|
||||
|
||||
The value of this option will be run with `eval` for the `lintr::lint`
|
||||
options. Consult the lintr documentation for more information.
|
||||
|
||||
|
||||
===============================================================================
|
||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
@ -101,6 +101,8 @@ CONTENTS *ale-contents*
|
||||
pycodestyle.........................|ale-python-pycodestyle|
|
||||
pylint..............................|ale-python-pylint|
|
||||
yapf................................|ale-python-yapf|
|
||||
r.....................................|ale-r-options|
|
||||
lintr...............................|ale-r-lintr|
|
||||
ruby..................................|ale-ruby-options|
|
||||
brakeman............................|ale-ruby-brakeman|
|
||||
rails_best_practices................|ale-ruby-rails_best_practices|
|
||||
|
34
test/command_callback/test_lintr_command_callback.vader
Normal file
34
test/command_callback/test_lintr_command_callback.vader
Normal file
@ -0,0 +1,34 @@
|
||||
Before:
|
||||
Save g:ale_r_lintr_options
|
||||
|
||||
unlet! g:ale_r_lintr_options
|
||||
unlet! b:ale_r_lintr_options
|
||||
|
||||
runtime ale_linters/r/lintr.vim
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
unlet! b:ale_r_lintr_options
|
||||
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(The default lintr command should be correct):
|
||||
AssertEqual
|
||||
\ 'cd ' . ale#Escape(getcwd()) . ' && '
|
||||
\ . 'Rscript -e '
|
||||
\ . ale#Escape('lintr::lint(commandArgs(TRUE)[1], eval(parse(text = commandArgs(TRUE)[2])))')
|
||||
\ . ' %t '
|
||||
\ . ale#Escape('lintr::with_defaults()'),
|
||||
\ ale_linters#r#lintr#GetCommand(bufnr(''))
|
||||
|
||||
Execute(The lintr options should be configurable):
|
||||
let b:ale_r_lintr_options = 'lintr::with_defaults(object_usage_linter = NULL)'
|
||||
|
||||
AssertEqual
|
||||
\ 'cd ' . ale#Escape(getcwd()) . ' && '
|
||||
\ . 'Rscript -e '
|
||||
\ . ale#Escape('lintr::lint(commandArgs(TRUE)[1], eval(parse(text = commandArgs(TRUE)[2])))')
|
||||
\ . ' %t '
|
||||
\ . ale#Escape('lintr::with_defaults(object_usage_linter = NULL)'),
|
||||
\ ale_linters#r#lintr#GetCommand(bufnr(''))
|
Loading…
Reference in New Issue
Block a user