Hendekagon / clique

Makes a graph of dependencies between functions
https://github.com/Hendekagon/clique/wiki
45 stars 6 forks source link

Missing dependency edges? #1

Open metasoarous opened 9 years ago

metasoarous commented 9 years ago

Unfortunately, this tool seems to frequently miss edges. I just tried it on my semantic-csv, and found that quite a number of dependencies were missing. For example, parse-and-process should depend on process but doesn't. For a minute, I thought that lein-clique might only capture edges between different namspaces, but in my project, process successfully points to mappify and remove-comments, so I discarded that theory. Is there any rhyme or reason here to what gets successfully captured?

Despite the troubles I'm having, I should say that this is an awesome tool, and applaud you :-)

Hendekagon commented 9 years ago

If you use the command-line via lein, then it only returns a graph of dependencies in namespaces outside those of a namespace, but if you use it as a lib, you can use the function all-deps which returns everything. Sorry this was undocumented. I should add the all-deps option to the lein options and update the documentation, thanks for finding this.

Hendekagon commented 9 years ago

...to get a graph of all your dependencies, add [lein-clique "0.1.2"] to your project deps vector then in a repl do (require '[clique.core :as c]) and ((fn [ds](c/export-graphviz %28c/nodes ds%29 %28c/edges ds%29 %28str))) (c/all-deps "src")) for now. Here's the graph for your project: http://celeriac.net/semantic-csv-deps.svg, which I made with cytoscape by importing a csv generated by doing (with-open [o (io/writer "deps.csv")] (csv/write-csv o (mapcat (fn [[k v]] (map (partial vector k) (remove (partial = k) v))) (c/all-deps "src")))) -- I should add a csv export option

metasoarous commented 9 years ago

I'm not sure what you mean by "dependencies in namespaces outside those of a namespace", if not "[dependencies] between different namespaces". Can you please clarify?

As for using c/all-deps, I think you're first code example got mis-formatted. I think you meant something like ((fn [ds] (c/export-graphiz (c/nodes ds) (c/edges ds) (str ...))) (c/all-deps "src")), yes?

One thing I see in the output of c/all-deps is that it includes even local variables like opts, v and such. It would be nice to specifically restrict to only namespaced vars (perhaps as an option, but possibly as default). For now I can do this myself with a simple filter, but it's another option to keep in mind.

CSV option sounds great; I can make another ticket for that if it's organizationally helpful.

Hendekagon commented 9 years ago

oh yes, forgot how my code worked! needs (filter namespace) (with-open [o (io/writer "deps.csv")] (csv/write-csv o (mapcat (fn [[k v]] (map (partial vector k) (filter namespace (remove (partial = k) v)))) (c/all-deps "src")))) By deps outside this namespace I just mean that for each function in a namespace x, it will return no functions it depends on in x, only those in other namespaces I updated the deps graph for your project btw here