Hi ,
for the past couple of month I was (and am still) working on a fully automated code-graph-analysis-pipeline in my free time. I have chosen AxonFramework to get started with a concrete code base because it is open, it is not too big or small, I know it a little bit but not too well and it is very well structured.
- Results: AxonFramework v4.8.0 reports
- More details on how this was made can be found in the main documentation of code-graph-analysis-pipeline.
I’m still working on this and trying to improve it. I’ve seen some copy&paste issues in the reports (I’ll fix them). I also try to make it work with larger code bases and hopefully can also get some visual graphs into the reports. So stay tuned…
Examples
Selected Reports
Cyclic Dependencies
A classic static code analysis feature is the detection of cyclic dependencies.
The following steps could resolve some of the cyclic dependencies. They aren’t guaranteed to do so because moving classes can lead to other cyclic dependencies as a consequence. These suggestions are based on AxonFramework-4.8.0 InternalDependencies (table 3)
-
Move ConvertingResponseMessage from Package
org.axonframework.messaging.responsetypes
toorg.axonframework.queryhandling
. -
Move NestingSpanFactory from Package
org.axonframework.tracing
toorg.axonframework.eventhandling
. -
Move Headers and StreamableMessageSource from Package
org.axonframework.messaging
toorg.axonframework.eventhandling
.
Interface Segregation
This is a less common analysis. At least I couldn’t find anything like that in commonly known tools. The following (selected) step could help to improve encapsulation and extensibility by applying the Interface Segregation Principle. On the downside this could lead to additional complexity by abstraction. So careful with these… This suggestion is based on AxonFramework-4.8.0 InternalDependencies (table 3b)
-
CommandMessage declares or inherits 11 methods. 19 types only use the method
getCommandName
. Either could they be changed to only use the return type ofgetCommandName
without any reference to CommandMessage, or a new interface could be introduced that provides justgetCommandName
that can then be used instead at these code locations. The latter change could be introduced without any breaking changes.
Graph Data Science
It gets really exciting when applying Graph Data Science to get even more information about the structure of the code: