Skip to content

False positive in object_usage_linter() for infix operators in glue strings #2069

Description

@MichaelChirico
lint(linters = object_usage_linter(), "
foo <- function() {
  `%++%` <- `+`
  glue('{x %++% y}')
}")
# <text>:3:3: warning: [object_usage_linter] local variable '%++%' assigned but may not be used
#   `%++%` <- `+`
#   ^~~~~~

The problem is we only look for SYMBOL or SYMBOL_FUNCTION_CALL in the parse tree of the glue expression:

symbols <- gsub("^`(.*)`$", "\\1", parse_data$text[parse_data$token %in% c("SYMBOL", "SYMBOL_FUNCTION_CALL")])

#2068 already fixed this by using all.vars() instead.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions