Skip to content

Commit

Permalink
assume glue is glue::glue
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico committed Aug 2, 2023
1 parent f9bf506 commit 0f6d69e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
## Changes to defaults

* `assignment_linter()` lints the {magrittr} assignment pipe `%<>%` (#2008, @MichaelChirico). This can be deactivated by setting the new argument `allow_pipe_assign` to `TRUE`.
* `object_usage_linter()` assumes `glue()` is `glue::glue()` when `interpret_glue=TRUE` (#2032, @MichaelChirico).

# lintr 3.1.0

Expand Down
1 change: 0 additions & 1 deletion R/object_usage_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ extract_glued_symbols <- function(expr) {
expr,
xpath = paste0(
"descendant::SYMBOL_FUNCTION_CALL[text() = 'glue']/", # a glue() call
"preceding-sibling::NS_GET/preceding-sibling::SYMBOL_PACKAGE[text() = 'glue']/", # qualified with glue::
"parent::expr[",
# without .envir or .transform arguments
"not(following-sibling::SYMBOL_SUB[text() = '.envir' or text() = '.transform']) and",
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-object_usage_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,14 @@ test_that("interprets glue expressions", {
}
"), NULL, linter)

# no need for namespace-qualification
expect_lint(trim_some("
fun <- function() {
local_var <- 42
glue('The answer is {local_var}.')
}
"), NULL, linter)

# multiple variables in different interpolations
expect_lint(trim_some("
fun <- function() {
Expand Down

0 comments on commit 0f6d69e

Please sign in to comment.