diff --git a/.github/workflows/R-CMD-check-hard.yaml b/.github/workflows/R-CMD-check-hard.yaml index 54db1e064..977807d3c 100644 --- a/.github/workflows/R-CMD-check-hard.yaml +++ b/.github/workflows/R-CMD-check-hard.yaml @@ -48,6 +48,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: + install-quarto: false pak-version: devel dependencies: '"hard"' cache: false diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 110d148cb..f0848b43b 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -70,6 +70,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: + install-quarto: false extra-packages: | any::rcmdcheck needs: check diff --git a/NEWS.md b/NEWS.md index 140ee54ea..68ef13f8d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -58,6 +58,7 @@ * `make_linter_from_xpath()` errors up front when `lint_message` is missing (instead of delaying this error until the linter is used, #2541, @MichaelChirico). * `paste_linter()` is extended to recommend using `paste()` instead of `paste0()` for simply aggregating a character vector with `collapse=`, i.e., when `sep=` is irrelevant (#1108, @MichaelChirico). * `expect_no_lint()` was added as new function to cover the typical use case of expecting no lint message, akin to the recent {testthat} functions like `expect_no_warning()` (#2580, @F-Noelle). +* `lint()` and friends emit a message if no lints are found (#2643, @IndrajeetPatil). ### New linters diff --git a/R/methods.R b/R/methods.R index 29a974d48..869c17ef1 100644 --- a/R/methods.R +++ b/R/methods.R @@ -101,10 +101,14 @@ print.lints <- function(x, ...) { if (isTRUE(settings$error_on_lint)) { quit("no", 31L, FALSE) # nocov } - } else if (use_rstudio_source_markers) { - # Empty lints: clear RStudio source markers - rstudio_source_markers(x) + } else { + # Empty lints + cli_inform(c(i = "No lints found.")) + if (use_rstudio_source_markers) { + rstudio_source_markers(x) # clear RStudio source markers + } } + invisible(x) } diff --git a/tests/testthat/test-methods.R b/tests/testthat/test-methods.R index 172b9692d..b337169f1 100644 --- a/tests/testthat/test-methods.R +++ b/tests/testthat/test-methods.R @@ -96,6 +96,13 @@ test_that("print.lint works", { expect_output(print(l), " 1:length(x)", fixed = TRUE) }) +test_that("print.lint works with empty lints", { + withr::local_options(list(lintr.rstudio_source_markers = FALSE)) + l <- lint(text = "1L") + + expect_message(print(l), "No lints found", fixed = TRUE) +}) + test_that("print.lint works for inline data, even in RStudio", { l <- lint("x = 1\n")