Skip to content

Commit 77f0dae

Browse files
authored
Report a helpful error if linters_with_tags() specifies no tags. (#2942)
1 parent 8ecf0c5 commit 77f0dae

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

R/with.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ modify_defaults <- function(defaults, ...) {
9292
#' }
9393
#' @export
9494
linters_with_tags <- function(tags, ..., packages = "lintr", exclude_tags = "deprecated") {
95+
if (missing(tags)) {
96+
cli_abort("{.arg tags} was not specified. Available tags: {available_tags()}")
97+
}
9598
if (!is.character(tags) && !is.null(tags)) {
9699
cli_abort("{.arg tags} must be a character vector, or {.code NULL}, not {.obj_type_friendly {tags}}.")
97100
}

tests/testthat/test-linter_tags.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ test_that("default_linters and default tag match up", {
4141
test_that("warnings occur only for deprecated linters", {
4242
skip_if_not_installed("cyclocomp") # actually we expect a warning there
4343

44+
expect_error(linters_with_tags(), "`tags` was not specified. Available tags:")
4445
expect_silent(linters_with_tags(tags = NULL))
4546
num_deprecated_linters <- nrow(available_linters(tags = "deprecated", exclude_tags = NULL))
4647
outer_env <- new.env(parent = emptyenv())

0 commit comments

Comments
 (0)