Skip to content

Not all usage issues reported back to user #1714

@AshesITR

Description

@AshesITR
tst <- function() { a <- ...; a; b }
codetools::checkUsage(tst)
#> <anonymous>: ... may be used in an incorrect context (<text>:1)
#> <anonymous>: no visible binding for global variable 'b' (<text>:1)

Created on 2022-10-16 by the reprex package (v2.0.1)

Lintr only reports one of the problems:

lintr::lint(text = "tst <- function() { a <- ...; a; b }", linters = lintr::object_usage_linter())
#> <text>:1:34: warning: [object_usage_linter] no visible binding for global variable 'b'
#> tst <- function() { a <- ...; a; b }
#>                                  ^

Created on 2022-10-15 by the reprex package (v2.0.1)


Checking the code of R/codetools.R, all issues are collected using the format signalUsageIssue(message). The regex - if I read it correctly - implicitly assumes there always is an sQuote(...) in the message.

This is not the case for the following messages, scouring the source code:

w$signal("... may be used in an incorrect context", w) # l. 416
w$signal(paste(a, "may be used in an incorrect context:", pasteExpr(e)), w) # l. 436
w$signal(paste("wrong number of arguments to '.Internal':", pasteExpr(e)), w) # l. 676
w$signal(paste("bad argument to '.Internal':", pasteExpr(e[[2]])), w) # l. 682

Originally posted by @AshesITR in #1661 (review)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorfalse-negativecode that should lint, but doesn't

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions