Chapter 9. Generating Metrics

One of JStyle’s strong points is its capability to compute many interesting object-oriented (some non object-oriented) metrics on the code that is being reviewed. Several research papers and books extol the importance of such metrics in designing quality software. If your company or team believes in these metrics, you will find JStyle an indispensable tool.

Generating metrics is possible only after comment generation is complete on the current project. Choose Reports->Metrics Spreadsheet from the main menu to display the project metrics in the form of a table. See the following figure.

Fig. 9.1

Project level metrics give information related to the whole project, such as number of classes, number of packages, average inheritance depth, etc. Immediately above the project metrics table are a few icons. These are (from left to right) for displaying project summary, file summary, class summary, method summary, and methods in a class.

Clicking on File Summary displays metrics applicable at file/module level. See the following figure. 

Fig. 9.2

This table displays for each file in the project, information such as total number of lines, comment density, etc. If your team requires a minimum comment density in the source, the above table quickly tells you whether there are violations of the rule.

The next icon is for generating class-level metrics. If you click on it, you get the following table. 

Fig. 9.3

You will find the maximum number of metrics reported under this category. Popular metrics including Depth of Inheritance Tree (DIT), Response for Class (RFC), Lack of Cohesion in Methods (LCOM), and Weighted Methods per Class (WMC) are shown here (definitions of all the metrics JStyle computes are available in the online help). One convenient aspect of the table view is that you can sort the respective column elements in ascending or descending order by double clicking on the column label.

The next icon is for generating method-level metrics. The figure below shows the details populated in the table view.

Fig. 9.4

The last view pertains to method summary for a selected class. To get this display, select a class from the class-level metrics and click on the last icon. See the following figure for the kind of information displayed.

Fig. 9.5

Metrics Reports – Other Options

Instead of viewing the metrics details on the screen as explained so far, you may save the data in other formats for later processing. JStyle supports the following options:

  • Text format

  • RTF format

  • HTML format

  • Saving to a database

  • Exporting in spreadsheet compatible format

If you choose to save the metrics data in HTML format, JStyle will prompt you for the destination directory. Data will be saved as HTML files in that directory and if Internet Explorer is installed on your machine, a browser view will open automatically. See the following diagram.

Fig. 9.6

This view gives convenient navigational links to other parts of the metrics report. To familiarize yourself with the various reporting options, look up Reports->Metrics Reports menu.

In addition to these reports, you can view metrics information in the form of charts. Select Tools->Charts from the menu. This will bring up a dialog listing several supported charts. See the following figure.

Fig. 9.7

Select one and click OK. For instance, when you select Comment Severity, you get the following chart.

Fig. 9.8

Multiple charts can be open at the same time and they can be saved to a file or printed.

Contents     Top    Previous    Next


Copyright © Man Machine Systems 1997-2001.
All Rights Reserved.
We acknowledge all trademarks.