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

FR: Show non used objects in flow_view_uses? #174

Closed
llrs opened this issue Mar 20, 2024 · 2 comments
Closed

FR: Show non used objects in flow_view_uses? #174

llrs opened this issue Mar 20, 2024 · 2 comments

Comments

@llrs
Copy link
Contributor

llrs commented Mar 20, 2024

I am using more flow to inspect my own packages to improve code and follow the "Don't repeat yourself" principle.
One particular use case is if I define a new helper function and I need to go back and find where it might be used.

I don't expect flow to check the code and compare an object with the code but it would be nice to have flow_view_uses to have an argument to display other functions/code aren't using the object. The way I see I could use flow::flow_view_uses(omit, all = TRUE) so that all (exported) objects of the package/environment would be shown (by default it would be FALSE). This way it might help to find some definitions I need to review to see if omit would be helpful there.

I am not sure if it fits well with the scope of the package, as I am asking for a diagram of objects/functions with no flow between them.

@moodymudskipper
Copy link
Owner

I think if there is no relationship between blocks a diagram might not be the right fit. And this would really be useful only for a small package, or the diagram will become huge.

Now I think flow could contain functions that describe dependencies between functions without drawing diagrams.

Alternately you can show everything on a single diagram:

devtools::load_all()
flow::flow_view_deps(as.list(asNamespace("yourpkg")))

Or we can fetch the data from the diagram and do some wrangling :

fl <- flow::flow_view_uses(yourpkg::your fun)
setdiff(getNamespaceExports("yourpkg"), c(fl$data$fun, "yourfun"))
setdiff(names(asNamespace("yourpkg")), c(fl$data$fun, "yourfun"))

Do those help ?

@llrs
Copy link
Contributor Author

llrs commented Mar 20, 2024

Yes, this helps. Many thanks.

A function that exposes data and another that plots it is great in case the end-user wants to use other plotting methods or customize it. It will also help with #127.

@llrs llrs closed this as completed Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants