Skip to content

Commit 3c76f1a

Browse files
Merge branch 'master' into hindi_j
2 parents 766e852 + 5c895e4 commit 3c76f1a

Some content is hidden

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

90 files changed

+18828
-5240
lines changed

.ci/.lintr.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ linters = c(dt_linters, all_linters(
99
packages = "lintr", # TODO(lintr->3.2.0): Remove this.
1010
# eq_assignment_linter(),
1111
brace_linter(allow_single_line = TRUE),
12+
implicit_integer_linter(allow_colon = TRUE),
1213
# TODO(michaelchirico): Activate these incrementally. These are the
1314
# parameterizations that match our style guide.
1415
# implicit_assignment_linter(allow_lazy = TRUE, allow_scoped = TRUE),
15-
# implicit_integer_linter(allow_colon = TRUE),
1616
# system_time_linter = undesirable_function_linter(c(
1717
# system.time = "Only run timings in benchmark.Rraw"
1818
# )),
@@ -85,6 +85,7 @@ exclusions = c(local({
8585
undesirable_function_linter = Inf
8686
)),
8787
exclusion_for_dir(c("vignettes", "vignettes/fr"), list(
88+
implicit_integer_linter = Inf,
8889
quotes_linter = Inf,
8990
sample_int_linter = Inf
9091
# strings_as_factors_linter = Inf

.ci/atime/tests.R

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,20 @@ test.list <- atime::atime_test_list(
231231
},
232232
expr = data.table:::melt(DT, measure.vars = measure.vars),
233233
Slow = "fd24a3105953f7785ea7414678ed8e04524e6955", # Parent of the merge commit (https://github.com/Rdatatable/data.table/commit/ed72e398df76a0fcfd134a4ad92356690e4210ea) of the PR (https://github.com/Rdatatable/data.table/pull/5054) that fixes the issue
234-
Fast = "ed72e398df76a0fcfd134a4ad92356690e4210ea"), # Merge commit of the PR (https://github.com/Rdatatable/data.table/pull/5054) that fixes the issue
234+
Fast = "ed72e398df76a0fcfd134a4ad92356690e4210ea"), # Merge commit of the PR (https://github.com/Rdatatable/data.table/pull/5054) that fixes the issue # Test case created directly using the atime code below (not adapted from any other benchmark), based on the issue/fix PR https://github.com/Rdatatable/data.table/pull/5054#issue-930603663 "melt should be more efficient when there are missing input columns."
235+
236+
# Test case created from @tdhock's comment https://github.com/Rdatatable/data.table/pull/6393#issuecomment-2327396833, in turn adapted from @philippechataignon's comment https://github.com/Rdatatable/data.table/pull/6393#issuecomment-2326714012
237+
"fwrite refactored in #6393" = atime::atime_test(
238+
setup = {
239+
set.seed(1)
240+
NC = 10L
241+
L <- data.table(i=1:N)
242+
L[, paste0("V", 1:NC) := replicate(NC, rnorm(N), simplify=FALSE)]
243+
out.csv <- tempfile()
244+
},
245+
expr = data.table::fwrite(L, out.csv, compress="gzip"),
246+
Before = "f339aa64c426a9cd7cf2fcb13d91fc4ed353cd31", # Parent of the first commit https://github.com/Rdatatable/data.table/commit/fcc10d73a20837d0f1ad3278ee9168473afa5ff1 in the PR https://github.com/Rdatatable/data.table/pull/6393/commits with major change to fwrite with gzip.
247+
PR = "3630413ae493a5a61b06c50e80d166924d2ef89a"), # Close-to-last merge commit in the PR.
235248

236249
tests=extra.test.list)
237250
# nolint end: undesirable_operator_linter.

.ci/linters/c/alloc_linter.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
# 2. Check the next line for a check like 'if (!x || !y)'
55
alloc_linter = function(c_obj) {
66
lines = c_obj$lines
7-
# Be a bit more precise to avoid mentions in comments
8-
alloc_lines = grep(R"{=\s*([(]\w+\s*[*][)])?[mc]alloc[(]}", lines)
7+
# Be a bit more precise to avoid mentions in comments, and allow
8+
# malloc(0) to be used for convenience (e.g. #6757)
9+
alloc_lines = grep(R"{=\s*([(]\w+\s*[*][)])?[mc]alloc[(][^0]}", lines)
910
if (!length(alloc_lines)) return()
1011
# int *tmp=(int*)malloc(...); or just int tmp=malloc(...);
1112
alloc_keys = lines[alloc_lines] |>

.ci/linters/c/cocci_linter.R

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
cocci_linter = if (!nzchar(Sys.which("spatch"))) function(...) {} else function(c_obj) {
2+
bad <- FALSE
3+
for (spfile in list.files(".ci/linters/cocci", full.names = TRUE)) {
4+
# Coccinelle parser gets confused sometimes, so ignore stderr and the exit code
5+
out = suppressWarnings(system2(
6+
"spatch",
7+
shQuote(c(
8+
"--sp-file", spfile, c_obj$path, "--recursive-includes",
9+
"-I", R.home("include"), "-I", "src"
10+
)),
11+
stdout = TRUE, stderr = FALSE
12+
))
13+
if (length(out) > 0) {
14+
cat(sprintf("In file '%s', Coccinelle patch '%s' recommends the following changes:\n", c_obj$path, spfile))
15+
writeLines(out)
16+
bad <- TRUE
17+
}
18+
}
19+
if (bad) stop("Please apply the changes above or fix the linter")
20+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@@
2+
type T;
3+
T* E;
4+
@@
5+
- (T*)
6+
E

.ci/linters/md/heading_id_linter.R

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
any_mismatch = FALSE
2+
3+
# ensure that ids are limited to alphanumerics and dashes
4+
# (in particular, dots and underscores break the links)
5+
check_header_ids = function(md) {
6+
# A bit surprisingly, some headings don't start with a letter.
7+
# We're interested in those that set an id to link to, i.e., end with {#id}.
8+
heading_captures = regmatches(md, regexec("^#+ \\S.*[{]#([^}]*)[}]$", md))
9+
lines_with_id = which(lengths(heading_captures) > 0)
10+
ids = vapply(heading_captures[lines_with_id], `[`, '', 2)
11+
# ids must start with a letter and consist of alphanumerics or dashes.
12+
good_ids = grepl('^[A-Za-z][A-Za-z0-9-]*$', ids)
13+
for (line in lines_with_id[!good_ids]) cat(sprintf(
14+
"On line %d, bad heading id '%s':\n%s\n",
15+
line, heading_captures[[line]][2], heading_captures[[line]][1]
16+
))
17+
!all(good_ids)
18+
}
19+
20+
any_error = FALSE
21+
for (vignette in list.files('vignettes', pattern = "[.]Rmd$", recursive = TRUE, full.name = TRUE)) {
22+
cat(sprintf("Checking vignette file %s...\n", vignette))
23+
rmd_lines = readLines(vignette)
24+
any_error = check_header_ids(rmd_lines) || any_error
25+
}
26+
if (any_error) stop("Please fix the vignette issues above.")

.dev/CRAN_Release.cmd

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@
33
###############################################
44

55
# 1) Update messages for new release
6-
## (a) Update C template file: src/data.table.pot
7-
## ideally, we are including _() wrapping in
8-
## new PRs throughout dev cycle, and this step
9-
## becomes about tying up loose ends
10-
## Check the output here for translatable messages
11-
xgettext -o /dev/stdout ./*.c \
12-
--keyword=Rprintf --keyword=error --keyword=warning --keyword=STOP --keyword=DTWARN --keyword=Error --keyword=DTPRINT --keyword=snprintf:3
13-
14-
## (b) Update R template file: src/R-data.table.pot
15-
## NB: this relies on R >= 4.0 to remove a bug in update_pkg_po
16-
Rscript -e "tools::update_pkg_po('.')"
6+
dt_custom_translators = list(
7+
R = 'catf:fmt|1',
8+
# TODO(MichaelChirico/potools#318): restore snprintf:3 here too
9+
src = c('STOP:1', 'DTWARN:1', 'DTPRINT:1')
10+
)
11+
message_db =
12+
potools::get_message_data(custom_translation_functions = dt_custom_translators)
13+
potools::check_cracked_messages(message_db)
14+
potools::check_untranslated_cat(message_db)
15+
potools::check_untranslated_src(message_db)
16+
17+
## (b) Update R template files (po/*.pot)
18+
potools::po_extract(custom_translation_functions = dt_custom_translators)
1719

1820
# 2) Open a PR with the new templates & contact the translators
1921
# * zh_CN: @hongyuanjia
@@ -114,12 +116,6 @@ grep -P "\t" ./src/*.c
114116
grep -n "[^A-Za-z0-9]T[^A-Za-z0-9]" ./inst/tests/tests.Rraw
115117
grep -n "[^A-Za-z0-9]F[^A-Za-z0-9]" ./inst/tests/tests.Rraw
116118

117-
# All integers internally should have L suffix to avoid lots of one-item coercions
118-
# Where 0 numeric is intended we should perhaps use 0.0 for clarity and make the grep easier
119-
# 1) tolerance=0 usages in setops.R are valid numeric 0, as are anything in strings
120-
# 2) leave the rollends default using roll>=0 though; comments in PR #3803
121-
grep -Enr "^[^#]*(?:\[|==|>|<|>=|<=|,|\(|\+)\s*[-]?[0-9]+[^0-9L:.e]" R | grep -Ev "stop|warning|tolerance"
122-
123119
# Never use ifelse. fifelse for vectors when necessary (nothing yet)
124120
grep -Enr "\bifelse" R
125121

@@ -135,10 +131,6 @@ grep -Fn "tryCatch" ./inst/tests/*.Rraw
135131
# All % in *.Rd should be escaped otherwise text gets silently chopped
136132
grep -n "[^\]%" ./man/*.Rd
137133

138-
# if (a & b) is either invalid or inefficient (ditto for replace & with |);
139-
# if(any(a [&|] b)) is appropriate b/c of collapsing the logical vector to scalar
140-
grep -nr "^[^#]*if[^&#]*[^&#\"][&][^&]" R | grep -Ev "if\s*[(](?:any|all)"
141-
142134
# seal leak potential where two unprotected API calls are passed to the same
143135
# function call, usually involving install() or mkChar()
144136
# Greppable thanks to single lines and wide screens

.github/workflows/code-quality.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ jobs:
3535
steps:
3636
- uses: actions/checkout@v4
3737
- uses: r-lib/actions/setup-r@v2
38+
- name: Install Coccinelle
39+
# relying on the action above us to have updated the package cache
40+
run: /usr/bin/sudo apt-get -y install coccinelle
3841
- name: Lint
3942
run: |
4043
linter_env = new.env()
@@ -70,6 +73,7 @@ jobs:
7073
runs-on: ubuntu-latest
7174
steps:
7275
- uses: actions/checkout@v4
76+
- uses: r-lib/actions/setup-r@v2
7377
- name: Lint
7478
run: for (f in list.files('.ci/linters/md', full.names=TRUE)) source(f)
7579
shell: Rscript {0}

.github/workflows/pkgup.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
cp -R ${{ env.R_LIBS_USER }} library
5151
R CMD INSTALL --library="library" $(ls -1t data.table_*.tar.gz | head -n 1) --html
5252
mkdir -p doc/html
53-
cp /usr/share/R/doc/html/{left.jpg,up.jpg,Rlogo.svg,R.css,index.html} doc/html
53+
cp $(R RHOME)/doc/html/{left.jpg,up.jpg,Rlogo.svg,R.css,index.html} doc/html
5454
Rscript -e 'utils::make.packages.html("library", docdir="doc")'
5555
sed -i "s|file://|../..|g" doc/html/packages.html
5656
mkdir -p public

CODEOWNERS

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@
4545
/R/translation.R @michaelchirico
4646
/src/po.h @michaelchirico
4747
/po/*.pot @Rdatatable/translators
48-
/po/*zh_CN.po @Rdatatable/chinese
49-
/po/*pt_BR.po @Rdatatable/brazil
5048
/po/*es.po @Rdatatable/spanish
49+
/po/*fr.po @Rdatatable/french
50+
/po/*pt_BR.po @Rdatatable/brazil
51+
/po/*ru.po @Rdatatable/russian
52+
/po/*zh_CN.po @Rdatatable/chinese
53+
/vignettes/fr/*.Rmd @Rdatatable/french
54+
/vignettes/ru/*.Rmd @Rdatatable/russian
5155

5256
# printing
5357
/R/print.data.table.R @michaelchirico
@@ -68,6 +72,11 @@
6872
# docs
6973
/man/openmp-utils.Rd @Anirban166
7074
/Seal_of_Approval.md @tdhock
75+
/GOVERNANCE.md: @Rdatatable/committers
7176

7277
# GLCI
7378
.gitlab-ci.yml @jangorecki @ben-schwen
79+
80+
# C code tricks
81+
/src/chmatch.c @aitap
82+
/src/fread.c @aitap

0 commit comments

Comments
 (0)