Skip to content

Commit 3358539

Browse files
Print a message when no lints found (#2643)
* Print a message when no lints found closes #2640 * use info markup * Update NEWS.md * delint * more inlining * use single if-else * Create a separate NEWS entry * don't install quarto to avoid NOTE
1 parent f2da882 commit 3358539

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

.github/workflows/R-CMD-check-hard.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848

4949
- uses: r-lib/actions/setup-r-dependencies@v2
5050
with:
51+
install-quarto: false
5152
pak-version: devel
5253
dependencies: '"hard"'
5354
cache: false

.github/workflows/R-CMD-check.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ jobs:
7070

7171
- uses: r-lib/actions/setup-r-dependencies@v2
7272
with:
73+
install-quarto: false
7374
extra-packages: |
7475
any::rcmdcheck
7576
needs: check

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
* `make_linter_from_xpath()` errors up front when `lint_message` is missing (instead of delaying this error until the linter is used, #2541, @MichaelChirico).
5959
* `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).
6060
* `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).
61+
* `lint()` and friends emit a message if no lints are found (#2643, @IndrajeetPatil).
6162

6263
### New linters
6364

R/methods.R

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,14 @@ print.lints <- function(x, ...) {
101101
if (isTRUE(settings$error_on_lint)) {
102102
quit("no", 31L, FALSE) # nocov
103103
}
104-
} else if (use_rstudio_source_markers) {
105-
# Empty lints: clear RStudio source markers
106-
rstudio_source_markers(x)
104+
} else {
105+
# Empty lints
106+
cli_inform(c(i = "No lints found."))
107+
if (use_rstudio_source_markers) {
108+
rstudio_source_markers(x) # clear RStudio source markers
109+
}
107110
}
111+
108112
invisible(x)
109113
}
110114

tests/testthat/test-methods.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ test_that("print.lint works", {
9696
expect_output(print(l), " 1:length(x)", fixed = TRUE)
9797
})
9898

99+
test_that("print.lint works with empty lints", {
100+
withr::local_options(list(lintr.rstudio_source_markers = FALSE))
101+
l <- lint(text = "1L")
102+
103+
expect_message(print(l), "No lints found", fixed = TRUE)
104+
})
105+
99106
test_that("print.lint works for inline data, even in RStudio", {
100107
l <- lint("x = 1\n")
101108

0 commit comments

Comments
 (0)