Skip to contents

Checks that all attached package functions are used within the source file.

Usage

box_unused_att_pkg_fun_linter()

Value

A custom linter function for use with r-lib/lintr.

Details

For use in rhino, see the Explanation: Rhino style guide to learn about the details.

Examples

# will produce lints
code <- "
box::use(
  stringr[str_pad],
)
"

lintr::lint(text = code, linters = box_unused_att_pkg_fun_linter())
#> ::warning file=<text>,line=3,col=11::file=<text>,line=3,col=11,[box_unused_att_pkg_fun_linter] Imported function unused.

code <- "
box::use(
  stringr[alias_func = str_pad],
)
"

lintr::lint(text = code, linters = box_unused_att_pkg_fun_linter())
#> ::warning file=<text>,line=3,col=24::file=<text>,line=3,col=24,[box_unused_att_pkg_fun_linter] Imported function unused.

# okay
code <- "
box::use(
  stringr[str_pad],
)

str_pad()
"

lintr::lint(text = code, linters = box_unused_att_pkg_fun_linter())

code <- "
box::use(
  stringr[alias_func = str_pad],
)

alias_func()
"

lintr::lint(text = code, linters = box_unused_att_pkg_fun_linter())