Skip to content

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

@yutannihilation

Description

@yutannihilation

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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions