tags:

views:

442

answers:

6

I neeed a free tool to count SLOC on a Java project. I only really need the following metrics:

  • SLOC
  • number of comment lines
  • optionally javadoc metrics
  • optionally sort statistics by file type (.java, .js, .css, .html, .xml, etc)

Bonus:

  • 100% Java, I don't like mix something like sloccount with cygwin
  • netbeans plugin
  • or preferably, maven plugin
+1  A: 

My advice is don't.

You get what you measure for.

If you reward big LOC, you'll get a lot of LOC.

If you reward small LOC, you'll get perl.

Will
Why do you think that he *rewards* big LOC? Reward is not the only usage of SLOC.
Rorick
"You get what you measure for" == reward, even if implicit.Everybody should go read what our hosts think about metrics :)
Will
This is "the" reference: *Tell me how [and when] you’ll measure me, and I’ll tell you how I’ll behave.* --Eliyahu M. Goldratt (The Goal). But nothing says the OP is measuring people here so I still do not agree with you.
Pascal Thivent
And here is another one: *If you cannot measure it, you cannot improve it.* --Lord Kelvin
Pascal Thivent
I'm not sure that our hosts are the last authority) There's a plenty of opinions.
Rorick
I'd take Joel over random programmer any day
Will
I think it's different if a dev measures for his own personal improvement vs. management measuring to make the the job of evaluation seem objective. (And also to make it easier)For personal observation and learning, I'm okay with it.Oh, and I'm a perl programmer! :-)
Matthew Heusser
+1  A: 

There is a maven plugin for JavaNCSS. There is also the JDepend plugin that generates some complexity metrics if you're interested in those.

Interestingly, the reason you're having trouble finding a decent plugin is because most people don't care enough to write one or don't find those metrics useful enough. Take that as you wish.

Kevin
+1  A: 

This is free (as in beer, not source sadly): http://www.campwoodsw.com/sourcemonitor.html

It's a bit rough around the edges, but does the job.

Paolo
Where in the world is that famous "free" beer. I still don't get where that phrase originated.
OscarRyz
@Oscar *"Free software" is a matter of liberty, not price. To understand the concept, you should think of "free" as in "free speech," not as in "free beer."* http://www.gnu.org/philosophy/free-sw.html
Pascal Thivent
@Pascal: Yeah I know that, but again, "as in free beer". What "free beer" everywhere I know the beer is not free at all :)
OscarRyz
@Oscar I misunderstood the initial question then. Anyway, the fact is that "free as in beer" has been adopted for gratis, even if beer is not gratis :) More at http://en.wikipedia.org/wiki/Gratis_versus_Libre
Pascal Thivent
@Reyes - you misunderstood, the idea is to promote free (libre) beer. Everywhere beer is kept locked in dark cellars or smoky bars - it wants to run free in the hills
Martin Beckett
+1  A: 

I used combination of RefactorIt browser and FreeMind (with some Groovy scripting) for semi-automatic generating of SLOC and Comments LOC metrics reports. RefactorIt can export metric in csv format, it is open source and pure Java. Unfortunately, it seems to be no longer developed. FreeMind is mind mapping software and I used it to generate mind map from that csv metrics report. I've done that mostly for fun, to be honest. You could build your solution upon these tools, though I doubt that it is the best way.

Rorick
+1  A: 

For an open source project, you can get SLOC measures as a side benefit of registering your project at http://ohloh.org

Stephen C
+6  A: 

Did you consider using Sonar (which uses its own internal tool since version 1.9, sonar-squid, instead of JavaNCSS which has some flaws and doesn't work well with Java 1.5 or 1.6 projects)? This is the kind of report you'll get:

alt text

Sonar does a lot more than just collecting SLOC though, maybe not what you want.

Pascal Thivent
+1, it looks promising :-)
dfa
accepted, it works like a charm. Thanks!
dfa
+1 Incredible thing!
Rorick
@Rorick @dfa Sonar is **the** qualimetry tool, it's just awesome.
Pascal Thivent