diff --git a/NEWS.md b/NEWS.md index 5eddfba41..88abe25fe 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +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. 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. ## Notes 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 33ffec4ab..d4ac2f9ec 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..10877da70 100644 --- a/man/assignment_linter.Rd +++ b/man/assignment_linter.Rd @@ -4,21 +4,13 @@ \alias{assignment_linter} \title{Assignment linter} \usage{ -assignment_linter( - operator = c("<-", "<<-"), - allow_cascading_assign = NULL, - allow_right_assign = NULL, - allow_trailing = TRUE, - allow_pipe_assign = NULL -) +assignment_linter(operator = c("<-", "<<-"), allow_trailing = TRUE) } \arguments{ \item{operator}{Character vector of valid assignment operators. Defaults to allowing \verb{<-} and \verb{<<-}; other valid 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 df481b891..5a333dbce 100644 --- a/tests/testthat/test-object_usage_linter.R +++ b/tests/testthat/test-object_usage_linter.R @@ -903,26 +903,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) })