-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Hi,
Thanks for the README it was very informative to get started and run it locally on a package. It was faster than expected (on a package with almost no tests).
I'm using covtracer to find which code can't be reached out with shiny::testServer. For that I need to find which function is a server and which is not.
I noticed that ttdf delivers some rows with alias but no source code. This is because those alias have no source code (the alias of the name of the package and similar code objects).
Also It would be great if besides the alias there could be a function to extract the names of the symbols and the lines of code. The following code is after running the README.
Some code for finding alias without source code
s <- ttdf[["srcref"]]
functions_names <- names(ttdf$srcref)
nas <- which(is.na(functions_names))
functions_names <- functions_names[-nas]
u_alias <- ttdf$alias |> unique()
ufn <- functions_names |> unique()
setdiff(u_alias, ufn)Code to extract name and line for each symbol with source code
For all:
src <- ttdf[["srcref"]]
functions_names <- names(ttdf$srcref)
nas <- which(is.na(functions_names))
functions_names <- functions_names[-nas]
src_text <- lapply(src[-nas], as.character, useSource = FALSE)
srcrefs <- unlist(src_text, use.names = TRUE)
lines <- strcapture(pattern = "([[:digit:]]+):([[:digit:]]+) to ([[:digit:]]+):([[:digit:]]+)>",
srcrefs,
proto = data.frame(
start_line = integer(),
start_col = integer(),
end_line = integer(),
end_col = integer()
))
data_f <- cbind(functions = functions_names, lines) |>
unique()Faster more direct (but might miss some other cases)
covv <- as.data.frame(cov)
covv_s <- covv |> dplyr::summarise(.by =functions, first_line = min(first_line), last_line=max(last_line))
covv_sSorry for the messy code