Online Manual



Metrics View

Metrics View

Metrics View is yet another way of representing the dataflow information. Unlike Analysis Report View and Query Tree View, which represent dataflow information on the current Java Element, Metrics View displays that information on all Java Elements simultaneously, allowing to compare Java Elements by some numerical parameters (metrics) and find Java Elements with the highest/lowest metrics. This feature is very useful in the tasks of source code quality improving. SourceGlider supports lots of different kinds of metrics (you can find the full list of metrics available in SourceGlider in the Reference). Some of these metrics could be interpreted as the measure of badness for the source code. You could quickly find the parts of code that have the most badness and refactor them.

Metrics View basically appears at the bottom of Eclipse workbench. You can display the view by either of the following ways:

  • Select Source Analysis > Show Metrics in the Eclipse menu. If there's no active analysis, you will be prompted to start the new Composite Analysis.
  • Select Window > Show View > Other... and choose Metrics from the Source Analysis group. In this case no analysis will be computed if there's no active analysis.
  • Press the button on the toolbar of the Analysis Report View.
  • Some sections in Analysis Report View contain Show in Metrics Table buttons. Click on such button to display the Metrics View (the Folders Mode will be set in this case and the current Java Element will be selected):

  • There are Show in Metrics Table submenus in Query Tree View context menu. Select such menu to display the Metrics View (the Folders Mode will be set in this case and the current Java Element will be selected):

In addition, if the corresponding option is switched on (it is switched off by default), Metrics View can be automatically displayed after the analysis is computed.

Metrics View has the toolbar with the following controls:

  • button is enabled in the Folders Mode. It will change the current folder to the parent folder.
  • button switches the Folders Mode on and off. The button is enabled only if the current Java Element has the type Folders or Types.
  • button will stop the current Java Elements sorting process (see below). The button is enabled if this process is currently running.
  • Configure Metrics... hyperlink will open up the Metrics Configure Dialog, where you can set up the current metrics.
  • icon denotes the current type of Java Elements (see below). You can change this type in the drop-down list at the right of this icon. Only types that support metrics are displayed here.

When the analysis is computed, Metrics View displays the following content:

The table in the view enlists the metrics data for Java Elements of some particular Java Elements Type. You can select this type in the drop-down list at the right of the toolbar:

The first column of the table displays the Java Elements. Each of the next columns displays the particular metric. The name of the metric is displayed at the top of column. For each Java Element there is the corresponding metric value which is displayed in the corresponding cell. If this value can't be evaluated, the cell contains the string n/a. You can sort the table by one of the metric columns. To sort by some metric simply click at the top of its column (at the place where the name of the metric is displayed). The down arrow will be displayed there indicating that the table is sorted by this metric in descending order. If you click at the top of the column again, down arrow will be changed to the up arrow and the table will be sorted in ascending order. If you click on the first column, Java Elements will be sorted in alphabetical order.

To reveal some Java Element in the source, double click on that element in the first column of the table. When you hover the mouse over the Java Element, the tooltip window will show the part of source code, which contain this Java Element.

Note: Not all of the Java Elements are displayed in the metrics table. Often the total number of Java Elements of some particular type available in the Working Set is quite big and only the part of them that has the highest/lowest metric values (according to the current sorting metric) is presented in the table. When you choose to sort the table by another metric, the different part of Java Elements is chosen to display.

The total number of Java Elements available in the Working Set can be tens of millions for some particular Java Elements Types. When you choose to sort the table by some metric, all of these Java Elements have to be processed. Therefore sometimes the sorting process can be quite long. Sorting process is launched when you click at some column to sort the table or change the current Java Elements Type. While the process is running, SourceGlider temporarily transitions to the phase Being Analyzed and all its views and features including Metrics View are temporarily disabled. You can determine that the sorting process is currently running by the state of the button on the toolbar. When it is enabled (it becomes red), the process is running. If you click at this button, sorting process will be cancelled. When the process finishes, the button becomes disabled.

Metrics Configure Dialog

You can configure which metrics have to appear at the columns of the table. To launch the Metrics Configure Dialog click at the Configure Metrics... hyperlink in the toolbar.

The list on the left corresponds to the metric columns of the table in Metrics View. The tree on the right displays all available metrics for current Java Elements Type. The tree resembles the queries hierarchy in Analysis Report and Query Tree views. Actually each metric is simply the number of answers for some particular Java Element Query except for Structure Metrics, where the metric is the answer for the Query. You can find the list of all available metrics in the Reference.

To change the metric for some particular column, select the corresponding position in the list at the left and choose the desired metric in the tree at the right. To add an extra column to the table press the button, to remove press button.

When you finish configuring the metrics, press OK button and the new metrics will appear at the corresponding columns. Note that if you change the metric that is currently the Sorting Metric (see above), the Metrics Sorting Process will be launched and SourceGlider will temporarily transition to the Being Analyzed phase. You can cancel this process by the button on the toolbar.

Each Java Elements Type remembers its set of metrics. Therefore if you once configured the metrics for some particular Java Elements Type, each time you choose this type in the Metrics View, your chosen metrics will be displayed in the table.

Folders Mode

Metrics View basically displays Java Elements from the entire Working Set. But if the current Java Elements Type is either Folders or Types, there is possibility to switch to the Folders Mode. In this case Metrics View displays only elements from the same folder that contains the currently selected Java Element. Folder is the special Java Elements Type that corresponds to the physical folder in the Eclipse file system. Each Java Element which has the type Types or Folders is located in some parent folder. When you switch to the Folders Mode, all other Java Elements from this parent folder are displayed in the table.

To switch to the Folders Mode, push the button on the toolbar. To return back to the plain mode, switch off this button.

You can navigate through the types and folders like in ordinary files browser. To move to the selected folder, double click on it. To move to the parent folder, click on the button on the toolbar. The root folder is the Eclipse workspace abstract folder which contains all the currently analyzed projects like the folders.

To illustrate the use of the Metrics View with the Folders Mode, imagine one practical task: you have the Java project and you want to look which parts of this project were last modified. SourceGlider has the special metric Structure Metric / Last modified, which is applicable for folders and types. Note that SourceGlider considers the last modified time of the folder as the maximum of the last modified times of all the recursive children of this folder. It is much more practical comparing with what you get, when you check the special 'last modified' attribute hooked on each folder by the file system. So when you see the last modified time of the analyzed project, you will actually get the latest last modified time of all the Compilation Units that were analyzed. Double click on the project and you will see which packages were modified recently. Click on the 'last modified' column to sort them. Click on the package that occurs at the top and you will see the last modified times for all its subpackages, and so on. Finally you will get the Compilation Unit that was modified at the latest time. Note that you could find such unit even simpler - switch back to the plain mode and choose the Types () as the current Java Elements Type. Sort the table by the last modified column and you will see the latest last modified Compilation Unit at the top of the table. You can find more tutorials on Metrics View in Source Analysis > Tutorials.