Considering the Embold analysis profile for Apache Flink source code it looks like the code needs some serious refactoring in terms of curtailing down the design and code issues detected. This article aims at analyzing where the code is degrading and how it can get back in the game. Have you got your Embold analysis profile generated yet? If not, get one here, Embold is free for your open-source repositories!
Before jumping to any deductions, let’s have a look at the overall rating of Apache Flink.
What are Anti-Patterns?
An anti-pattern is a pattern that seems to work but, is counter-productive. It is code emerged over time and has some major maintainability issues. However, a repeated pattern of actions, processes or structures that initially appears to be beneficial, but ultimately produces more bad consequences.
Making any changes in such code leads to a resisting effect on unlikely components within the application. The above image clearly points out that the design rating has a lot of scope to improve. Without messing around, we will quickly take you to the Anti-Pattern distribution list. Through Embold, you can easily identify and focus on an inefficient component.
In the image below, we have an array of anti-patterns categorized as per the complexity. </br> For more details, refer Antipatterns article.
As you can see, there are so many design blunders here. These issues are of huge significance in terms of their complexity. Looking at the right-hand side list, its evident that the issues in the global context are the topmost culprits. Take a look at the numbers for Global Breakable or Global Butterfly for that matter, fixing such tightly coupled issues will take a painstaking amount of time and effort.
Leaping right into the code
Drilling inside package “fink-core”, we reach class “CollectionExecuter” to find the flaky blocks. The method “executeUnaryOperator” seems to have a serious Dispersed Coupling involved!! Now Dispersed Coupling happens when methods of class access (depend on) many operations across an excessive number of classes thereby making this particular class difficult to maintain.
Maintainable code is the next Clean Code!
One might argue that maintainability is not an issue here, but, the advent of agility in Software Development has focused on creating a ready-to-ship product in each and every stage of the project life-cycle. Unmaintainable code slows down the software development process.
Lets now have a closer look at how the method “executeUnaryOperator” is trapped inside this mare’s nest called Dispersed Coupling.
As we can clearly see, this method “executeUnaryOperator” consisting of 31 lines, calls 10 other methods from 8 classes. However, this class being loosely coupled, it is less risky to make changes here.
The fundamental problem with program maintenance is that fixing a defect has a substantial (20-50 percent) chance of introducing another. So the whole process is two steps forward and one step back..
— Fred Brooks
Code Issues: the local goons
Moving ahead to the Code Issues there is another interesting finding from Embold called the Code Issues Distribution list which guides us fairly to the locality of issue occurrence.
Embold also has a lot of third-party tools integrated into it thereby fitting perfectly into your existing product development ecosystem.
Another engaging verdict is the Hotspots detection inside the “fink-core” component. Above image states that:
- Class Record is a hotspot component in the repository. With the integration of the relevance engine, this class is at a 3% risk out of 5%.
- In spite of having a pretty disturbed overall rating of -1.73, the positive here is, one can easily start focusing individually on which aspects to work on.
- Code Issues rating is -4.69. Code issues are easier to fix because it occurs in a very local context as there is hardly any dependency. Hence, this can majorly leverage the overall quality of the component.
Overall, the take on intelligent Static code analysis solution is that it must have configurations to squeeze the most out of your code analysis as well as indicate clearly on HOW to make code BETTER. These configurations depend on the logic and environment of the application; also on your personal expectations of the scan results. </br> Embold addresses this concern very well by allowing you to fine-tune the analysis results at various levels, to point a few are:
- Code Issue Suppression
- File Exclusions
- Adding customized Quality gate profiles
- Support for DevOps environment by creating an automated feedback loop through the pull request
The findings list can be continued for long maybe an upcoming article for the next part but until then happy coding!!
Comments are closed.