jenkins the definitive guide

(Jeff_L) #1

As we mentioned earlier, the same approach also works with the PMD plugin and the FindBugs plugin.
These plugins are a great way to provide more focused reporting on the results of a particular tool, and
also give you more control over the impact that these violations will have on the build results.


9.6. Reporting on Code Complexity


Code complexity is another important aspect of code quality. Code complexity is measured in a
number of ways, but one commonly used (and easy-to-understand) complexity metric is Cyclometric
Complexity, which involves measuring the number of different paths through a method. Using this
metric, complex code typically has large numbers of nested conditional statements and loops, which
make the code harder to understand and to debug.


There is also a code quality theory that correlates code complexity and code coverage, to give a general
idea of how reliable a particular piece of code is. This is based on the (very understandable) idea that
code that is both complex and poorly tested is more likely to contain bugs than simple, well-tested code.


The Coverage Complexity Scatter Plot plugin is designed to let you visualize this information in your
Jenkins builds (see Figure 9.14, “A coverage/complexity scatter plot”). Dangerously complex and/or
untested methods will appear high on the graph, where as the more well-written and well-tested methods
will appear lower down.


Figure 9.14. A coverage/complexity scatter plot


The scatter graph gives you a good overview of the state of your code in terms of complexity and test
coverage, but you can also drill down to investigate further. If you click on any point in the graph, you
can see the corresponding methods, with their test coverage and complexity (see Figure 9.15, “You can
click on any point in the graph to investigate further”).

Free download pdf