From f611a13c642c89de2aec709f74fe1823d5348f5c Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Thu, 27 Nov 2025 11:15:59 -0500 Subject: [PATCH 1/4] Progress deprecations of function arguments --- NEWS.md | 5 +++- R/assignment_linter.R | 33 +---------------------- R/object_usage_linter.R | 12 ++------- man/assignment_linter.Rd | 7 +---- man/object_usage_linter.Rd | 4 +-- tests/testthat/test-assignment_linter.R | 6 ----- tests/testthat/test-object_usage_linter.R | 23 ++++------------ 7 files changed, 14 insertions(+), 76 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8cf3fb344..e118e8de8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,9 @@ # lintr (development version) -Nothing yet :) +## Deprecations & breaking changes + +* Arguments `allow_cascading_assign=`, `allow_right_assign=`, and `allow_pipe_assign=` to `assignment_linter()` are now removed. +* Argument `interpret_glue` to `object_usage_linter()`, marked deprecated in the previous release, is now defunct. # lintr (3.3.0-1) diff --git a/R/assignment_linter.R b/R/assignment_linter.R index 73b4e674e..d369720bd 100644 --- a/R/assignment_linter.R +++ b/R/assignment_linter.R @@ -5,7 +5,6 @@ #' @param operator Character vector of valid assignment operators. Defaults to allowing `<-` and `<<-`; other valid #' options are `=`, `->`, `->>`, `%<>%`; use `"any"` to denote "allow all operators", in which case this linter only #' considers `allow_trailing` for generating lints. -#' @param allow_cascading_assign,allow_right_assign,allow_pipe_assign (Defunct) #' @param allow_trailing Logical, default `TRUE`. If `FALSE` then assignments aren't allowed at end of lines. #' #' @examples @@ -81,37 +80,7 @@ #' - #' @export assignment_linter <- function(operator = c("<-", "<<-"), - allow_cascading_assign = NULL, - allow_right_assign = NULL, - allow_trailing = TRUE, - allow_pipe_assign = NULL) { - if (!missing(allow_cascading_assign)) { - lintr_deprecated( - "allow_cascading_assign", - '"<<-" and/or "->>" in operator', - version = "3.2.0", - type = "Argument", - signal = "stop" - ) - } - if (!missing(allow_right_assign)) { - lintr_deprecated( - "allow_right_assign", - '"->" in operator', - version = "3.2.0", - type = "Argument", - signal = "stop" - ) - } - if (!missing(allow_pipe_assign)) { - lintr_deprecated( - "allow_pipe_assign", - '"%<>%" in operator', - version = "3.2.0", - type = "Argument", - signal = "stop" - ) - } + allow_trailing = TRUE) { all_operators <- c("<-", "=", "->", "<<-", "->>", "%<>%") if ("any" %in% operator) { operator <- all_operators diff --git a/R/object_usage_linter.R b/R/object_usage_linter.R index cb533b422..d0b179540 100644 --- a/R/object_usage_linter.R +++ b/R/object_usage_linter.R @@ -3,9 +3,7 @@ #' Check that closures have the proper usage using [codetools::checkUsage()]. #' Note that this runs [base::eval()] on the code, so **do not use with untrusted code**. #' -#' @param interpret_glue (Deprecated) If `TRUE`, interpret [glue::glue()] calls to avoid -#' false positives caused by local variables which are only used in a glue expression. -#' Provide `interpret_extensions` instead, see below. +#' @param interpret_glue (Defunct) #' @param interpret_extensions Character vector of extensions to interpret. These are meant to cover known cases where #' variables may be used in ways understood by the reader but not by `checkUsage()` to avoid false positives. #' Currently `"glue"` and `"rlang"` are supported, both of which are in the default. @@ -42,14 +40,8 @@ object_usage_linter <- function(interpret_glue = NULL, interpret_extensions = c( '"glue" in interpret_extensions', version = "3.3.0", type = "Argument", - signal = "warning" + signal = "stop" ) - - if (interpret_glue) { - interpret_extensions <- union(interpret_extensions, "glue") - } else { - interpret_extensions <- setdiff(interpret_extensions, "glue") - } } if (length(interpret_extensions) > 0L) { diff --git a/man/assignment_linter.Rd b/man/assignment_linter.Rd index 808ea4974..68dd59ce8 100644 --- a/man/assignment_linter.Rd +++ b/man/assignment_linter.Rd @@ -6,10 +6,7 @@ \usage{ assignment_linter( operator = c("<-", "<<-"), - allow_cascading_assign = NULL, - allow_right_assign = NULL, - allow_trailing = TRUE, - allow_pipe_assign = NULL + allow_trailing = TRUE ) } \arguments{ @@ -17,8 +14,6 @@ assignment_linter( options are \code{=}, \verb{->}, \verb{->>}, \verb{\%<>\%}; use \code{"any"} to denote "allow all operators", in which case this linter only considers \code{allow_trailing} for generating lints.} -\item{allow_cascading_assign, allow_right_assign, allow_pipe_assign}{(Defunct)} - \item{allow_trailing}{Logical, default \code{TRUE}. If \code{FALSE} then assignments aren't allowed at end of lines.} } \description{ diff --git a/man/object_usage_linter.Rd b/man/object_usage_linter.Rd index e22e4508c..1dba94aa8 100644 --- a/man/object_usage_linter.Rd +++ b/man/object_usage_linter.Rd @@ -11,9 +11,7 @@ object_usage_linter( ) } \arguments{ -\item{interpret_glue}{(Deprecated) If \code{TRUE}, interpret \code{\link[glue:glue]{glue::glue()}} calls to avoid -false positives caused by local variables which are only used in a glue expression. -Provide \code{interpret_extensions} instead, see below.} +\item{interpret_glue}{(Defunct)} \item{interpret_extensions}{Character vector of extensions to interpret. These are meant to cover known cases where variables may be used in ways understood by the reader but not by \code{checkUsage()} to avoid false positives. diff --git a/tests/testthat/test-assignment_linter.R b/tests/testthat/test-assignment_linter.R index 5c8d685f4..ed6300514 100644 --- a/tests/testthat/test-assignment_linter.R +++ b/tests/testthat/test-assignment_linter.R @@ -375,12 +375,6 @@ test_that("multiple lints throw correct messages when = is required", { ) }) -test_that("Deprecated arguments error as intended", { - expect_error(regexp = "allow_cascading_assign", assignment_linter(allow_cascading_assign = FALSE)) - expect_error(regexp = "allow_right_assign", assignment_linter(allow_right_assign = TRUE)) - expect_error(regexp = "allow_pipe_assign", assignment_linter(allow_pipe_assign = TRUE)) -}) - test_that("implicit '<-' assignments inside calls are ignored where top-level '<-' is disallowed", { linter <- assignment_linter(operator = "=") diff --git a/tests/testthat/test-object_usage_linter.R b/tests/testthat/test-object_usage_linter.R index 4283e16d6..e95e5227a 100644 --- a/tests/testthat/test-object_usage_linter.R +++ b/tests/testthat/test-object_usage_linter.R @@ -905,26 +905,13 @@ test_that("dplyr's .env-specified objects are marked as 'used'", { ) }) -test_that("interpret_glue is deprecated", { - expect_warning( - { - linter_no <- object_usage_linter(interpret_glue = FALSE) - }, +test_that("interpret_glue is defunct", { + expect_error( + object_usage_linter(interpret_glue = FALSE), rex::rex("interpret_glue", anything, "deprecated") ) - expect_warning( - { - linter_yes <- object_usage_linter(interpret_glue = TRUE) - }, + expect_error( + object_usage_linter(interpret_glue = TRUE), rex::rex("interpret_glue", anything, "deprecated") ) - - code <- trim_some(" - fun <- function() { - local_var <- 42 - glue::glue('The answer is {local_var}.') - } - ") - expect_lint(code, "local_var", linter_no) - expect_no_lint(code, linter_yes) }) From b8f762e6f94d74fb8cdf7c70c56e7540168e040d Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Thu, 27 Nov 2025 11:21:07 -0500 Subject: [PATCH 2/4] match autoformatting of \usage --- man/assignment_linter.Rd | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/man/assignment_linter.Rd b/man/assignment_linter.Rd index 68dd59ce8..a3f741c12 100644 --- a/man/assignment_linter.Rd +++ b/man/assignment_linter.Rd @@ -4,10 +4,7 @@ \alias{assignment_linter} \title{Assignment linter} \usage{ -assignment_linter( - operator = c("<-", "<<-"), - allow_trailing = TRUE -) +assignment_linter(operator = c("<-", "<<-"), allow_trailing = TRUE)\ } \arguments{ \item{operator}{Character vector of valid assignment operators. Defaults to allowing \verb{<-} and \verb{<<-}; other valid From 6e9b31435083068a9d0227a1b8d08f934dacb18c Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Thu, 27 Nov 2025 11:26:08 -0500 Subject: [PATCH 3/4] yuck --- man/assignment_linter.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/assignment_linter.Rd b/man/assignment_linter.Rd index a3f741c12..10877da70 100644 --- a/man/assignment_linter.Rd +++ b/man/assignment_linter.Rd @@ -4,7 +4,7 @@ \alias{assignment_linter} \title{Assignment linter} \usage{ -assignment_linter(operator = c("<-", "<<-"), allow_trailing = TRUE)\ +assignment_linter(operator = c("<-", "<<-"), allow_trailing = TRUE) } \arguments{ \item{operator}{Character vector of valid assignment operators. Defaults to allowing \verb{<-} and \verb{<<-}; other valid From 47a1e0768fd78224e1d15e7ac9411bb623db4264 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Sun, 30 Nov 2025 01:19:00 -0500 Subject: [PATCH 4/4] blurb about workarounds --- NEWS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index ddc8c20f2..44c0bad85 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,8 +3,8 @@ ## Deprecations & breaking changes * Six linters fully deprecated in the previous release are now removed: `consecutive_stopifnot_linter()`, `extraction_operator_linter()`, `no_tab_linter()`, `single_quotes_linter()`, `unnecessary_nested_if_linter()`, and `unneeded_concatenation_linter()`. -* Arguments `allow_cascading_assign=`, `allow_right_assign=`, and `allow_pipe_assign=` to `assignment_linter()` are now removed. -* Argument `interpret_glue` to `object_usage_linter()`, marked deprecated in the previous release, is now defunct. +* Arguments `allow_cascading_assign=`, `allow_right_assign=`, and `allow_pipe_assign=` to `assignment_linter()` are now removed. Use `operator=` instead. +* Argument `interpret_glue` to `object_usage_linter()`, marked deprecated in the previous release, is now defunct. Use `interpret_extensions=` instead; see the 3.3.0-1 release notes and `?object_usage_linter` for more. # lintr (3.3.0-1)