Skip to content

Commit 7459b3f

Browse files
authoredMar 6, 2025··
Merge pull request #239 from pharmaverse/238-unexpected-lintr-message
Closes #238
2 parents d616a44 + df810ae commit 7459b3f

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed
 

‎R/get.R

+8-7
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,16 @@ get_unapproved_use <- function(approved_packages, used_packages) {
304304
#'
305305
get_lint_results <- function(file) {
306306

307-
if (!requireNamespace("lintr", quietly = TRUE)) {
308-
message(strwrap("Linting will not be included in the log. Install the
309-
lintr package to use the log.rx.lint feature.",
310-
prefix = " ", initial = ""))
311-
return()
312-
}
313-
314307
# lint file if option is turned on
315308
if (!is.logical(getOption('log.rx.lint'))) {
309+
310+
if (!requireNamespace("lintr", quietly = TRUE)) {
311+
message(strwrap("Linting will not be included in the log. Install the
312+
lintr package to use the log.rx.lint feature.",
313+
prefix = " ", initial = ""))
314+
return()
315+
}
316+
316317
lintr::lint(file, getOption('log.rx.lint'))
317318
}
318319
}

‎tests/testthat/test-get.R

+6
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ test_that("lint returns expected result when using the default log.rx.lint optio
174174
expect_identical(get_lint_results(filename), NULL)
175175
})
176176

177+
test_that("get_lint_results does not return a message if the option set to FALSE", {
178+
options(log.rx.lint = FALSE)
179+
filename <- test_path("ref", "ex6.R")
180+
expect_no_message(get_lint_results(filename))
181+
})
182+
177183
test_that("lint returns expected result when option is changed", {
178184
skip_if_not_installed("lintr")
179185

0 commit comments

Comments
 (0)
Please sign in to comment.