Example
# without assignment: no lint
lintr::lint(text = "function() x",
linters = lintr::object_usage_linter())
# with assignment: lint
lintr::lint(text = "myfun <- function() x",
linters = lintr::object_usage_linter())
#> <text>:1:21: warning: [object_usage_linter] no visible binding for global variable 'x'
#> myfun <- function() x
#> ^
In cases like lapply
where I often use an anonymous function, lintr does not check those functions.
lintr::lint(text = "lapply(1:3, FUN = function() x)",
linters = lintr::object_usage_linter())
Can I enable lintr to check those cases, as well? And out of curiosity: What is the reasoning behind that behaviour?