Skip to content

Commit e03707e

Browse files
add examples
1 parent fdc5460 commit e03707e

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

R/for_loop_index_linter.R

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,29 @@
33
#' `for (x in x)` is a poor choice of indexing variable. This overwrites
44
#' `x` in the calling scope and is confusing to read.
55
#'
6+
#' @examples
7+
#' # will produce lints
8+
#' lint(
9+
#' text = "for (x in x) { TRUE }",
10+
#' linters = for_loop_index_linter()
11+
#' )
12+
#'
13+
#' lint(
14+
#' text = "for (x in foo(x, y)) { TRUE }",
15+
#' linters = for_loop_index_linter()
16+
#' )
17+
#'
18+
#' # okay
19+
#' lint(
20+
#' text = "for (xi in x) { TRUE }",
21+
#' linters = for_loop_index_linter()
22+
#' )
23+
#'
24+
#' lint(
25+
#' text = "for (col in DF$col) { TRUE }",
26+
#' linters = for_loop_index_linter()
27+
#' )
28+
#'
629
#' @evalRd rd_tags("for_loop_index_linter")
730
#' @seealso [linters] for a complete list of linters available in lintr.
831
#' @export

man/for_loop_index_linter.Rd

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)