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. 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.
To start collecting metrics for a project, right click on the project and from the popup menu select "Metrics->Enable" (or alternatively, use the properties page ). This will tell Eclipse to calculate metrics every time a compile happens.
So how we check the cyclomatic complexity of those projects? Not an IDE plugin, but SonarQube is pretty useful for static code analysis that includes cyclomatic complexity. Sonar has an Eclipse plugin called SonarLint that also tells if the cyclomatic complexity is too hight.
Metrics2 is an updated version of the Metrics plug-in described by js3v that should do what you need. It can also aggregate some of the measurements (e.g. add up the LOC of classes in a package to give you the LOC of the package). 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. Besides logical lines of code, it will also compute cyclomatic and N-path complexity (which may be a better indicator of code problems).
While I don't know if it will generate a report on every module, you might try setting the threshold very low, (like 2). Checkstyle should give you a yellow highlight at the start of every method, telling you how many lines of code it found.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With