Learn R Programming

lintr (version 3.1.2)

pipe_consistency_linter: Pipe consistency linter

Description

Check that pipe operators are used consistently by file, or optionally specify one valid pipe operator.

Usage

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

Arguments

pipe

Which pipe operator is valid (either "%>%" or "|>"). By default ("auto"), the linter has no preference but will check that each file uses only one type of pipe operator.

Tags

configurable, readability, style

See Also

linters for a complete list of linters available in lintr.

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