We got some code in a git repository that’s used along different projects (with git different repositories), the problem is that we got now so many different projects that’s difficult to track which projects will be affected and how when there is a change in the shared module.
Is there any way to find classes and methods usages along different git repositories? Or who would you manage an architecture like that?
1
Take a look at some code quality and code indexing tools.
FishEye
For starters, you could use FishEye, which would index your code and allow you to quickly query for code from all the repositories so you can keep a bird’s eye view of the whole codebase.
For instance, you could search for a given file (but also for a file’s content, including a method name) and it will find affiliated tickets and changesets that modified it, and its latest version in your code repositories:
However, FishEye doesn’t necessarily understand the code and see methods as units to be tracked, so you can’t say “find call points of method M of class C”.
Sonar
A code quality tool like Sonar would also allow you to keep an eye on dependencies (especially if you have a maven-based build).
For instance, a very handy view is this one:
It allows you to see the connections between different components in terms of dependencies, so you know that a change to this component might impact the other ones.
Read here for more.
Again, it doesn’t really tell you that at the method level though (it relies on the dependency graph of the binary dependencies of your build).
Update: Actually, looks like Sonar even does method level tracking (see the SonarSource blog I linked above):
Krugle
Available online for open-source project repositories, you can also deploy your own instance (basic version for free).
http://www.krugle.org/
CodeSight
Host your own CodeSight instance.
http://www.blackducksoftware.com/products/code-sight
Elastic Search
GitHub uses it since January 2013, so if your git repo is GitHub-hosted you can already benefit from that. Otherwise you can roll out your own.
Roll Out Your Own
Probably not adviseable, but you could probably produce an indexed database of your code using a nightly job parsing your projects and using a full-text search engine (like Apache Lucene, for instance), or even something more low-tech than that.
You can find more tooling support for code analysis and graphing at the class level, but you’d end up with pretty complicated and unreadable graphs very quickly anyways, for any relatively large system.
Many build systems have plugins for that sort of thing.