Skip to content

Commit 035ebcc

Browse files
authored
Merge branch 'master' into hindi_s
2 parents f7148b4 + 6f225f3 commit 035ebcc

File tree

121 files changed

+9698
-2195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+9698
-2195
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
^\.github$
2020
^\.vscode$
2121
^\.zed$
22+
^\.lintr$
2223

2324
^\.gitlab-ci\.yml$
2425

.ci/.lintr.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ linters = c(dt_linters, all_linters(
2121
message = "Use messagef to avoid fragmented translations.",
2222
warning = "Use warningf to avoid fragmented translations.",
2323
stop = "Use stopf to avoid fragmented translations.",
24+
rev = "Use frev internally, or setfrev if by-reference is safe.",
2425
NULL
2526
)),
2627
# undesirable_function_linter(modify_defaults(

.ci/atime/tests.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,5 +277,14 @@ test.list <- atime::atime_test_list(
277277
Slow = "73d79edf8ff8c55163e90631072192301056e336", # Parent of the first commit in the PR (https://github.com/Rdatatable/data.table/commit/8397dc3c993b61a07a81c786ca68c22bc589befc)
278278
Fast = "8397dc3c993b61a07a81c786ca68c22bc589befc"), # Commit in the PR (https://github.com/Rdatatable/data.table/pull/7019/commits) that removes inefficiency
279279

280+
"isoweek improved in #7144" = atime::atime_test(
281+
setup = {
282+
set.seed(349)
283+
x = sample(Sys.Date() - 0:5000, N, replace=TRUE)
284+
},
285+
expr = data.table::isoweek(x),
286+
Slow = "548410d23dd74b625e8ea9aeb1a5d2e9dddd2927", # Parent of the first commit in the PR (https://github.com/Rdatatable/data.table/commit/548410d23dd74b625e8ea9aeb1a5d2e9dddd2927)
287+
Fast = "c0b32a60466bed0e63420ec105bc75c34590865e"), # Commit in the PR (https://github.com/Rdatatable/data.table/pull/7144/commits) that uses a much faster implementation
288+
280289
tests=extra.test.list)
281290
# nolint end: undesirable_operator_linter.

.ci/linters/md/news_linter.R renamed to .ci/linters/md/news_github_link_mismatch_linter.R

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,6 @@
1-
# ensure that numbered list in each section is in sequence
2-
check_section_numbering = function(news) {
3-
if (!grepl("NEWS", news)) return(invisible())
4-
news = readLines(news)
5-
# plain '#' catches some examples; 'd' for 'data.table'
6-
sections = grep("^#+ [A-Zd]", news)
7-
entries = grep("^[0-9]+[.]", news)
8-
entry_value = as.integer(gsub("^([0-9]+)[.].*", "\\1", news[entries]))
9-
section_id = findInterval(entries, sections)
10-
11-
any_mismatch = FALSE
12-
for (id in unique(section_id)) {
13-
section_entries = entry_value[section_id == id]
14-
intended_value = seq_along(section_entries)
15-
matched = section_entries == intended_value
16-
if (all(matched)) next
17-
any_mismatch = TRUE
18-
section_header = news[sections[id]]
19-
cat(sprintf(
20-
"In section '%s' (line %d), bad numbering:\n%s\n",
21-
section_header, sections[id],
22-
paste0(" [", section_entries[!matched], " --> ", intended_value[!matched], "]", collapse="\n")
23-
))
24-
}
25-
stopifnot("Please fix the NEWS issues above" = !any_mismatch)
26-
}
27-
281
# ensure that GitHub link text & URL actually agree
29-
check_gh_links = function(news) {
2+
news_github_link_mismatch_linter = function(news) {
3+
if (!grepl("NEWS", news)) return(invisible())
304
news = readLines(news)
315
gh_links_info = gregexpr(
326
"\\[#(?<md_number>[0-9]+)\\]\\(https://github.com/Rdatatable/data.table/(?<link_type>[^/]+)/(?<link_number>[0-9]+)\\)",
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# ensure that numbered list in each section is in sequence
2+
news_section_numbering_linter = function(news) {
3+
if (!grepl("NEWS", news)) return(invisible())
4+
news = readLines(news)
5+
# plain '#' catches some examples; 'd' for 'data.table'
6+
sections = grep("^#+ [A-Zd]", news)
7+
entries = grep("^[0-9]+[.]", news)
8+
entry_value = as.integer(gsub("^([0-9]+)[.].*", "\\1", news[entries]))
9+
section_id = findInterval(entries, sections)
10+
11+
any_mismatch = FALSE
12+
for (id in unique(section_id)) {
13+
section_entries = entry_value[section_id == id]
14+
intended_value = seq_along(section_entries)
15+
matched = section_entries == intended_value
16+
if (all(matched)) next
17+
any_mismatch = TRUE
18+
section_header = news[sections[id]]
19+
cat(sprintf(
20+
"In section '%s' (line %d), bad numbering:\n%s\n",
21+
section_header, sections[id],
22+
paste0(" [", section_entries[!matched], " --> ", intended_value[!matched], "]", collapse="\n")
23+
))
24+
}
25+
stopifnot("Please fix the NEWS issues above" = !any_mismatch)
26+
}

.ci/linters/md/heading_id_linter.R renamed to .ci/linters/md/vignette_heading_id_linter.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ensure that ids are limited to alphanumerics and dashes
22
# (in particular, dots and underscores break the links)
3-
check_header_ids = function(md) {
3+
vignette_heading_id_linter = function(md) {
44
if (!grepl('[.]Rmd$', md)) return(invisible())
55
md = readLines(md)
66
# A bit surprisingly, some headings don't start with a letter.

.ci/linters/r/eval_parse_linter.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
eval_parse_linter = make_linter_from_xpath(
2+
"//SYMBOL_FUNCTION_CALL[text() = 'parse']
3+
/ancestor::expr
4+
/preceding-sibling::expr[SYMBOL_FUNCTION_CALL[text() = 'eval']]
5+
/parent::expr
6+
",
7+
"Avoid eval(parse()); build the language directly, possibly using substitute2()."
8+
)

.ci/linters/rd/backtick_linter.R

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# ensure no markdown-style backticks wind up in Rd where \code is intended
2+
options_documentation_linter = function(rd_file) {
3+
rd = tools::parse_Rd(rd_file)
4+
5+
error_if_backtick = function(rd_obj) {
6+
if (!is.recursive(rd_obj)) {
7+
if (any(grepl("`", rd_obj, fixed=TRUE))) {
8+
stop(sprintf(
9+
"Rd is not markdown -- backticks (`) don't render as code! Use \\code{...}.\nObserved in string '%s' in file %s",
10+
trimws(rd_obj), rd_file
11+
))
12+
}
13+
return(invisible())
14+
}
15+
tags = vapply(rd_obj, \(x) attr(x, "Rd_tag") %||% "", FUN.VALUE="")
16+
# backtick is valid inside R code (e.g. \examples, \code, \preformatted)
17+
rd_obj = rd_obj[!tags %in% c("RCODE", "VERB")]
18+
lapply(rd_obj, error_if_backtick)
19+
}
20+
21+
invisible(error_if_backtick(rd))
22+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Ensure that data.table condition classes in code match documentation
2+
condition_classes_documentation_linter = function(rd_file) {
3+
if (!grepl("\\name{data.table-condition-classes}", readChar(rd_file, 100L), fixed = TRUE)) return(invisible())
4+
5+
# Find condition classes in R code
6+
walk_r_ast_for_classes = function(expr) {
7+
if (is.call(expr) && is.name(e <- expr[[1L]]) && as.character(e) %in% c("stopf", "warningf", "messagef", "packageStartupMessagef") && is.character(class_arg <- expr[["class"]]) && startsWith(class_arg, "dt_")) {
8+
class_arg
9+
} else if (is.recursive(expr)) {
10+
unlist(lapply(expr, walk_r_ast_for_classes))
11+
}
12+
}
13+
14+
# Find condition classes in documentation
15+
walk_rd_ast_for_classes = function(rd_element) {
16+
if (!is.list(rd_element)) return(character())
17+
18+
result = character()
19+
if (isTRUE(attr(rd_element, "Rd_tag") == "\\code") && length(rd_element) >= 1L) {
20+
content = rd_element[[1L]]
21+
if (is.character(content) && startsWith(content, "dt_")) {
22+
result = content
23+
}
24+
}
25+
c(result, unlist(lapply(rd_element, walk_rd_ast_for_classes)))
26+
}
27+
28+
code_classes = list.files("R", pattern = "\\.R$", full.names = TRUE) |>
29+
lapply(\(f) lapply(parse(f), walk_r_ast_for_classes)) |>
30+
unlist() |>
31+
unique()
32+
33+
doc_classes = rd_file |>
34+
tools::parse_Rd() |>
35+
walk_rd_ast_for_classes() |>
36+
unique()
37+
38+
miss_in_doc = setdiff(code_classes, doc_classes)
39+
miss_in_code = setdiff(doc_classes, code_classes)
40+
41+
if (length(miss_in_doc) > 0L || length(miss_in_code) > 0L) {
42+
if (length(miss_in_doc) > 0L) {
43+
cat(sprintf("Condition classes in code but missing from docs: %s\n", toString(miss_in_doc)))
44+
}
45+
if (length(miss_in_code) > 0L) {
46+
cat(sprintf("Condition classes in docs but not in code: %s\n", toString(miss_in_code)))
47+
}
48+
stop("Please sync man/datatable-condition-classes.Rd with code condition classes")
49+
}
50+
}
51+
File renamed without changes.

0 commit comments

Comments
 (0)