Software code metrics can be extremely useful when reviewing source code for its suitability. Having a solid picture of how many classes, members, and statements are involved in your solution can point out potential problem areas to you. Understanding which classes have a high complexity can help you determine if portions of your system need some refactoring attention to ease risk and maintainability.
DevMetrics, from Anticipating Minds, enables you to generate metrics on your C# source code. DevMetrics will analyze your entire solution, skipping any VB.NET projects, and render you a clear, useful report for examining your solution. You’ll be able to get metrics on the solution’s projects, total statements and lines. Metrics continue down to individual classes, calling out cyclomatic code complexity numbers for classes and class members.
Two different versions of devMetrics are available, the free Community Edition covered in this article, and the Professional Edition which will cost you $75. One downloadable install package will install either version, although installing the Professional edition will prompt you for a license key.
DevMetrics installs itself as a Visual Studio add-in and creates its own submenu under the Tools menu. You can invoke devMetrics quickly from Visual Studio, or you can use the command line version. Invoking devMetrics inside Visual Studio fires off the analysis engine, after which a report is displayed in VS. The report offers summary figures for the solution.
Each project in the solution is broken down further, displaying the number of files and types in that project, along with cyclomatic code complexity (as defined by the Software Engineering Institute), plus statements and lines of code. You can drill down through the report from solution, to project, to Class/Type, and finally to the individual source code file.
DevMetric’s reports are a useful part of your code review process, even if it’s not a formalized one.