- 25 Jul 2008 -

I was recently tasked with finding out the number of methods in each class in each package inside of OpenMRS. My first thought was to write a java class to do some reflection. My second thought was to find a java class that someone else had written and use that. My third thought was to find a way for Eclipse to do it.

I really should have jumped to that last one first.  Googling for my second thought gave me nothing useful.  However, simply adding “eclipse” to my search term brought up the Metrics plugin as the first result!  The Metrics plugin counts all different types of things.  Lucky for me, “number of methods” just happens to be one of them.

To get the counts working for you, follow these easy steps:

  1. Add http://metrics.sourceforge.net/update to eclipse as a plugin update site
  2. Turn metrics on for your project:
    1. Right click on the root of your project in Package Explorer view
    2. Choose Properties–>Metrics–>Enable Metrics
  3. Do an Eclipse clean rebuild
  4. Click on the root of your project in the Package Explorer
  5. Open the “Metrics” view

These are the relevant statistics from the OpenMRS project:

The second api/web are from the test package.  We have a lot of work to do to catch our total number of unit test methods up with our number of api methods.

I’ve also uploaded the entire OpenMRS metrics output.

This is in the openmrs category tagged as , ,

Add a comment »

Leave a Comment




Your comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.