Skip to content

Commit

Permalink
infer dev dependency on lintr if .lintr exists (#2005)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Nov 13, 2024
1 parent 8a65378 commit 755c2d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions R/dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ renv_dependencies_root_impl <- function(path) {
renv_dependencies_callback <- function(path) {

cbname <- list(
".lintr" = function(path) renv_dependencies_discover_lintr(path),
".Rprofile" = function(path) renv_dependencies_discover_r(path),
"DESCRIPTION" = function(path) renv_dependencies_discover_description(path),
"NAMESPACE" = function(path) renv_dependencies_discover_namespace(path),
Expand Down Expand Up @@ -1029,6 +1030,10 @@ renv_dependencies_discover_rproj <- function(path) {

}

renv_dependencies_discover_lintr <- function(path) {
renv_dependencies_list(path, "lintr", dev = TRUE)
}

renv_dependencies_discover_r <- function(path = NULL,
text = NULL,
expr = NULL,
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -630,3 +630,10 @@ test_that("R scripts that appear destined for knitr::spin() are detected", {
result <- dependencies("resources/knitr-spin.R", quiet = TRUE)
expect_contains(result$Package, c("knitr", "rmarkdown"))
})

test_that("renv infers a dev. dependency on lintr", {
project <- renv_tests_scope()
file.create(".lintr")
deps <- dependencies(quiet = TRUE, dev = TRUE)
expect_contains(deps$Package, "lintr")
})

0 comments on commit 755c2d9

Please sign in to comment.