Learn R Programming

lintr (version 3.3.0-1)

pipe_consistency_linter: 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

Run this code
# 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("%>%")
)

Run the code above in your browser using DataLab