SLOC for Java projects

dfa picture dfa · Feb 2, 2010 · Viewed 9.2k times · Source

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

Answer

Pascal Thivent picture Pascal Thivent · Feb 2, 2010

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 http://sonar.codehaus.org/wp-content/uploads/2009/05/sonar-squid.jpg

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