- Notifications
You must be signed in to change notification settings - Fork4
lintr-compatible linters for box modules in R
Appsilon/box.linters
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
lintr-compatible linters for box modules in R
box.linters is an R package that provides the{lintr} package compatibility with{box} package modules. In addition to providing code-styling checks forbox::use() function calls,box.linters includes a collection of linter functions to replacelintr::object_usage_linter().
While the primary purpose of{box.linters} is for use with the{rhino} package, its functions and features are available for use with any R code or project that uses the{box} package for modular R code.
lintr::object_usage_linter is not compatible with{box} modules.
# use of box modulesbox::use(stringr[...])some_function<-function() { str_trim(" String with trailing and leading white space\t")}
> lintr::lint(box-module.R)<text>:6:3: warning: [object_usage_linter] no visible global function definition for 'str_trim' str_trim(" String with trailing and leading white space ") ^~~~~~~~In order to uselintr andbox together, it was necessary to disablelintr::object_usage_linter():
lintr::lint(box-module.R,linters=lintr::linters_with_defaults(object_usage_linter=NULL))
However, this meant we lose the functionality provided bylintr::object_usage_linter().
Stable version:
install.packages("box.linters")Development version:
# install.packages("remotes")remotes::install_github("Appsilon/box.linters")
Create a configuration file and run selected linters:
# create a .lintr filebox.linters::use_box_lintr()# a file:lintr::lint(filename.R)# in a project:lintr::lint_dir()
Or, usebox.linters manually withlintr:
# a file:lintr::lint(filename.R,linters=box.linters::box_default_linters)# in a project:lintr::lint_dir(linters=box.linters::box_default_linters)
Or, usebox.linters from within a{rhino} project:
# a .lintr file should already exist when a rhino project is created# box.linters::use_box_lintr(type = "rhino")# in a rhino project:rhino::lint_r()
{box.linters} also looks inside{glue} strings. The default opening and closing delimiters are "{" and "}".{glue} provides a way tocustomize delimiters. Support for custom{glue} delimiters are providedproject-wide by settingglue.open andglue.close options in the following manner:
options(list(glue.open="<<",glue.close=">>" ))
This is consistent withglue::glue(), doubling the full delimiter escapes it.
Because settingglue.open andglue.close will beglobal orproject-wide, it is advised to invokeglue in the following manner to avoid confusion:
glue::glue(...,.open= getOption("glue.open"),.close= getOption("glue.close"))
If you want to contribute to this project, please submit a regular PR, once you're done with the new feature or bug fix.
Reporting a bug is also helpful - please useGithub issues and describe your problem as detailed as possible.
Appsilon is aPosit (formerly RStudio) Full Service Certified Partner.
Learn more atappsilon.com.
Get in touchopensource@appsilon.com
Explore theRhinoverse - a family of R packages built aroundRhino!

About
lintr-compatible linters for box modules in R
Topics
Resources
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors7
Uh oh!
There was an error while loading.Please reload this page.
