SLOC for Java projects

醉酒当歌 提交于 2019-12-03 10:38:39

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.

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.

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.

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.

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.

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

CodeFacts will give you line counts for the source and comments along with some stats on lines and class/method counts differences between two revisions. It's really a metrics tool though so it may be overkill for what you want.

If using NetBeans 8, download the TikiOne JaCoCoverage plugin and then run the code coverage test against your project. It will give you lines per package and total lines. It doesn't, however, differentiate between things like lines of code and lines of comments.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!