pkgnet icon indicating copy to clipboard operation
pkgnet copied to clipboard

Missing dependency link, if function call happens within the arguments of a function

Open vertesy opened this issue 1 year ago • 4 comments

pkgnet::CreatePackageReport misses function calls that happens within the arguments of a function. For instance GetGruffiClusteringName is a helper to guess granuleRes in ParseGruffiGranuleScoreName. See more in gruffi

ParseGruffiGranuleScoreName <- function(goID, obj = combined.obj, granuleRes = GetGruffiClusteringName(obj)) {
  Stringendo::kppu(granuleRes, "cl.av", make.names(goID))
}

I did:

pkgnet_result <- pkgnet::CreatePackageReport(package.name)
fun_graph     <- pkgnet_result$FunctionReporter$pkg_graph$'igraph'
PackageTools::convert_igraph_to_mermaid(graph = fun_graph, openMermaid = T, copy_to_clipboard = T)

The result: https://github.com/jn-goe/gruffi/blob/main/Functions.md

The problem The network is missing all, but one of the links to GetGruffiClusteringName(), bc all, but one uses were in the argument lines!

vertesy avatar Mar 02 '24 14:03 vertesy

Thanks for the report. Are you interested in trying to contribute this?

jameslamb avatar Mar 03 '24 22:03 jameslamb

Thanks James, looking at your codebase, and its structure, and I am clearly not at well versed enough in R.

As far as i understood the problem is using body(), e.g. in FunctionReporter() and the solution would be to use body() and formals() to parse the argument list as well. But body() appears at multiple locations so I am not confident.

> # Define a simple function
> myFunction <- function(x, y = 1, argX = .myfun(x)) {
+       return(x + y)
+   }
> # Use formals() to get the arguments of the function
> (formals(myFunction))
$x


$y
[1] 1

$argX
.myfun(x)

This may be not too useful, I am sorry for that.

vertesy avatar Mar 04 '24 09:03 vertesy

It's been 2 years since we made any meaningful changes to the code in this library... everything in the current state could be changed if there was a need!

If you're not interested in contributing at this time, we'll leave it here as a feature request. This project isn't being actively maintained, but occasionally one of us decides to put a weekend into it, so it might be picked up in the future.

jameslamb avatar Mar 05 '24 14:03 jameslamb

Okay, thank you that's fair! I will try to allocate time - as said, the package code is more professional than what I write so it may take time.

vertesy avatar Mar 08 '24 15:03 vertesy