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

Update use of superseded functions #34

Open
ddsjoberg opened this issue Dec 20, 2023 · 6 comments
Open

Update use of superseded functions #34

ddsjoberg opened this issue Dec 20, 2023 · 6 comments

Comments

@ddsjoberg
Copy link
Collaborator

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:

  • these variables come from a template in the respective package. does the template need to be updated? if so, that will need to happen before we update.
  • if the template has already been updated to use a non-superseded function, then we can simply update our CSV file.

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

@bms63
Copy link
Contributor

bms63 commented Dec 20, 2023

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

@ddsjoberg
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Contributor

bms63 commented Dec 21, 2023

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
Copy link
Contributor

bms63 commented Dec 21, 2023

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
Copy link
Collaborator Author

ddsjoberg commented Dec 21, 2023

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.

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

No branches or pull requests

2 participants