37

I'm looking for a tool to give me some code metrics (total LOCs, LOC/Class, # of external references/class, etc...).

Does anyone know a good eclipse plugin that could provide me some some code metrics?

Ben S
  • 68,394
  • 30
  • 171
  • 212

9 Answers9

28

CodePro AnalytiX originally form Instantiations is now free at Google:

http://code.google.com/javadevtools/download-codepro.html

kjwenger
  • 281
  • 1
  • 3
  • 2
22

here is one called Metrics.

edit:

i put together a short program for this screenshot in eclipse 3.3.1.1:

Edit 2
Metrics New version Thanks @mpartel for the link

Peter Perháč
  • 20,434
  • 21
  • 120
  • 152
akf
  • 38,619
  • 8
  • 86
  • 96
  • This looks kind of old. Their latest news: "New release for Eclipse 3.1 2005-07-08". – Ben S Jun 26 '09 at 02:46
  • just installed it at home on the mac. looks good on 3.3.1.1 – akf Jun 26 '09 at 03:10
  • 3
    I've been researching metrics plug-ins recently. Since this is the accepted answer, I wanted to point out to future readers looking for metrics plugins (like me) that a couple of the other answers mention 'metrics2'. The metrics2 project claims that metrics.sourceforge.net is discontinued, so metrics2 is intended to be a continuation of it. As of the writing of this comment, the last release was Jul 2010 and code was last committed as recently as 6 days ago. – Bert F Oct 20 '10 at 18:59
  • 13
    Metrics 2 home page: http://metrics2.sourceforge.net/ – mpartel Sep 29 '11 at 10:21
  • 2
    FYI: I can't get Metrics 2 to show up in a fresh install of Eclipse. It may or may not work anymore either. – Yamikuronue Jul 12 '12 at 18:30
  • Works for me on fresh Install - Dec 2012. Check that you've done the show views thing :-) Dear Eclipse when I install a plugin the odds are on I want the views shown and the thing enabled without my having to step through every menu ever. – Mark Levison Dec 17 '12 at 16:44
  • 1
    The screenshot is no longer hosted at Imageshack, please update! – Eric Tobias Jan 05 '15 at 12:32
  • 1
    metric 2 didn't work with eclipse mars – nofomopls May 25 '16 at 15:06
  • Metrics 2 works for me in Eclipse 26. Requires a manual install from their update site. See link above from @mpartel. – dan Apr 28 '23 at 16:58
17

Sorry for the necropost but it seems like the right thing to do since this was my starting point. Try Metrics2, its a fork of the original metrics plugin and is built for Eclipse 3.5.

ebt
  • 1,358
  • 1
  • 13
  • 18
3

If you want LOC only then use locmetric http://www.locmetrics.com/ . and if you want check metric and code coverage usse SONAR or Eclips CodePro Analytix plugin.

i suggest to use https://developers.google.com/java-dev-tools/codepro/doc/ it has Automated tools measure quality of Java source code and code coverage

kapil das
  • 2,061
  • 1
  • 28
  • 29
3

There is an updated version of the Metrics plug-in described above that should do what you need. It can aggregate some of the measurements (e.g. add up the LOC of classes in a package to give you the LOC of the package) and export the measurements to XML. Some time in the near future, it should also export them to a relational database.

kc2001
  • 5,008
  • 4
  • 51
  • 92
  • 1
    Metrics2 (ebt's answer) is the current name of the updated version of the Metrics plug-in. – kc2001 Jun 16 '11 at 19:09
2

A search for eclipse code+metrics turns up http://eclipse-metrics.sourceforge.net/, which looks good.

Jordan Stewart
  • 674
  • 6
  • 10
  • 1
    This is a snazzy one that creates warnings when the metrics start to show potential problems, but it doesn't seem to have a summary feature with overall stats. – Ben S Jun 26 '09 at 03:00
2

I also recommend the eclipse-metrics plugin.

It is capable of exporting the metrics into html, and is capable of doing this from an ant task (at least according to the documentation, I have never tried it).

The plugin works even in Eclipse 3.5 fine.

Zoltán Ujhelyi
  • 13,788
  • 2
  • 32
  • 37
1

Sonar seems worth to look at: http://docs.codehaus.org/display/SONAR/Installing+Sonar+in+Eclipse

cuh
  • 3,723
  • 4
  • 30
  • 47
0

Another good project is the projectusus, which shows you not only the metrics but also whether you are respecting the standards or not and gives you a hint of what should be refactored

iberbeu
  • 15,295
  • 5
  • 27
  • 48