Skip to content

Hotspot analysis

Silvio Montanari edited this page Jan 1, 2017 · 4 revisions

Description

This analysis combines the level of complexity of each module in the code base with its level of churn (expressed as number of revisions). The complexity of a file is measured in a language-neutral way simply by counting the number of lines of code (SLOC). However if your code contains files written in a one of the supported programming languages (e.g. JavaScript) then this analysis provides also an alternative view using the cyclomatic complexity as a more specific metric.

Tasks

hotspot analysis

This task merges a revision report with a sloc report and a complexity report run on each file of the repository.

Usage
$ gulp hotspot-analysis [--dateFrom=<dateFrom>] [--dateTo=<dateTo>]
Visualisation

The results of this analysis are displayed through an enclosure diagram, a popular representation of the typical hierarchical structure of a codebase where each circle/node represents a package/module or a file. The diagram is interactive and you can navigate through each entity by zooming in and out of every circle. The size of each circle is proportional to the value of the main metric of the file it represents or to the sum of the values of the children nodes/files. At the same time each node representing a file is filled with a dark red colour of increasing intensity depending on its level of churn for the period of time of the analysis.

The analysis chart offers two slightly different perspectives: a more generic one (always available) where the main value metric for each file is the number of source lines of code. In the second visualisation the main metric for each file is calculated on its total cyclomatic complexity. The churn for each module is calculated from the number of revisions affecting the file during the analysed time period, and is expressed as a percentage value, relative to the module with the highest churn.

This visualisation can be used to identify potential hotspots in the system, i.e. parts of the code that may be unstable and in need of refactoring.

Below are some sample hotspot diagrams from a popular Ruby on Rails codebase (Diaspora):

Hotspot diagram - sloc

The visualisation also offers some filtering features:

  • A filter on the main metric value to show only the nodes/modules with a certain size or complexity.
  • A filter on the churn level to show only the modules with a level of churn above a certain percentage.

Hotspot diagram - complexity filter

When moving the mouse pointer over a leaf node a tooltip is shown to display the details of the file and its metric values.

Hotspot diagram - tooltip