55.1. Code Metrics

Code metrics will serve as a reference to know how maintainable your code is. This feature is new in Visual Studio 2008; in this version it comes with five metrics. All of them have to be looked at with care, and you have to set your own context at the time you evaluate your projects. Figure 55-1 shows the Code Metrics window for a sample project. You open this window from the Analyze Windows Code Metric Results menu. To calculate the metrics you should hit the button on the top-left corner. The Code Metrics window shows a hierarchy of the projects, namespaces, types, and members.

Directly from the list you can filter any of the metrics to show methods that fall within a specified range, export to Excel, configure columns to remove metrics, or create a work item. Export to Excel is particularly useful to generate reports using pivot tables or to work with a flat view of the information using filters and sorts. For example, if you want to look for methods with more than 15 lines of code, filtering directly in the Code Metrics window will get you a lot of namespaces and types, but you will have to expand each to see whether there are any methods, whereas in Excel you can easily filter out namespaces and types and only look at methods.

Work items are activities assigned ...

Get Professional Visual Studio® 2008 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.