Running lintr with box.linters on a project
Source:vignettes/how-to/box-default.Rmd
box-default.Rmd
Setup box.linters
The function use_box_lintr()
creates a minimal .lintr
config file.
box.linters::use_box_lintr()
This would create a .lintr
file in your project
root:
Active box
-compatible linters
Because lintr::object_usage_linter()
is not compatible with box
, the following linter functions
are provided in place of object_usage_linter()
. Examples of
what are considered lint are included in the function reference
pages.
Example
box::use(
stringr[function_not_exists],
dplyr[`%>%`, filter, select, mutate],
shiny
)
unused_function <- function() {
1
}
unused_object <- mtcars %>%
select(mpg, cyl) %>%
filter(mpg >= 10) %>%
undefined_function()
Lint results
<text>:2:11: warning: [box_pkg_fun_exists_linter] Function not exported by package.
stringr[function_not_exists],
^~~~~~~~~~~~~~~~~~~
<text>:2:11: warning: [box_unused_attached_pkg_fun_linter] Imported function unused.
stringr[function_not_exists],
^~~~~~~~~~~~~~~~~~~
<text>:3:32: warning: [box_unused_attached_pkg_fun_linter] Imported function unused.
dplyr[`%>%`, filter, select, mutate],
^~~~~~
<text>:4:3: warning: [box_unused_att_pkg_linter] Attached package unused.
shiny
^~~~~
<text>:7:1: warning: [unused_declared_object_linter] Declared function/object unused.
unused_function <- function() {
^~~~~~~~~~~~~~~
<text>:11:1: warning: [unused_declared_object_linter] Declared function/object unused.
unused_object <- mtcars %>%
^~~~~~~~~~~~~
<text>:14:3: warning: [box_usage_linter] Function not imported nor defined.
undefined_function()
^~~~~~~~~~~~~~~~~~