lintr::lint("a <- function() {\n 1:10 %>% sum()\n}", lintr::object_usage_linter())
# <text>:1:6: warning: [object_usage_linter] no visible global function definition for ‘%>%’. Disable this with a comment: `# nolint` (one line) or `# lintr: disable` (multiple lines). See go/tidy-style#linting for more.
# a <- function() {
# ^~~~~~~~~~~~
The linter anchors to the function definition, not to the usage of %>% itself. Similar goes for other infixes, e.g.
lintr::lint("a <- function() {\n 1:10 %>% sum()\n}", lintr::object_usage_linter())
# <text>:1:6: warning: [object_usage_linter] no visible global function definition for ‘:=’. Disable this with a comment: `# nolint` (one line) or `# lintr: disable` (multiple lines). See go/tidy-style#linting for more.
# a <- function(x) {
# ^~~~~~~~~~~~~
I guess this is codetools' fault, but is there something we can do to patch it up? Or maybe we have a bad XPath?
The linter anchors to the function definition, not to the usage of
%>%itself. Similar goes for other infixes, e.g.I guess this is
codetools' fault, but is there something we can do to patch it up? Or maybe we have a bad XPath?