Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
33 changes: 1 addition & 32 deletions R/assignment_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -81,37 +80,7 @@
#' - <https://style.tidyverse.org/pipes.html#assignment-2>
#' @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
Expand Down
12 changes: 2 additions & 10 deletions R/object_usage_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 1 addition & 9 deletions man/assignment_linter.Rd

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

4 changes: 1 addition & 3 deletions man/object_usage_linter.Rd

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

6 changes: 0 additions & 6 deletions tests/testthat/test-assignment_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "=")

Expand Down
23 changes: 5 additions & 18 deletions tests/testthat/test-object_usage_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Loading