Skip to content

Commit

Permalink
missing_argument_linter() allows missing arguments in quote() cal…
Browse files Browse the repository at this point in the history
…ls (#1890)

Closes #1889
  • Loading branch information
IndrajeetPatil authored Jan 5, 2023
1 parent 6d892a3 commit bb4d43d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@

* `all_linters()` function provides an easy way to access all available linters (#1843, @IndrajeetPatil)

* `missing_argument_linter()` allows missing arguments in `quote()` calls (#1889, @IndrajeetPatil).

### New linters

* `unnecessary_lambda_linter()`: detect unnecessary lambdas (anonymous functions), e.g.
Expand Down
2 changes: 1 addition & 1 deletion R/missing_argument_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#' @evalRd rd_tags("missing_argument_linter")
#' @seealso [linters] for a complete list of linters available in lintr.
#' @export
missing_argument_linter <- function(except = c("switch", "alist"), allow_trailing = FALSE) {
missing_argument_linter <- function(except = c("alist", "quote", "switch"), allow_trailing = FALSE) {
conds <- c(
"self::OP-COMMA[preceding-sibling::*[not(self::COMMENT)][1][self::OP-LEFT-PAREN or self::OP-COMMA]]",
"self::EQ_SUB[following-sibling::*[not(self::COMMENT)][1][self::OP-RIGHT-PAREN or self::OP-COMMA]]"
Expand Down
5 changes: 4 additions & 1 deletion man/missing_argument_linter.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/testthat/test-missing_argument_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test_that("missing_argument_linter skips allowed usages", {
expect_lint("array[, , 1]", NULL, linter)
expect_lint("switch(a =, b =, c = 1, 0)", NULL, linter)
expect_lint("alist(a =, b =, c = 1, 0)", NULL, linter)
expect_lint("pairlist(path = quote(expr = ))", NULL, linter) #1889

expect_lint("test(a =, b =, c = 1, 0)", NULL, missing_argument_linter("test"))
})
Expand Down

0 comments on commit bb4d43d

Please sign in to comment.