Here, note that NSE is used in both the formula and the data= argument, and it's throwing off the line number detection:
lintr::lint("
foo <- function(x) {
lm(
y ~ z,
data = x[!is.na(y)]
)
}
", lintr::object_usage_linter())
# <text>:4:5: warning: [object_usage_linter] no visible binding for global variable 'y'
# y ~ z,
# ^
This makes it look like codetools is confused by the LHS of the formula, but actually what's being marked is the data= argument on the next line.
codetools itself only provides a range:
codetools::checkUsage(foo)
# <anonymous>: no visible binding for global variable ‘y’ (:2-5)