pharmaverse / admiraldiscovery

https://pharmaverse.github.io/admiraldiscovery/
Other
1 stars 4 forks source link

Update use of superseded functions #34

Open ddsjoberg opened 10 months ago

ddsjoberg commented 10 months ago

There are three superseded functions currently being used in the variable listings. And we need to make updates to no longer use them.

image

we need to identify a few things:

@athenamelia is this something you have the bandwidth to work on?

bms63 commented 10 months ago

Sorry to hijack your issue!! Can we get this test to run run on the templates and vignettes in admiral??!!

ddsjoberg commented 10 months ago

Kind of? maybe? idk?

We'd need to ingest the entire template script, parse it in such a way where we extract every function used, then take that list of functions and compare it the the list of superseded/deprecated functions (which we can get that list using functions in admiraldiscovery).

So that first bit it going to be tricky I think, unless someone has a script/function to do this....

ok, after two seconds of searching: here's a method using a script someone wrote on the posit community forum: https://community.rstudio.com/t/is-there-a-way-to-extract-the-names-of-all-functions-in-an-r-script/51905 here's a function in a package that looks like it'll do it as well: https://rdrr.io/cran/NCmisc/man/list.functions.in.file.html

ddsjoberg commented 10 months ago

how/where do you want this to work? i don't think it belongs in the individual packages. maybe this could be more warnings here in admiraldiscovery?

bms63 commented 10 months ago

I was thinking it would be a test in admiral where we could grab the @superseded functions and make sure none of them are being used in the templates.

I wonder if something from logrx could be used?
https://github.com/pharmaverse/logrx/blob/4e078732bebc031c0bd00120fe336fb1a91ff76e/R/get.R#L137

but the list.functions.in.file looks really easy...maybe we could just borrow the code rather than put NCmisc in the suggests

> list.functions.in.file function (filename, alphabetic = TRUE) { if (!file.exists(filename)) { stop("couldn't find file ", filename) } if (!get.ext(filename) == "R") { warning("expecting *.R file, will try to proceed") } tmp <- getParseData(parse(filename, keep.source = TRUE)) nms <- tmp$text[which(tmp$token == "SYMBOL_FUNCTION_CALL")] funs <- unique(if (alphabetic) { sort(nms) } else { nms }) src <- paste(as.vector(sapply(funs, find))) outlist <- tapply(funs, factor(src), c) return(outlist) }

bms63 commented 10 months ago

I guess at the end of the day - I just want something that alerts me to superseded functions or deprecated functions being used. It can live where ever, but I just want it to be something that is continuously checked.

ddsjoberg commented 10 months ago

Hmmm, let's think about the best ways to make this work and discuss at our meeting? I agree we shouldn't add dependencies to make this work.