SourceForge.net Logo

Eclipse Metrics Plugin

This Eclipse plugin calculates various metrics for your code during build cycles and warns you, via the Problems view, of 'range violations' for each metric. This allows you to stay continuously aware of the health of your code base. You may also export the metrics to HTML for public display or to CSV format for further analysis.

Note that although metrics can be useful in a software development effort, they should not take the place of good taste and experience. Also, metrics are more useful as indicators of unhealthy code than they are as indicators of healthy code, i.e. a codebase with many range violation warnings is probably an indication that the code needs to be refactored but no range violation warnings does not necessarily mean that the code is good.

Using the Plugin

Download the latest version of the plugin, unzip it into your plugins directory and (re)start Eclipse.

Enabling / Disabling

The metric plugin is enabled and disabled per Java project. In any Java Perspective, open the project's Properties. Select the 'Metrics' tab and check or uncheck the 'Enable Metrics Gathering' checkbox. Clicking 'OK' now causes the project to recompile (assuming your preferences are set up to perform automatic builds) and metrics will be recalculated. If any metrics are out of range, warnings will be added to the Task List and the code will also be marked up as usual.

Exporting Metrics in HTML or CSV Format

To export the metrics for a project, pop up the context sensitive menu on any resource in the project and select 'Export...'. Choose the 'Metrics' export wizard and select the directory you want to export to and the export formats you require. Click 'OK'.

When exporting HTML, you can elect to create a histogram for each metric (this appears to work only on Windows). The appropriate metric's histogram will be displayed on each page.

Metrics do not have to be enabled on the project in order to export.

Excluding Java Files

If you have Java files for which you do not want to have metrics calculated, you can exclude them. To do this, open the project's Properties in any Java Perspective and select the 'Metrics' tab. You can either choose the files to ignore by browsing the file system -- press 'Add Files...' -- or you can enter a Perl5 regular expression that matches the file path -- press 'Add Regex...'.

Regular expressions are particularly useful when you have a naming convention for classes such as Mocks, Visitors, Mementos, etc. As an example, if you want to exclude all classes with 'Mock' in the path , you could specify the regex ".*Mock.*".

Setting Preferences

Open the Window/Preferences dialog and select the 'Metrics' tab. You can now:

Once the preferences have been set, clicking 'Apply' or 'OK' causes the project to recompile (assuming your preferences are set up to perform automatic builds) and metrics will be calculated. If any metrics are out of range, warnings will be added to the Problems list and the code will also be marked up as usual.

Supported Metrics

Bugs

Please report bugs on Sourceforge.

Author

Lance Walton for State Of Flow