Let's Take a Deeper Look
Are all static analysis defects created equal? Certainly not. There are some issues that are more important to address than others. Every organization categorizes defects differently. For some a memory leak may be important, particularly for long running applications where even a tiny memory leak can add up to a big problem. For others applications, like a desktop application that loads and exits frequently, memory may be hardly an issue but crashes may be a serious priority. Other factors that affect priority can include effect (such as data corruption), frequency, compliance, etc. Regardless of any company's individual priority, one can roughly bucket static analysis defects in these categories:
- Critical - we should fix it now (e.g. don't check it in)
- High - we should fix it before the next milestone
- Medium - we should fix it at the next appropriate milestone
- Low - nice to have - fix it if opportunistic situation
- Ignore - analysis is doing the right thing but the problem doesn't need to be fixed (might be in test code, 3rd party code or perhaps the defect is incorrect because it couldn't take into account an environmental assumption)
- False positive - the analysis goofed and the bug report is wrong
Keep in mind that most bugs are prioritized based on the effect of the bug, which is easier to tie to a business problem. Static analysis defects are reports of flaws in the code -- for instance, it might show a potential memory leak along a specific path in the code. It may be difficult to discern how much memory is being leaked, what the specific steps are that cause the leak and what happens if enough memory leaks. Static analysis defects are thus, harder to prioritize.
A "Typical" Distribution
The distribution of defect types varies greatly among organizations. Some organizations (like a company that writes mil-aero software) consider any coding defect a serious issue. Based on experience with customers at Code Integrity Solutions, we often see defect distributions like this:
- Critical - 10%
- High - 10%
- Medium - 10%
- Low - 10%
- Ignore - 45%
- False positive - 15%
The Biggest Cost?
In addressing the defects reported from a static analysis tool, you need to:
- Make sure the analysis is set up properly
- Someone needs to triage the results meaning interpreting the results for action
- Someone needs to address the issue, typically by fixing the problem
- Someone needs to verify that the issue is addressed
Back of the Envelope
Most organizations purchase a static analysis solution for a product after the product has already been released. Therefore there is a considerable amount of "legacy" code already there. When you run a static analysis solution it finds problems consistently across old and new code. Thus, many organizations who recently purchased a static analysis start by running the analysis and creating a backlog of sometimes thousands, if not tens of thousands of defects.
Let's use a fictitious example. Let's say an organization has 3 million lines of code and finds 3000 defects in their backlog. In order to triage all of the defects, it would take 3000 defects x 10 minutes per defect = 500 hours (62.5 developer days). For a team of 12 developers, this would take a little over 5 business days or essentially a full week. Assuming the distribution above, the distribution of defects would be around:
- Critical - 10% = 300 defects
- High - 10% = 300 defects
- Medium - 10% = 300 defects
- Low - 10% = 300 defects
- Ignore - 45% = 1350 defects
- False positive - 15% = 450 defects
The Hidden Cost
So to triage all the defects takes a team of 12 developers 1 full week. To fix the defects that you care most about, it takes 1 day. That's a whopping ratio of 5:1. Clearly, one of the largest costs of static analysis is triaging the results - to sift through to determine which are the ones worth fixing and which are the ones worth ignoring. In addition, some static analysis tools have much higher false positive rates which means much of the time is spent in reviewing defects rather than the actual time performing the fixes.
The Case for Outside Help
For most organizations, developer time is precious - the most constrained of resources. A week of a team of 12's time can mean a significant number of customer-focused features developed. Many organizations are turning to outside teams to help review defects so that their developers can focus on their core competence - developing capabilities within their product rather than developing expertise reading static analysis results.
An additional strategy is to address the defects even earlier in the software development process, e.g. to the developers as they are coding. This may slightly reduce triage time overall.
However, whether you use an outside team or not, the time required to triage defects must be taken into consideration. It's surprising for many that the most time consuming aspect of using static analysis is in the triaging of results rather than the actual fixing of defects.