mirror of https://github.com/dense-analysis/ale
Add lint_package support to lintr
This commit is contained in:
parent
33b3331b04
commit
dda132c1a2
|
@ -1,13 +1,23 @@
|
||||||
" Author: Michel Lang <michellang@gmail.com>, w0rp <devw0rp@gmail.com>
|
" Author: Michel Lang <michellang@gmail.com>, w0rp <devw0rp@gmail.com>,
|
||||||
|
" Fenner Macrae <fmacrae.dev@gmail.com>
|
||||||
" Description: This file adds support for checking R code with lintr.
|
" Description: This file adds support for checking R code with lintr.
|
||||||
|
|
||||||
let g:ale_r_lintr_options = get(g:, 'ale_r_lintr_options', 'with_defaults()')
|
let g:ale_r_lintr_options = get(g:, 'ale_r_lintr_options', 'with_defaults()')
|
||||||
" A reasonable alternative default:
|
" A reasonable alternative default:
|
||||||
" get(g:, 'ale_r_lintr_options', 'with_defaults(object_usage_linter = NULL)')
|
" get(g:, 'ale_r_lintr_options', 'with_defaults(object_usage_linter = NULL)')
|
||||||
|
|
||||||
|
|
||||||
|
let g:ale_r_lintr_lint_package = get(g:, 'ale_r_lintr_lint_package', 0)
|
||||||
|
|
||||||
function! ale_linters#r#lintr#GetCommand(buffer) abort
|
function! ale_linters#r#lintr#GetCommand(buffer) abort
|
||||||
|
if ale#Var(a:buffer, 'r_lintr_lint_package')
|
||||||
|
let l:lint_cmd = 'lint_package'
|
||||||
|
else
|
||||||
|
let l:lint_cmd = 'lint'
|
||||||
|
endif
|
||||||
|
|
||||||
let l:cmd_string = 'suppressPackageStartupMessages(library(lintr));'
|
let l:cmd_string = 'suppressPackageStartupMessages(library(lintr));'
|
||||||
\ . 'lint(cache = FALSE, commandArgs(TRUE),'
|
\ . l:lint_cmd . '(cache = FALSE, commandArgs(TRUE),'
|
||||||
\ . ale#Var(a:buffer, 'r_lintr_options') . ')'
|
\ . ale#Var(a:buffer, 'r_lintr_options') . ')'
|
||||||
|
|
||||||
return ale#path#BufferCdString(a:buffer)
|
return ale#path#BufferCdString(a:buffer)
|
||||||
|
|
|
@ -16,5 +16,14 @@ g:ale_r_lintr_options *g:ale_r_lintr_options*
|
||||||
options. Consult the lintr documentation for more information.
|
options. Consult the lintr documentation for more information.
|
||||||
|
|
||||||
|
|
||||||
|
g:ale_r_lintr_lint_package *g:ale_r_lintr_lint_package*
|
||||||
|
*b:ale_r_lintr_lint_package*
|
||||||
|
Type: |Number|
|
||||||
|
Default: `0`
|
||||||
|
|
||||||
|
When set to `1`, the file will be checked with `lintr::lint_package` instead
|
||||||
|
of `lintr::lint`. This prevents erroneous namespace warnings when linting
|
||||||
|
package files.
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
|
|
|
@ -34,3 +34,15 @@ Execute(The lintr options should be configurable):
|
||||||
\ . 'with_defaults(object_usage_linter = NULL))')
|
\ . 'with_defaults(object_usage_linter = NULL))')
|
||||||
\ . ' %t',
|
\ . ' %t',
|
||||||
\ ale_linters#r#lintr#GetCommand(bufnr(''))
|
\ ale_linters#r#lintr#GetCommand(bufnr(''))
|
||||||
|
|
||||||
|
Execute(If the lint_package flag is set, lintr::lint_package should be called):
|
||||||
|
let b:ale_r_lintr_lint_package = 1
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ 'cd ' . ale#Escape(getcwd()) . ' && '
|
||||||
|
\ . 'Rscript -e '
|
||||||
|
\ . ale#Escape('suppressPackageStartupMessages(library(lintr));'
|
||||||
|
\ . 'lint_package(cache = FALSE, commandArgs(TRUE),'
|
||||||
|
\ . 'with_defaults())')
|
||||||
|
\ . ' %t',
|
||||||
|
\ ale_linters#r#lintr#GetCommand(bufnr(''))
|
||||||
|
|
Loading…
Reference in New Issue