Description
Is your feature request related to a problem? Please describe.
When running the lintr hook on a package, it flags many object_usage_linter
errors.
This happens because, unless the package is loaded, lintr is unable to distinguish when a referenced object is completely undefined from when it is defined within the package.
Typically, we would lint the whole package in CI but use pre-commit to only lint those files in a commit set.
We could turn off the object_usage_linter
in the .lintr config, but that config affects both precommit and CI runs of lintr, so would mean that this useful linter would be unavailable in CI.
Describe the solution you'd like
Would it be possible to add a command line option to the pre-commit linting script that determines whether the package in a repo should be loaded prior to running lintr. For example, Rscript lintr.R <files>
would run as currently implemented. But Rscript lintr.R --load-package <files>
would run pkgload::load_all()
before running lintr on the files.