Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework ?pipe_return_linter to avoid roxygen issue #2817

Merged
merged 1 commit into from
Mar 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions R/pipe_return_linter.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
#' Block usage of return() in magrittr pipelines
#'
#' [return()] inside a magrittr pipeline does not actually execute `return()`
#' like you'd expect: `\(x) { x %>% return(); FALSE }` will return `FALSE`!
#' It will technically work "as expected" if this is the final statement
#' in the function body, but such usage is misleading. Instead, assign
#' the pipe outcome to a variable and return that.
#' like you'd expect:
#'
#' ```r
#' bad_usage <- function(x) {
#' x %>%
#' return()
#' FALSE
#' }
#' ```
#'
#' `bad_usage(TRUE)` will return `FALSE`! It will technically work "as expected"
#' if this is the final statement in the function body, but such usage is misleading.
#' Instead, assign the pipe outcome to a variable and return that.
#'
#' @examples
#' # will produce lints
Expand Down
17 changes: 13 additions & 4 deletions man/pipe_return_linter.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading