Merge pull request #1326 from michaelquinn32/patch-1
Call lintr library before linting
This commit is contained in:
commit
31e0f48d62
@ -1,14 +1,18 @@
|
||||
" 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()')
|
||||
let g:ale_r_lintr_options = get(g:, 'ale_r_lintr_options', 'with_defaults()')
|
||||
" A reasonable alternative default:
|
||||
" \ get(g:, 'ale_r_lintr_options', 'lintr::with_defaults(object_usage_linter = NULL)')
|
||||
" get(g:, 'ale_r_lintr_options', 'with_defaults(object_usage_linter = NULL)')
|
||||
|
||||
function! ale_linters#r#lintr#GetCommand(buffer) abort
|
||||
let l:cmd_string = 'suppressPackageStartupMessages(library(lintr));'
|
||||
\ . 'lint(cache = FALSE, commandArgs(TRUE),'
|
||||
\ . ale#Var(a:buffer, 'r_lintr_options') . ')'
|
||||
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . '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'))
|
||||
\ . 'Rscript -e '
|
||||
\ . ale#Escape(l:cmd_string) . ' %t'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('r', {
|
||||
|
@ -17,18 +17,20 @@ 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#Escape('suppressPackageStartupMessages(library(lintr));'
|
||||
\ . 'lint(cache = FALSE, commandArgs(TRUE),'
|
||||
\ . 'with_defaults())')
|
||||
\ . ' %t',
|
||||
\ 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)'
|
||||
let b:ale_r_lintr_options = '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#Escape('suppressPackageStartupMessages(library(lintr));'
|
||||
\ . 'lint(cache = FALSE, commandArgs(TRUE),'
|
||||
\ . 'with_defaults(object_usage_linter = NULL))')
|
||||
\ . ' %t',
|
||||
\ ale_linters#r#lintr#GetCommand(bufnr(''))
|
||||
|
Loading…
Reference in New Issue
Block a user