Skip to content

Commit ddc1b71

Browse files
Add missing spaces around "and" in glue_collapse() (#1946)
* Add missing spaces around "and" in glue_collapse() * Add regression test * Add NEWS entries * Specify stringAsFactors value Co-authored-by: Michael Chirico <[email protected]> * Do not make claims about what is typical Co-authored-by: Michael Chirico <[email protected]> * Keep line under 120 characters --------- Co-authored-by: Michael Chirico <[email protected]>
1 parent 2997038 commit ddc1b71

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
## Bug fixes
99

10+
* `linters_with_tags()` now includes the previously missing spaces around "and" when listing missing linters advertised by `available_linters()`.
11+
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)
12+
1013
* `fixed_regex_linter()` is more robust to errors stemming from unrecognized escapes (#1545, #1845, @IndrajeetPatil).
1114

1215
* `get_source_expressions()` can handle Sweave/Rmarkdown documents with reference chunks like `<<ref_file>>` (#779, @MichaelChirico).

R/with.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ linters_with_tags <- function(tags, ..., packages = "lintr", exclude_tags = "dep
104104
if (!all(available$linter %in% ns_exports)) {
105105
missing_linters <- setdiff(available$linter, ns_exports)
106106
stop(
107-
"Linters ", glue::glue_collapse(sQuote(missing_linters), sep = ", ", last = "and"),
107+
"Linters ", glue::glue_collapse(sQuote(missing_linters), sep = ", ", last = " and "),
108108
" advertised by `available_linters()` but not exported by package ", package, "."
109109
)
110110
}

tests/testthat/test-with.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ test_that("linters_with_defaults warns on unused NULLs", {
2121
)
2222
})
2323

24+
test_that("linters_with_tags() verifies the output of available_linters()", {
25+
skip_if_not_installed("mockery")
26+
mockery::stub(
27+
linters_with_tags,
28+
"available_linters",
29+
data.frame(linter = c("fake_linter", "very_fake_linter"), package = "lintr", tags = "", stringsAsFactors = FALSE)
30+
)
31+
expect_error(
32+
linters_with_tags(NULL),
33+
"'fake_linter' and 'very_fake_linter'"
34+
)
35+
})
36+
2437
test_that("all default linters are tagged default", {
2538
expect_named(linters_with_defaults(), available_linters(tags = "default")$linter)
2639

0 commit comments

Comments
 (0)