View source: R/nested_pipe_linter.R
nested_pipe_linter | R Documentation |
Nesting pipes harms readability; extract sub-steps to separate variables, append further pipeline steps, or otherwise refactor such usage away.
nested_pipe_linter(
allow_inline = TRUE,
allow_outer_calls = c("try", "tryCatch", "withCallingHandlers")
)
allow_inline |
Logical, default |
allow_outer_calls |
Character vector dictating which "outer"
calls to exempt from the requirement to unnest (see examples). Defaults
to |
configurable, consistency, readability
linters for a complete list of linters available in lintr.
# will produce lints
code <- "df1 %>%\n inner_join(df2 %>%\n select(a, b)\n )"
writeLines(code)
lint(
text = code,
linters = nested_pipe_linter()
)
lint(
text = "df1 %>% inner_join(df2 %>% select(a, b))",
linters = nested_pipe_linter(allow_inline = FALSE)
)
lint(
text = "tryCatch(x %>% filter(grp == 'a'), error = identity)",
linters = nested_pipe_linter(allow_outer_calls = character())
)
# okay
lint(
text = "df1 %>% inner_join(df2 %>% select(a, b))",
linters = nested_pipe_linter()
)
code <- "df1 %>%\n inner_join(df2 %>%\n select(a, b)\n )"
writeLines(code)
lint(
text = code,
linters = nested_pipe_linter(allow_outer_calls = "inner_join")
)
lint(
text = "tryCatch(x %>% filter(grp == 'a'), error = identity)",
linters = nested_pipe_linter()
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.