lintr icon indicating copy to clipboard operation
lintr copied to clipboard

Dealing with `object_usage_linter` during local development

Open AlexAxthelm opened this issue 8 months ago • 16 comments

Hi! I love object_usage_linter; it makes identifying issues during refactoring so much easier than the "run things until they break" strategy 😆

One issue that I've been finding in my package development workflow is that newly-created package objects aren't picked up by lintr if they're spread across files.

For example, if I have R/foo.R:

foo <- function(x) {
  return(x + 1L)
}

and R/bar.r:

bar <- function(y) {
  z <- foo(y)
  return(z)
}

Then I get an object_usage_linter flag for the call to foo() from bar.

If the functions are in the same file, then everything is fine, and lintr runs cleanly. Or if I install the work-in-progress version of the package (using pak::local_install()) then the function gets recognized in the namespace, but that's not ideal.

Is there something I'm missing that would allow lintr to effectively run something like pkgload::load_all()? Ideally it would be something I could set in my local environment, but leave unset for my CI runners.

AlexAxthelm avatar May 30 '24 08:05 AlexAxthelm