Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

## Bug fixes

* `linters_with_tags()` now includes the previously missing spaces around "and" when listing missing linters advertised by `available_linters()`.
This error message may appear e.g. when you update lintr to a version with new linters but don't restart your R session (#1946, @Bisaloo)

* `fixed_regex_linter()` is more robust to errors stemming from unrecognized escapes (#1545, #1845, @IndrajeetPatil).

* `get_source_expressions()` can handle Sweave/Rmarkdown documents with reference chunks like `<<ref_file>>` (#779, @MichaelChirico).
Expand Down
2 changes: 1 addition & 1 deletion R/with.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ linters_with_tags <- function(tags, ..., packages = "lintr", exclude_tags = "dep
if (!all(available$linter %in% ns_exports)) {
missing_linters <- setdiff(available$linter, ns_exports)
stop(
"Linters ", glue::glue_collapse(sQuote(missing_linters), sep = ", ", last = "and"),
"Linters ", glue::glue_collapse(sQuote(missing_linters), sep = ", ", last = " and "),
" advertised by `available_linters()` but not exported by package ", package, "."
)
}
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/test-with.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ test_that("linters_with_defaults warns on unused NULLs", {
)
})

test_that("linters_with_tags() verifies the output of available_linters()", {
skip_if_not_installed("mockery")
mockery::stub(
linters_with_tags,
"available_linters",
data.frame(linter = c("fake_linter", "very_fake_linter"), package = "lintr", tags = "", stringsAsFactors = FALSE)
)
expect_error(
linters_with_tags(NULL),
"'fake_linter' and 'very_fake_linter'"
)
})

test_that("all default linters are tagged default", {
expect_named(linters_with_defaults(), available_linters(tags = "default")$linter)

Expand Down