8

I'm trying to collect software code metrics in my Java project on every cycle of continuous integration. I'm interested mostly in size-related metrics like number of classes, number of methods, function points, lines of code, etc. I would like to get a summary report with these metrics in some XML file. Later I will use it in project report, or somehow else.

Is there any free open-source tool which I can integrate with Maven for this purpose?

yegor256
  • 102,010
  • 123
  • 446
  • 597
  • Function points? Good luck with automating that! http://en.wikipedia.org/wiki/Function_point – Pontus Gagge Oct 26 '10 at 16:12
  • Apparantly the software metrics community can compute function points from code metrics by so-called "backfiring", basically multiplying by a constant factor that empirically relates code metrics values to function points. Check out Capers Jones book: Applied Software Measurement http://www.amazon.com/gp/product/0071502440/ref=oss_product – Ira Baxter Nov 14 '10 at 18:23

3 Answers3

7

One good option is Sonar.

Its primary purpose is to manage technical debt, so it does a lot of things you don't need, but it provides really good metrics.

You can integrate it with Hudson or whatever other continuous integration system you are using.

Alan Geleynse
  • 24,821
  • 5
  • 46
  • 55
4

Take a look at the javancss-maven-plugin.

JavaNCSS is a source measurement suite for Java which produces quantity & complexity metrics for your java source code.

This plugin provides the capability to run the JavaNCSS tool on your Maven 2 project sources and produce an html report. Optionally you can fail the build whenever one of the metrics goes beyond a fixed limit.

Community
  • 1
  • 1
matt b
  • 138,234
  • 66
  • 282
  • 345
  • 2
    NCSS stands for "Non Commenting Source Statements". Took me a while to work out :) – dogbane Oct 26 '10 at 16:09
  • JavaNCSS is an old tool that doesn't handle correctly the syntax introduced by Java 1.5. `Sonar` is a far better alternative, and since 1.9 it bundles its own *JavaNCSS-like* tool, called `Sonar Squid`. – Romain Linsolas Oct 27 '10 at 06:44
  • @romaintaz Sonar is excellent but I'm not sure that you're right about JavaNCSS: [the homepage](http://www.kclee.de/clemens/java/javancss/) lists support for 1.5/generics syntax. – matt b Oct 27 '10 at 10:58
  • 1
    @matt_b Annotations and Generics are in fact **partially** supported. JavaNCSS does not handle nested classes. That's why I said that this tool is a not up to date. Have a look here: http://www.sonarsource.org/the_next_major_version_of_javancss_is_on_its_way/ – Romain Linsolas Oct 27 '10 at 11:21
1

I'll throw in XRadar which provides similar functionality to Sonar.

Philipp Jardas
  • 3,222
  • 3
  • 29
  • 42