I have been experimenting with the Metrics plugin for Eclipse from StateOfFlow and I am getting to like the idea of having my code quality analysed. Of course, not all the metrics are too clear to me, or useful, but from the wide range of various metrics the plugin provides (currently 14, by my count), I tend to take these seriously:
Method metrics: Cyclomatic complexity | Number of statements | Number of locals in scope | Number of levels
Class metrics: Number of fields | Weighted methods per class
To reduce this list even further, I really believe in McCabe's Cyclomatic Complexity measure and I find the number of statements also a quite useful indication of too much work being done in one place.
Of the rest of the metrics provided by the plugin, I find the ones from the Lack of cohesion in methods group rather difficult to understand. Today, I started with a little experiment of my own and after a couple of hours' coding I turned on the Metrics support for the project. 6/7 problems found were related to cohesion, one particularly surprising: Lack of Cohesion in Methods (Total Correlation) is 209%.
I find it hard to do anything about these: Chidamber and Kemerer | Henderson-Sellers | Total Correlation | Pairwise Field Irrelation. I am very tempted to raise the allowed maxima for these metrics, so they would stop appearing as Warnings.
I think having code metrics calculated on-the-fly provides a helpful guide to writing better code. I am glad you asked this question, as I would like to read more about how the others are using metrics to improve code quality.
By the way, I would welcome any recommendations of other (Eclipse) plugins you might have experience with. The one from StateOfFlow provides a nice way of exporting the metrics information in the form of HTML pages with graphs and tables, and also can export metrics to CSV files which you can then feed into whatever other utilities you may be using. I am enjoying the plugin so far :)