Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a GHA for linting code #5908

Merged
merged 51 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
e4324cf
1.15.0 on CRAN. Bump to 1.15.99
MichaelChirico Jan 6, 2024
18a7209
Fix transform slowness (#5493)
OfekShilon Jan 6, 2024
b6bd964
Improvements to the introductory vignette (#5836)
Anirban166 Jan 6, 2024
68f0e41
Vignette typo patch (#5402)
davidbudzynski Jan 6, 2024
7e1a950
Improved handling of list columns with NULL entries (#4250)
sritchie73 Jan 7, 2024
d9d17a7
clarify that list input->unnamed list output (#5383)
MichaelChirico Jan 8, 2024
da24f85
fix subsetting issue in split.data.table (#5368)
MichaelChirico Jan 8, 2024
58608a2
switch to 3.2.0 R dep (#5905)
MichaelChirico Jan 12, 2024
c84a123
Allow early exit from check for eval/evalq in cedta (#5660)
MichaelChirico Jan 12, 2024
513f20f
frollmax1: frollmax, frollmax adaptive, left adaptive support (#5889)
jangorecki Jan 12, 2024
daee139
Friendlier error in assignment with trailing comma (#5467)
MichaelChirico Jan 14, 2024
f5ef168
Link to ?read.delim in ?fread to give a closer analogue of expected b…
MLopez-Ibanez Jan 13, 2024
f658ff4
Run GHA jobs on 1-15-99 dev branch (#5909)
MichaelChirico Jan 14, 2024
a289cee
overhauled linter
MichaelChirico Oct 26, 2020
8bfa507
revert code changes
MichaelChirico Jan 14, 2024
d0c9e8e
Initial commit of {lintr} approach
MichaelChirico Dec 14, 2023
b2b407d
first pass at personalization
MichaelChirico Dec 14, 2023
c3ad3a2
first custom linter
MichaelChirico Dec 14, 2023
56f240c
delint vignettes
MichaelChirico Dec 14, 2023
463b974
delint tests
MichaelChirico Dec 14, 2023
3edafef
delint R sources
MichaelChirico Dec 14, 2023
0ce0980
rm empty
MichaelChirico Jan 14, 2024
f4a1f48
re-merge
MichaelChirico Jan 14, 2024
5e36615
Move config to .ci directory
MichaelChirico Jan 14, 2024
93066bb
Use endsWithAny
MichaelChirico Jan 14, 2024
a56b796
Make declarations static for covr (#5910)
MichaelChirico Jan 15, 2024
f4f4a0f
Merge branch '1-15-99' into linter-ci
MichaelChirico Jan 15, 2024
42931a3
restore lint on branch
MichaelChirico Jan 15, 2024
d1a640d
extension needed after all?
MichaelChirico Jan 15, 2024
9b29249
set option in R
MichaelChirico Jan 15, 2024
0cd9a64
debug printing
MichaelChirico Jan 15, 2024
2915467
Exact file name in option
MichaelChirico Jan 15, 2024
e174f66
really hacky approach
MichaelChirico Jan 15, 2024
4a06a64
skip more linters
MichaelChirico Jan 15, 2024
b007dc3
One more round of deactivation
MichaelChirico Jan 15, 2024
621f90d
FIx whitespace issues (again??)
MichaelChirico Jan 15, 2024
6b84cc5
Merge branch 'master' into linter-ci
MichaelChirico Feb 19, 2024
1726b70
botched merge
MichaelChirico Feb 19, 2024
b40cf8a
obsolete branch ref
MichaelChirico Feb 19, 2024
a14e673
Merge branch 'master' into linter-ci
MichaelChirico Mar 8, 2024
8cb07e1
Merge branch 'master' into linter-ci
MichaelChirico Apr 3, 2024
b74f29f
restore simple CI script thanks to upstream fix
MichaelChirico Apr 3, 2024
babffeb
Merge branch 'master' into linter-ci
MichaelChirico Apr 9, 2024
07432fd
more delint
MichaelChirico Apr 9, 2024
0c8ec4e
just disable unused_import_linter() everywhere for now
MichaelChirico Apr 9, 2024
9091b36
Merge branch 'master' into linter-ci
MichaelChirico Apr 20, 2024
d5759f5
Merge branch 'master' into linter-ci
MichaelChirico Apr 20, 2024
d08b222
rm whitespace from atime tests
MichaelChirico Apr 20, 2024
ff3c715
Merge remote-tracking branch 'origin/linter-ci' into linter-ci
MichaelChirico Apr 20, 2024
2558ecb
comment about comment
MichaelChirico Apr 23, 2024
7b0aecc
Merge branch 'master' into linter-ci
MichaelChirico Apr 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .ci/.lintr.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
for (f in list.files('ci/linters', full.names=TRUE)) source(f)
rm(f)

linters = all_linters(
packages = "lintr", # TODO(lintr->3.2.0): Remove this.
# eq_assignment_linter(),
brace_linter(allow_single_line = TRUE),
# implicit_assignment_linter(allow_lazy = TRUE, allow_scoped = TRUE),
# implicit_integer_linter(allow_colon = TRUE),
# system_time_linter = undesirable_function_linter(c(
# system.time = "Only run timings in benchmark.Rraw"
# )),
# undesirable_function_linter(modify_defaults(
# default_undesirable_functions,
# ifelse = "Use fifelse instead.",
# Sys.setenv = NULL,
# library = NULL,
# options = NULL,
# par = NULL,
# setwd = NULL
# )),
tdhock marked this conversation as resolved.
Show resolved Hide resolved
undesirable_operator_linter(modify_defaults(
default_undesirable_operators,
`<<-` = NULL
)),
# TODO(lintr#2441): Use upstream implementation.
assignment_linter = NULL,
# TODO(lintr#2442): Use this once x[ , j, by] is supported.
commas_linter = NULL,
commented_code_linter = NULL,
# TODO(linter->3.2.0): Activate this.
consecutive_assertion_linter = NULL,
cyclocomp_linter = NULL,
# TODO(linter->3.2.0): Remove this.
extraction_operator_linter = NULL,
function_argument_linter = NULL,
indentation_linter = NULL,
infix_spaces_linter = NULL,
# TODO(R>3.2.0): Activate this, extending to recognize vapply_1i(x, length).
lengths_linter = NULL,
line_length_linter = NULL,
missing_package_linter = NULL,
namespace_linter = NULL,
nonportable_path_linter = NULL,
object_name_linter = NULL,
object_usage_linter = NULL,
quotes_linter = NULL,
semicolon_linter = NULL,
spaces_inside_linter = NULL,
spaces_left_parentheses_linter = NULL,
# TODO(michaelchirico): Only exclude from vignettes, not sure what's wrong.
strings_as_factors_linter = NULL,
# TODO(lintr->3.2.0): Fix on a valid TODO style, enforce it, and re-activate.
todo_comment_linter = NULL,
# TODO(lintr#2443): Use this.
unnecessary_nested_if_linter = NULL,
# TODO(michaelchirico): Enforce these and re-activate them one-by-one. Also stop using '<<-'.
brace_linter = NULL,
fixed_regex_linter = NULL,
function_left_parentheses_linter = NULL,
if_not_else_linter = NULL,
implicit_assignment_linter = NULL,
implicit_integer_linter = NULL,
keyword_quote_linter = NULL,
paren_body_linter = NULL,
redundant_equals_linter = NULL,
scalar_in_linter = NULL,
undesirable_function_linter = NULL,
unnecessary_concatenation_linter = NULL,
unreachable_code_linter = NULL
)
# TODO(lintr#2172): Glob with lintr itself.
exclusions = local({
exclusion_for_dir <- function(dir, exclusions) {
files = list.files(dir, pattern = "\\.(R|Rmd)$")
stats::setNames(rep(list(exclusions), length(files)), files)
}
c(
exclusion_for_dir("tests", list(
quotes_linter = Inf,
# TODO(michaelchirico): Enforce these and re-activate them one-by-one.
implicit_integer_linter = Inf,
infix_spaces_linter = Inf,
undesirable_function_linter = Inf
)),
exclusion_for_dir("vignettes", list(
quotes_linter = Inf
# strings_as_factors_linter = Inf
# system_time_linter = Inf
))
)
})
32 changes: 16 additions & 16 deletions .dev/CRAN_Release.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ R CMD build .
export GITHUB_PAT="f1c.. github personal access token ..7ad"
# avoids many too-many-requests in --as-cran's ping-all-URLs step (20 mins) inside the `checking CRAN incoming feasibility...` step.
# Many thanks to Dirk for the tipoff that setting this env variable solves the problem, #4832.
R CMD check data.table_1.14.99.tar.gz --as-cran
R CMD INSTALL data.table_1.14.99.tar.gz --html
R CMD check data.table_1.15.99.tar.gz --as-cran
R CMD INSTALL data.table_1.15.99.tar.gz --html

# Test C locale doesn't break test suite (#2771)
echo LC_ALL=C > ~/.Renviron
R
Sys.getlocale()=="C"
q("no")
R CMD check data.table_1.14.99.tar.gz
R CMD check data.table_1.15.99.tar.gz
rm ~/.Renviron

# Test non-English does not break test.data.table() due to translation of messages; #3039, #630
Expand All @@ -220,9 +220,9 @@ q("no")

# User supplied PKG_CFLAGS and PKG_LIBS passed through, #4664
# Next line from https://mac.r-project.org/openmp/. Should see the arguments passed through and then fail with gcc on linux.
PKG_CFLAGS='-Xclang -fopenmp' PKG_LIBS=-lomp R CMD INSTALL data.table_1.14.99.tar.gz
PKG_CFLAGS='-Xclang -fopenmp' PKG_LIBS=-lomp R CMD INSTALL data.table_1.15.99.tar.gz
# Next line should work on Linux, just using superfluous and duplicate but valid parameters here to see them retained and work
PKG_CFLAGS='-fopenmp' PKG_LIBS=-lz R CMD INSTALL data.table_1.14.99.tar.gz
PKG_CFLAGS='-fopenmp' PKG_LIBS=-lz R CMD INSTALL data.table_1.15.99.tar.gz

R
remove.packages("xml2") # we checked the URLs; don't need to do it again (many minutes)
Expand Down Expand Up @@ -266,7 +266,7 @@ alias R310=~/build/R-3.1.0/bin/R
### END ONE TIME BUILD

cd ~/GitHub/data.table
R310 CMD INSTALL ./data.table_1.14.99.tar.gz
R310 CMD INSTALL ./data.table_1.15.99.tar.gz
R310
require(data.table)
test.data.table(script="*.Rraw")
Expand All @@ -278,15 +278,15 @@ test.data.table(script="*.Rraw")
vi ~/.R/Makevars
# Make line SHLIB_OPENMP_CFLAGS= active to remove -fopenmp
R CMD build .
R CMD INSTALL data.table_1.14.99.tar.gz # ensure that -fopenmp is missing and there are no warnings
R CMD INSTALL data.table_1.15.99.tar.gz # ensure that -fopenmp is missing and there are no warnings
R
require(data.table) # observe startup message about no OpenMP detected
test.data.table()
q("no")
vi ~/.R/Makevars
# revert change above
R CMD build .
R CMD check data.table_1.14.99.tar.gz
R CMD check data.table_1.15.99.tar.gz


#####################################################
Expand Down Expand Up @@ -341,11 +341,11 @@ alias Rdevel-strict-gcc='~/build/R-devel-strict-gcc/bin/R --vanilla'
alias Rdevel-strict-clang='~/build/R-devel-strict-clang/bin/R --vanilla'

cd ~/GitHub/data.table
Rdevel-strict-[gcc|clang] CMD INSTALL data.table_1.14.99.tar.gz
Rdevel-strict-[gcc|clang] CMD INSTALL data.table_1.15.99.tar.gz
# Check UBSAN and ASAN flags appear in compiler output above. Rdevel was compiled with them so they should be
# passed through to here. However, our configure script seems to get in the way and gets them from {R_HOME}/bin/R
# So I needed to edit my ~/.R/Makevars to get CFLAGS the way I needed.
Rdevel-strict-[gcc|clang] CMD check data.table_1.14.99.tar.gz
Rdevel-strict-[gcc|clang] CMD check data.table_1.15.99.tar.gz
# Use the (failed) output to get the list of currently needed packages and install them
Rdevel-strict-[gcc|clang]
isTRUE(.Machine$sizeof.longdouble==0) # check noLD is being tested
Expand All @@ -354,7 +354,7 @@ install.packages(c("bit64", "bit", "R.utils", "xts", "zoo", "yaml", "knitr", "ma
Ncpus=4)
# Issue #5491 showed that CRAN is running UBSAN on .Rd examples which found an error so we now run full R CMD check
q("no")
Rdevel-strict-[gcc|clang] CMD check data.table_1.14.99.tar.gz
Rdevel-strict-[gcc|clang] CMD check data.table_1.15.99.tar.gz
# UBSAN errors occur on stderr and don't affect R CMD check result. Made many failed attempts to capture them. So grep for them.
find data.table.Rcheck -name "*Rout*" -exec grep -H "runtime error" {} \;

Expand Down Expand Up @@ -391,7 +391,7 @@ cd R-devel-valgrind
make
cd ~/GitHub/data.table
vi ~/.R/Makevars # make the -O2 -g line active, for info on source lines with any problems
Rdevel-valgrind CMD INSTALL data.table_1.14.99.tar.gz
Rdevel-valgrind CMD INSTALL data.table_1.15.99.tar.gz
R_DONT_USE_TK=true Rdevel-valgrind -d "valgrind --tool=memcheck --leak-check=full --track-origins=yes --show-leak-kinds=definite,possible --gen-suppressions=all --suppressions=./.dev/valgrind.supp -s"
# the default for --show-leak-kinds is 'definite,possible' which we're setting explicitly here as a reminder. CRAN uses the default too.
# including 'reachable' (as 'all' does) generates too much output from R itself about by-design permanent blocks
Expand Down Expand Up @@ -429,7 +429,7 @@ cd ~/build/rchk/trunk
. ../scripts/config.inc
. ../scripts/cmpconfig.inc
vi ~/.R/Makevars # set CFLAGS=-O0 -g so that rchk can provide source line numbers
echo 'install.packages("~/GitHub/data.table/data.table_1.14.99.tar.gz",repos=NULL)' | ./bin/R --slave
echo 'install.packages("~/GitHub/data.table/data.table_1.15.99.tar.gz",repos=NULL)' | ./bin/R --slave
# objcopy warnings (if any) can be ignored: https://github.com/kalibera/rchk/issues/17#issuecomment-497312504
. ../scripts/check_package.sh data.table
cat packages/lib/data.table/libs/*check
Expand Down Expand Up @@ -622,10 +622,10 @@ bunzip2 inst/tests/*.Rraw.bz2 # decompress *.Rraw again so as not to commit com
# 3. Add new heading in NEWS for the next dev version. Add "(submitted to CRAN on <today>)" on the released heading.
# 4. Bump minor version in dllVersion() in init.c
# 5. Bump 3 minor version numbers in Makefile
# 6. Search and replace this .dev/CRAN_Release.cmd to update 1.14.99 to 1.15.99 inc below, 1.15.0 to 1.16.0 above, 1.14.0 to 1.15.0 below
# 6. Search and replace this .dev/CRAN_Release.cmd to update 1.15.99 to 1.16.99 inc below, 1.16.0 to 1.17.0 above, 1.15.0 to 1.16.0 below
# 7. Another final gd to view all diffs using meld. (I have `alias gd='git difftool &> /dev/null'` and difftool meld: http://meldmerge.org/)
# 8. Push to master with this consistent commit message: "1.15.0 on CRAN. Bump to 1.14.10"
# 9. Take sha from step 8 and run `git tag 1.15.0 96c..sha..d77` then `git push origin 1.15.0` (not `git push --tags` according to https://stackoverflow.com/a/5195913/403310)
# 8. Push to master with this consistent commit message: "1.16.0 on CRAN. Bump to 1.16.99"
# 9. Take sha from step 8 and run `git tag 1.16.0 96c..sha..d77` then `git push origin 1.16.0` (not `git push --tags` according to https://stackoverflow.com/a/5195913/403310)
######

###### Bump dev for PATCH RELEASE
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
on:
push:
branches:
- main
- master
- 1-15-99
pull_request:
branches:
- main
- master
- 1-15-99

name: R-CMD-check

Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
on:
push:
branches: master
pull_request:
branches: master

name: lint

jobs:
lint:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: |
r-lib/lintr
local::.
needs: lint

- name: Lint
run: lintr::lint_package()
shell: Rscript {0}
env:
LINTR_ERROR_ON_LINT: true
R_LINTR_LINTER_FILE: .ci/.lintr
jangorecki marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
on:
push:
branches:
- main
- master
- 1-15-99
pull_request:
branches:
- main
- master
- 1-15-99

name: test-coverage

Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: data.table
Version: 1.14.99
Version: 1.15.99
Title: Extension of `data.frame`
Depends: R (>= 3.1.0)
Depends: R (>= 3.2.0)
Imports: methods
Suggests: bit64 (>= 4.0.0), bit (>= 4.0.4), R.utils, xts, zoo (>= 1.8-1), yaml, knitr, markdown
Description: Fast aggregation of large data (e.g. 100GB in RAM), fast ordered joins, fast add/modify/delete of columns by group using no copies at all, list columns, friendly and fast character-separated-value read/write. Offers a natural and flexible syntax, for faster development.
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ some:

.PHONY: clean
clean:
$(RM) data.table_1.14.99.tar.gz
$(RM) data.table_1.15.99.tar.gz
$(RM) src/*.o
$(RM) src/*.so

Expand All @@ -28,7 +28,7 @@ build:

.PHONY: install
install:
$(R) CMD INSTALL data.table_1.14.99.tar.gz
$(R) CMD INSTALL data.table_1.15.99.tar.gz

.PHONY: uninstall
uninstall:
Expand All @@ -40,7 +40,7 @@ test:

.PHONY: check
check:
_R_CHECK_CRAN_INCOMING_REMOTE_=false $(R) CMD check data.table_1.14.99.tar.gz --as-cran --ignore-vignettes --no-stop-on-test-error
_R_CHECK_CRAN_INCOMING_REMOTE_=false $(R) CMD check data.table_1.15.99.tar.gz --as-cran --ignore-vignettes --no-stop-on-test-error

.PHONY: revision
revision:
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ S3method(cube, data.table)
S3method(rollup, data.table)
export(frollmean)
export(frollsum)
export(frollmax)
export(frollapply)
export(nafill)
export(setnafill)
Expand Down
28 changes: 28 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
**If you are viewing this file on CRAN, please check [latest news on GitHub](https://github.com/Rdatatable/data.table/blob/master/NEWS.md) where the formatting is also better.**

# data.table [v1.15.99]() (in development)

## NEW FEATURES

1. `print.data.table()` shows empty (`NULL`) list column entries as `[NULL]` for emphasis. Previously they would just print nothing (same as for empty string). Part of [#4198](https://github.com/Rdatatable/data.table/issues/4198). Thanks @sritchie73 for the proposal and fix.

```R
data.table(a=list(NULL, ""))
# a
# <list>
# 1: [NULL]
# 2:
```

2. New window function `frollmax` computes the rolling maximum. Request came from @gpierard who needs left-aligned, adaptive, rolling max, [#5438](https://github.com/Rdatatable/data.table/issues/5438). Adaptive rolling functions did not have support for `align="left"`, therefore we added this feature as well for all adaptive rolling functions. We measure adaptive `frollmax` to be up to 50 times faster than the next fastest solution using `max` and grouping `by=.EACHI`.

## NOTES

1. `transform` method for data.table sped up substantially when creating new columns on large tables. Thanks to @OfekShilon for the report and PR. The implemented solution was proposed by @ColeMiller1.

2. The documentation for the `fill` argument in `rbind()` and `rbindlist()` now notes the expected behaviour for missing `list` columns when `fill=TRUE`, namely to use `NULL` (not `NA`), [#4198](https://github.com/Rdatatable/data.table/pull/4198). Thanks @sritchie73 for the proposal and fix.

3. data.table now depends on R 3.2.0 (2015) instead of 3.1.0 (2014). 1.17.0 will likely move to R 3.3.0 (2016). Recent versions of R have good features that we would gradually like to incorporate, and we see next to no usage of these very old versions of R.

4. Erroneous assignment calls in `[` with a trailing comma (e.g. ``DT[, `:=`(a = 1, b = 2,)]``) get a friendlier error since this situation is common during refactoring and easy to miss visually. Thanks @MichaelChirico for the fix.

# data.table [v1.14.99](https://github.com/Rdatatable/data.table/milestone/29) (in development)

## BREAKING CHANGE
Expand Down Expand Up @@ -560,6 +586,8 @@

55. `fread(URL)` with `https:` and `ftps:` could timeout if proxy settings were not guessed right by `curl::curl_download`, [#1686](https://github.com/Rdatatable/data.table/issues/1686). `fread(URL)` now uses `download.file()` as default for downloading files from urls. Thanks to @cderv for the report and Benjamin Schwendinger for the fix.

56. `split.data.table()` works for downstream methods that don't implement `DT[i]` form (i.e., requiring `DT[i, j]` form, like plain `data.frame`s), for example `sf`'s `[.sf`, [#5365](https://github.com/Rdatatable/data.table/issues/5365). Thanks @barryrowlingson for the report and @michaelchirico for the fix.

## NOTES

1. New feature 29 in v1.12.4 (Oct 2019) introduced zero-copy coercion. Our thinking is that requiring you to get the type right in the case of `0` (type double) vs `0L` (type integer) is too inconvenient for you the user. So such coercions happen in `data.table` automatically without warning. Thanks to zero-copy coercion there is no speed penalty, even when calling `set()` many times in a loop, so there's no speed penalty to warn you about either. However, we believe that assigning a character value such as `"2"` into an integer column is more likely to be a user mistake that you would like to be warned about. The type difference (character vs integer) may be the only clue that you have selected the wrong column, or typed the wrong variable to be assigned to that column. For this reason we view character to numeric-like coercion differently and will warn about it. If it is correct, then the warning is intended to nudge you to wrap the RHS with `as.<type>()` so that it is clear to readers of your code that a coercion from character to that type is intended. For example :
Expand Down
1 change: 0 additions & 1 deletion R/bmerge.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,3 @@ bmerge = function(i, x, icols, xcols, roll, rollends, nomatch, mult, ops, verbos
ans$xo = xo # for further use by [.data.table
return(ans)
}

15 changes: 14 additions & 1 deletion R/cedta.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ cedta.pkgEvalsUserCode = c("gWidgetsWWW","statET","FastRWeb","slidify","rmarkdow
# package authors could set it using assignInNamespace and then not revert its value properly which would
# cause subsequent calls from other packages to fail.

# nocov start: very hard to reach this within our test suite -- the call stack within a call generated by e.g. knitr
# for loop, not any(vapply_1b(.)), to allow early exit
.any_eval_calls_in_stack <- function() {
calls = sys.calls()
# likelier to be close to the end of the call stack, right?
for (ii in length(calls):1) { # rev(seq_len(length(calls)))? See https://bugs.r-project.org/show_bug.cgi?id=18406.
the_call <- calls[[ii]][[1L]]
if (is.name(the_call) && (the_call %chin% c("eval", "evalq"))) return(TRUE)
}
return(FALSE)
}
# nocov end

# cedta = Calling Environment Data.Table-Aware
cedta = function(n=2L) {
# Calling Environment Data Table Aware
Expand All @@ -41,7 +54,7 @@ cedta = function(n=2L) {
(exists("debugger.look", parent.frame(n+1L)) ||
(length(sc<-sys.calls())>=8L && sc[[length(sc)-7L]] %iscall% 'example')) ) || # 'example' for #2972
(nsname=="base" && all(c("FUN", "X") %chin% ls(parent.frame(n)))) || # lapply
(nsname %chin% cedta.pkgEvalsUserCode && any(vapply_1b(sys.calls(), function(x) is.name(x[[1L]]) && (x[[1L]]=="eval" || x[[1L]]=="evalq")))) ||
(nsname %chin% cedta.pkgEvalsUserCode && .any_eval_calls_in_stack()) ||
nsname %chin% cedta.override ||
isTRUE(ns$.datatable.aware) || # As of Sep 2018: RCAS, caretEnsemble, dtplyr, rstanarm, rbokeh, CEMiTool, rqdatatable, RImmPort, BPRMeth, rlist
tryCatch("data.table" %chin% get(".Depends",paste("package",nsname,sep=":"),inherits=FALSE),error=function(e)FALSE) # both ns$.Depends and get(.Depends,ns) are not sufficient
Expand Down
Loading
Loading