Skip to content

Commit 2a4941c

Browse files
further simplify
1 parent 44c9d79 commit 2a4941c

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

.ci/linters/rd/options_doc_check.R

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,21 @@ check_options_documentation = function(rd_file) {
33
if (!grepl("\\name{data.table-options}", rd_file, fixed = TRUE)) return(invisible())
44

55
# Find options in R code
6-
get_options_from_code = function() {
7-
found = character(0)
8-
9-
walk_for_dt_options = function(expr) {
10-
result = character(0)
11-
if (is.call(expr) && length(expr) >= 2 && identical(expr[[1]], quote(getOption)) && is.character(expr[[2]]) && startsWith(expr[[2]], "datatable.")) {
12-
result = expr[[2]]
13-
} else if (is.recursive(expr)) {
14-
result = c(result, unlist(lapply(expr, walk_for_dt_options)))
15-
}
16-
result
6+
walk_for_dt_options = function(expr) {
7+
result = character()
8+
if (is.call(expr) && length(expr) >= 2L && identical(expr[[1]], quote(getOption)) && is.character(e2 <- expr[[2L]]) && startsWith(e2, "datatable.")) {
9+
result = e2
10+
} else if (is.recursive(expr)) {
11+
result = c(result, unlist(lapply(expr, walk_for_dt_options)))
1712
}
18-
r_files = list.files("R", pattern = "\\.R$", full.names = TRUE)
19-
for (file in r_files) {
20-
found = c(found, unlist(lapply(parse(file = file), walk_for_dt_options)))
21-
}
22-
sort(unique(found))
13+
result
14+
}
15+
get_options_from_code = function() {
16+
list.files("R", pattern = "\\.R$", full.names = TRUE) |>
17+
lapply(\(f) lapply(parse(f), walk_for_dt_options)) |>
18+
unlist() |>
19+
unique() |>
20+
sort()
2321
}
2422

2523
# Find options in documentation

0 commit comments

Comments
 (0)