nested_pipe
What it does
Reports pipes (%>% or |>) that are nested inside another function call, e.g. print(x %>% foo()).
Why is this bad?
Nesting a pipe inside another call hides the data flow and makes the code harder to read. Extracting the pipe into its own statement keeps each step on its own line.
try(), tryCatch(), and withCallingHandlers() are automatically skipped. The list of skipped functions can be customized with rule-specific arguments in jarl.toml.
Configuration options
The operation of the nested_pipe rule can be customised in the configuration file.
Use skipped-functions to fully replace the default list of outer calls whose nested pipes are allowed. Use extend-skipped-functions to add to the default list. Specifying both is an error.
Default values
skipped-functions = [
"try",
"tryCatch",
"withCallingHandlers"
]TOML settings
[lint]
...
[lint.nested_pipe]
# also allow in stopifnot()
extend-skipped-fuctions = ["stopifnot"]Example
print(x %>% foo() %>% bar())Use instead:
out <- x %>%
foo() %>%
bar()
print(out)