Skip to content

tests/testthat/test-prohibited-functions.R is not working #4445

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

Closed
yutannihilation opened this issue Apr 24, 2021 · 0 comments · Fixed by #4446
Closed

tests/testthat/test-prohibited-functions.R is not working #4445

yutannihilation opened this issue Apr 24, 2021 · 0 comments · Fixed by #4446

Comments

@yutannihilation
Copy link
Member

At the time of proposing #3758, I think it works fine, but currently it has two problem

  1. It fails on local (i.e. when devtools::test())
  2. It does nothing on GitHub Actions CI (i.e. when R CMD check) because of some difference of the path to R files.

For 1., I'm seeing this on my local.

─ Failure (test-prohibited-functions.R:50:3): do not use data.frame(), use `data_frame()` or `new_data_frame()` ─
sum(data.frames) not equal to 0.
1/1 mismatches
[1] 12 - 0 == 12

because some code is actually using data.frame with base:: prefix.

get_n_data.frame <- function(f) {
  d <- getParseData(parse(f, keep.source = TRUE))
  sum(d$token == "SYMBOL_FUNCTION_CALL" & d$text == "data.frame")
}


R_files <- list.files("~/repo/ggplot2/R", pattern = ".*\\.(R|r)$", full.names = TRUE)

data.frames <- vapply(R_files, get_n_data.frame, integer(1))
data.frames[data.frames > 0]
#>    /home/yutani/repo/ggplot2/R/fortify-multcomp.r 
#>                                                 4 
#> /home/yutani/repo/ggplot2/R/stat-smooth-methods.r 
#>                                                 8

Created on 2021-04-24 by the reprex package (v2.0.0)

I'm sorry I didn't notice this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant