Skip to content

Commit

Permalink
Also warn for positionally-passed allow_cascadign_assign
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico authored Feb 3, 2025
1 parent 9e216c9 commit caf576c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/assignment_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ assignment_linter <- function(operator = c("<-", "<<-"),
allow_right_assign = FALSE,
allow_trailing = TRUE,
allow_pipe_assign = FALSE) {
if (!missing(allow_cascading_assign)) {
if (!missing(allow_cascading_assign) || is.logical(operator)) {
lintr_deprecated("allow_cascading_assign", '"<<-" and/or "->>" in operator', version = "3.2.0", type = "Argument")
operator <- drop_or_add(operator, "<<-", allow_cascading_assign)
}
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-assignment_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ test_that("Deprecated arguments work & warn as intended", {
expect_warning(regexp = "allow_cascading_assign", {
linter_no_cascade <- assignment_linter(allow_cascading_assign = FALSE)
})
# Also throw a deprecation warning for positionally-passed argument since we changed argument order.
expect_warning(assignment_linter(FALSE), "allow_cascading_assign")
expect_warning(regexp = "allow_right_assign", {
linter_yes_right <- assignment_linter(allow_right_assign = TRUE)
})
Expand Down

0 comments on commit caf576c

Please sign in to comment.