简体   繁体   English

Eclipse插件,用于测量代码行

[英]Eclipse plugin for measuring lines of code

I'm running Eclipse Helios (3.6) and was wondering if there is a nice plugin out there that will count the number of logical lines of code in a java source file. 我正在运行Eclipse Helios(3.6),想知道是否有一个不错的插件来计算Java源文件中逻辑代码的行数。 By logical, I mean 逻辑上,我的意思是

if (j > 6) {
   j--;
}

In other words, 2 logical lines of code (2 statements) will be counted instead of 3 physical lines of code. 换句话说,将计算2条逻辑代码行(2条语句),而不是3条物理代码行。

Metrics2 is an updated version of the Metrics plug-in described by js3v that should do what you need. Metrics2是js3v描述的Metrics插件的更新版本,可以满足您的需求。 It can also aggregate some of the measurements (eg add up the LOC of classes in a package to give you the LOC of the package). 它还可以汇总一些度量(例如,将包中的类的LOC加起来以提供包的LOC)。 This page explains some of its capabilities and mentions that it counts logical lines of code, not physical ones. 页面解释了其某些功能,并提到它计算的是逻辑代码行,而不是物理代码行。

I have been using checkstyle-cs , a free Eclipse plug-in. 我一直在使用免费的Eclipse插件checkstyle-cs Besides logical lines of code, it will also compute cyclomatic and N-path complexity (which may be a better indicator of code problems). 除了逻辑代码行之外,它还将计算循环和N路径复杂度(这可能是代码问题的更好指示)。

While I don't know if it will generate a report on every module, you might try setting the threshold very low, (like 2). 虽然我不知道它是否会在每个模块上生成报告,但是您可以尝试将阈值设置得很低(如2)。 Checkstyle should give you a yellow highlight at the start of every method, telling you how many lines of code it found. Checkstyle应该在每种方法的开头都以黄色突出显示,告诉您找到了多少行代码。

Incidentally, there was some disagreement on our team as to whether 顺便说一句,我们的团队在是否

a[i++] = 7;

was one statement or two. 是一两个陈述。 There was no disagreement that 没有分歧,

a[i] = 7;
i++; 

counted as two statements. 算作两个陈述。

Here's one that I've used... works pretty well. 这是我用过的一个……效果很好。 http://sourceforge.net/projects/metrics/ http://sourceforge.net/projects/metrics/

ProjectCodeMeter can be integrated as eclipse external metrics tool, counts many source code metrics such as logical lines of code, complexity, arithmetic intricacy, strings, numeric constants, even estimates development time in hours. ProjectCodeMeter可以集成为Eclipse外部度量工具,可以计数许多源代码度量,例如代码的逻辑行,复杂性,算术复杂度,字符串,数字常数,甚至可以估算开发时间(以小时为单位)。

Look at the "integrating into eclipse" section (about half way through the page) 查看“整合到日食”部分(大约在页面的一半)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM