SPLevo/Metrics View
The SPLevo Metrics View is a small helper to calculate metrics about one or more selected items. Out of the box, it provides the number of lines and the number of non-empty lines of selected files.
Installation
You can get the SPLevo Metrics View from the according Update Site http://sdqweb.ipd.kit.edu/eclipse/splevo/nightly/
Just install via "Help -> Install new software..." and open the view by "Window -> Show View -> Other -> SPLevo -> SPLevo Common Metrics View".
Usage
Then simply select one or more files and see the results in the overview table or in the raw textual output view. You can switch between them using the tabs at the bottom of the view.
Calculators
In the following section the calculators are explained. All caluclators have recursive directory support enabled, meaning that if a folder or project is chosen, the results are computed for all subfiles.
Lines-of-Code Calculator
The Lines-of-Code Calculator returns the total number of lines and the lines that are not empty.
QVTO-Calculator
The QVTO-Calculator returns metrics specific for .qvto files. It returns the number of helpers, queries and mappings.
Preprocessor Calculator
The Preprocessor Calculator returns the number of preprocessor statements used in a file. It works for c-style files like .c, .cpp, etc. and also for java files. Information about the java preprocessor style can be found here: http://www.slashdev.ca/javapp/
Java Metric Calculator
The Java Metric Calculator returns java specific metrics. For now it supports
- Number of Classes
- Number of Methods
- Number of Packages (if you select the project root)
- Number of inner Classes
To compute these statistics the calculator makes use of the Eclipse Java Model. More information about the Java Model (and the AST) can be found here: http://www.vogella.com/articles/EclipseJDT/article.html
If you want to add more java specific metrics, this would be the place.
Generic Calculator
The Generic Calculator can be specified via a preferences page. It checks whether a line of code starts with the metric that was entered in the pref page. If you enter multiple metrics, you have to separate them by comma. Note: The string is split by comma so do not enter a white space after the comma if this is not your metric.
Example:
correct:
"private,public" -> {[private], [public]}
probably wrong:
"private, public" ->{[private][ public]}
The calculation of the metrics can be enabled and disabled over the preferences page and via a button in tool box menu. Those buttons are synchronized.
The representation of the complete results is displayed in a table format. It was started with a graph representation that currently only works for the LoC-Calculator.
For the graph representation the BIRT Engine is used. The code for creating the chart can be found in BarChartGenerator. The chart is updated in the same way the table layout is: When the selection changes, the result gets recomputed and displayed in both forms.
Outlook
When the metrics are calculated for very large projects, it might be that the there are some performance issues. Another important point is the completion if the graphical user interface, meaning the chart representation.
Metrics Extension Point
The metrics view provides an extension point to add custom metrics for selected objects.
The id of the extension point is org.splevo.utilities.metrics.calculator
and it has to specify a calculator with a class implementing the MetricsCalculator interface:
<plugin>
<extension
point="org.splevo.utilities.metrics.calculator">
<calculator
calculator.class="org.splevo.utilities.metrics.MyCalculator">
</calculator>
</extension>
</plugin>
The class diagram shows the class structure for a metrics calculator extension. A calculator has to implement the MetricsCalculator interface. The interface returns the calculators id and provides a method to calculate a MetricResultSet. The MetricResultSet itself contains a list of MetricResultItems which again contain the metrics for a single selected item.
The metrics caclulator view plugin provides default implementations for a MetricResultSet and a MetricResultItem.
Development
For the metrics view, the same coding guidelines apply as for the overall SPLevo project: SPLevo/Development.
Issues for the metrics view are tracked in the utilities component of the SPLevo project in JIRA: https://sdqbuild.ipd.kit.edu/jira/browse/SPLEVO/component/10600
Resources
Subversion Code Repository:
https://svnserver.informatik.kit.edu/i43/svn/code/SPLevo/Core/trunk/Utilities/org.splevo.utilities.metrics/
user: anonymous
password: anonymous