我的包中的这个测试在devtools::test()中运行得很好。此外,在线Travis的构建也进展顺利。
test_that("Package style", {
lintr::expect_lint_free()
})然而,对于devtools::check(),它失败了。错误信息是
invalid 'path' argument
Backtrace:
1. lintr::expect_lint_free()
2. lintr::lint_package(...)
3. base::normalizePath(path, mustWork = FALSE)
4. base::path.expand(path)我正在运行RVersion3.6.3 (2020-02-29),在Windows上测试2.3.2和lintr 2.0.1。
我认为问题在于lintr不知道哪个文件要lintr。
有人能告诉我这个问题的解决办法是什么吗?
发布于 2022-02-02 22:27:11
这是带有lintr的已知臭虫。目前,最好的解决方法是将代码替换为:
if (requireNamespace("lintr", quietly = TRUE)) {
library(lintr)
context("linting package")
test_that("Package Style", {
# A duplicate copy of the find_package function from lintr
find_package <- function(path) {
path <- normalizePath(path, mustWork = FALSE)
while (!file.exists(file.path(path, "DESCRIPTION"))) {
path <- dirname(path)
if (identical(path, dirname(path))) {
return(NULL)
}
}
path
}
if (!is.null(find_package("."))) {
expect_lint_free()
)
}
})
}此解决方案的来源在该相同链接中。
https://stackoverflow.com/questions/62540872
复制相似问题