Engineering Blog

Early Warnings for Future Maintenance Problems

Written by Adam Tornhill | Sep 8, 2017 10:00:00 AM

A codebase under active development evolves at a rapid pace, and as soon as the organization scales beyond 10-12 people it’s virtually impossible for a single individual to maintain a holistic picture of the system. 

The roots of future maintenance problems are often introduced in change bursts, perhaps by shoehorning a new feature into an existing design, and from there they only grow worse over time. Wouldn’t it be great if you could get an early warning when that happens so that you can take appropriate counter measures and save your code from decay?

 

What’s an Early Warning?

The CodeScene tool offers the ability to detect potential maintenance problems and early warnings in your codebase. The earlier you react to those findings, the better, so let’s look at a few examples.

The following figure shows an example on three different warnings auto-detected by CodeScene in Google's TensorFlow codebase. TensorFlow is a library for machine learning, and the warnings are highlighted using yellow tiles:

CodeScene detects early warnings in your codebase.

 

These early warnings point your attention to different aspects of the system:

  • Detects Code before it becomes a Hotspot: This warning highlights code that isn’t a hotspot yet, but climbs rapidly on the hotspot ranking (check out Predict Maintenance Problems In Large Codebases for an introduction to hotspots). You use this information as a driver to refactor those Hotspots into more cohesive units, if appropriate.
  • Identifies Steep Increases In Complexity: Since CodeScene knows how your code typically evolves, the tool can detect parts of the code that suddenly increases in complexity as shown in the next figure. This doesn’t mean it’s a problem, rather the warning is CodeScene’s way of drawing your attention to an area of the code. Use this information to focus code reviews and additional testing.

Early warnings are delivered for code that accumulate complexity rapidly.

  • Predict Delivery Risk: CodeScene calculates a risk profile for your codebase, which is based on how the system has evolved and what a typical change looks like. That is, the algorithm focuses more at how a commit looks than the changed code itself and combines its technical metrics with social data such as developer experience. This is information that you use to prioritize code reviews and to reason about delivery risks of individual features.

The detailed view of high risk commits

 

Context Matters

The advantage of social code analyses – like these early warnings – is that they take your context into account. This is important because different organizations have different quality goals; In some codebases large, monolithic files are the norm, while others prefer a more modular design with small and cohesive units.

CodeScene solves that by making the warnings relative to the rest of your code, which means that false positives are kept at a minimum and the presented results are directly relevant in your context.

Finally, there’s the option of integrating the early warning detection into your continuous integration pipeline as demonstrated.

CodeScene is free for open source, so give it a try.