Code Review Tool

First published at Monday, 5 November 2012

This blog post has first been published in the Qafoo blog and is duplicated here since I wrote it or participated in writing it.

Warning: This blog post is more then 12 years old – read and use with care.

Code Review Tool

We, at Qafoo, do Code Reviews quite often together with our customers. This often focusses on dicussing metrics, browsing the associated code and discussing solutions for the issues found. We started using a bunch of shell scripts for that, like everyone else, but at some point we came up with a webinterface to do this in a more comfortable way. Now we want to share this tool with you.

The tool currently focuses on our use cases and probably will continue to do so. This involves getting an overview on the customers source code. There are several metrics, like Code Rank, Weighted Method per Class and alike which give you an overview on that. We found "tag clouds" and tables the best view to browse them. Of course all classes are clickable and directly lead to the related source code view:

PDepend Code Rank classes tag cloudPDepend Code Rank classes tag cloud

Additionally we often want to know about especially complex parts in the application, and the distribution of complexity. For the first also Method based tag clouds for metrics like Cyclomatic Complexity and NPath Complexity exist. For the distribution we also generate charts to get a quick overview:

Cyclomatic Complexity distribution chartCyclomatic Complexity distribution chart

On top of those simple metrics a combination of metrics often makes sense especially on class level. For this we included a metrics "calculator" which lists the results of formulas based on class metric to find out more sophisticated and task related issues in software:

PDepend metric calculatorPDepend metric calculator

Source Code Browser

All mentions of classes reference the respective files in the source code browser. The source code browser also contains clickable annotations, so you can directly see if some analyzer complained about a certain class, method or line of code.

Basic source code browserBasic source code browser

You can of course also get a list of all annotations of the currently selected file:

Source file annotation listSource file annotation list

Or you can click through the class dependencies, based on usage or inheritance connections:

Class dependency listClass dependency list

Other Tools

It should be fairly simple to include other (custom) analyzers in this tool. By default there is also something which draws simplified class diagrams, lists issues discovered by PHPMD and the PHP Copy Paste Detector.

Class diagram extractClass diagram extract

The software has been licensed under AGPLv3 and is available on Github. Please keep in mind that we develop this software mainly for internal use, so things might change or break. We still want to share this little gem with you. Feel free to issue pull requests, fork it or do whatever you like with it. More screenshots can also be found on github.

For an installation guide checkout the README.rst. We hope it works for you as well, as it does for us.

Subscribe to updates

There are multiple ways to stay updated with new posts on my blog: