Force explicit calls in magrittr pipes, e.g., 1:3 %>% sum()
instead of 1:3 %>% sum
.
Note that native pipe always requires a function call, i.e. 1:3 |> sum
will produce an error.
See also
linters for a complete list of linters available in lintr.
Examples
# will produce lints
lint(
text = "1:3 %>% mean %>% as.character",
linters = pipe_call_linter()
)
#> <text>:1:9: warning: [pipe_call_linter] Use explicit calls in magrittr pipes, i.e., `a %>% foo` should be `a %>% foo()`.
#> 1:3 %>% mean %>% as.character
#> ^~~~
#> <text>:1:18: warning: [pipe_call_linter] Use explicit calls in magrittr pipes, i.e., `a %>% foo` should be `a %>% foo()`.
#> 1:3 %>% mean %>% as.character
#> ^~~~~~~~~~~~
# okay
lint(
text = "1:3 %>% mean() %>% as.character()",
linters = pipe_call_linter()
)
#> ℹ No lints found.