pipe_consistency_linter: Pipe consistency linter

View source: R/pipe_consistency_linter.R

pipe_consistency_linterR Documentation

Pipe consistency linter

Description

Check that the recommended pipe operator is used, or more conservatively that pipes are consistent by file.

Usage

pipe_consistency_linter(pipe = c("|>", "%>%", "auto"))

Arguments

pipe

Which pipe operator is valid (either "%>%" or "|>"). The default is the native pipe (⁠|>⁠). "auto" will instead only enforce consistency, i.e., that in any given file there is only one pipe.

Tags

configurable, default, readability, style

See Also

Examples

# will produce lints
lint(
  text = "1:3 |> mean() %>% as.character()",
  linters = pipe_consistency_linter()
)

lint(
  text = "1:3 %>% mean() %>% as.character()",
  linters = pipe_consistency_linter("|>")
)

# okay
lint(
  text = "1:3 |> mean() |> as.character()",
  linters = pipe_consistency_linter()
)

lint(
  text = "1:3 %>% mean() %>% as.character()",
  linters = pipe_consistency_linter("%>%")
)

jimhester/lintr documentation built on June 14, 2025, 1:27 a.m.