Check that the recommended pipe operator is used, or more conservatively that pipes are consistent by file.
Usage
pipe_consistency_linter(pipe = c("|>", "%>%", "auto"))
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_consistency_linter()
)
#> <text>:1:15: style: [pipe_consistency_linter] Use the |> pipe operator instead of the %>% pipe operator.
#> 1:3 |> mean() %>% as.character()
#> ^~~
lint(
text = "1:3 %>% mean() %>% as.character()",
linters = pipe_consistency_linter("|>")
)
#> <text>:1:5: style: [pipe_consistency_linter] Use the |> pipe operator instead of the %>% pipe operator.
#> 1:3 %>% mean() %>% as.character()
#> ^~~
#> <text>:1:16: style: [pipe_consistency_linter] Use the |> pipe operator instead of the %>% pipe operator.
#> 1:3 %>% mean() %>% as.character()
#> ^~~
# okay
lint(
text = "1:3 |> mean() |> as.character()",
linters = pipe_consistency_linter()
)
#> ℹ No lints found.
lint(
text = "1:3 %>% mean() %>% as.character()",
linters = pipe_consistency_linter("%>%")
)
#> ℹ No lints found.