Skip to content

Commit 6ca8e28

Browse files
rework to avoid roxygen issue
1 parent c315baf commit 6ca8e28

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

R/pipe_return_linter.R

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
#' Block usage of return() in magrittr pipelines
22
#'
33
#' [return()] inside a magrittr pipeline does not actually execute `return()`
4-
#' like you'd expect: `\(x) { x %>% return(); FALSE }` will return `FALSE`!
5-
#' It will technically work "as expected" if this is the final statement
6-
#' in the function body, but such usage is misleading. Instead, assign
7-
#' the pipe outcome to a variable and return that.
4+
#' like you'd expect:
5+
#'
6+
#' ```r
7+
#' bad_usage <- function(x) {
8+
#' x %>%
9+
#' return()
10+
#' FALSE
11+
#' }
12+
#' ```
13+
#'
14+
#' `bad_usage(TRUE)` will return `FALSE`! It will technically work "as expected"
15+
#' if this is the final statement in the function body, but such usage is misleading.
16+
#' Instead, assign the pipe outcome to a variable and return that.
817
#'
918
#' @examples
1019
#' # will produce lints

man/pipe_return_linter.Rd

+13-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)