lintr
lintr copied to clipboard
`lint_dir` doesn't vectorize properly.
I can't really provide a good reprex since it relies on having a specific filesystem constructed.
Note that there's no vectorization test: https://github.com/r-lib/lintr/blob/master/tests/testthat/test-dir_linters.R
Note below: <project-dir> has been clipped and redacted.
> lintr::lint_dir(c("R", "test/R"))
.........................
Error in .rs.normalizePath(marker$file, mustWork = TRUE) :
path[1]="/Users/<project-dir>/R//Users/<project-dir>/R/build_report.R": No such file or directory
In addition: Warning messages:
1: In while (!has_config(path, config)) { :
the condition has length > 1 and only the first element will be used
2: In while (!has_config(path, config)) { :
the condition has length > 1 and only the first element will be used
It looks like either lint_dir needs to be explicitly non-vectorized and stop() if given a char vector over length 1 in the path argument, or it needs to vectorize arguments and handle multiple directories.
Thanks for reporting this. Using a vector input requires relative_path = FALSE. See also the implementation of lint_package(), which handles the relative path feature consistently.
Reproduced on latest master as well as the 2.0.1 release from CRAN.
@AshesITR thanks for that! I tried setting that and it did stop that bug from occurring.
However, upon adding that, the .lintr config is no longer getting picked up.
From the same working directory, unvectorized picks up the .lintr in cwd but vectorized ignores it and applies just the defaults.
Is it a viable option to use lint_dir(".", exclude = list("other", "dirs", "in", ".", "or", "tests/not-R"))?
The directory exclusion feature would allow you to exclude entire directories of other R sources.