Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

lintr-compatible linters for box modules in R

NotificationsYou must be signed in to change notification settings

Appsilon/box.linters

lintr-compatible linters for box modules in R

CRAN statusR-CMD-checkCodecov test coverage

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.

Motivation

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().

Installation

Stable version:

install.packages("box.linters")

Development version:

# install.packages("remotes")remotes::install_github("Appsilon/box.linters")

Usage

Create a configuration file and run selected linters:

.lintr setup

# create a .lintr filebox.linters::use_box_lintr()# a file:lintr::lint(filename.R)# in a project:lintr::lint_dir()

Manually

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)

Rhino

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()

{glue} String Interpolation

{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"))

Contribute

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

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!

Subscribe for Shiny tutorials, exclusive articles, R/Shiny community events, and more.

About

lintr-compatible linters for box modules in R

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors7

Languages


[8]ページ先頭

©2009-2025 Movatter.jp