1

I am about to employ Checkstyle on a project to improve coding standards and discovered in my research that I can also setup Checkstyle to return some coding metrics as well as some other useful checks. However there seems to be a glaring omission, which is Lines of Code. I know its a horrible metric but I've been asked to produce it! Does anyone know if Checkstyle can return lines of code on the project and if so how?

Cheers

Ally
  • 1,476
  • 3
  • 19
  • 30

2 Answers2

0

Checkstyle calculates mutiple LOC-like metrics:

  • FileLength (com.puppycrawl.tools.checkstyle.checks.sizes) The default maximum is 2000.

  • ExecutableStatementCount and JavaNCSS, i.e., Non Commenting Source Statements. In a way, it is close to SLOC (source lines of code) or even better LLOC (logical lines of code). LLOC, ExecutableStatementCount and JavaNCSS are aware of the fact that one statement can be spread over multiple physical lines of code and that one physical line of code can contain multiple statements. JavaNCSS adheres to the specification for the JavaNCSS-Tool written by Chr. Clemens Lee. The specification can be found on http://www.kclee.de/clemens/java/javancss/#specification

Alexander Serebrenik
  • 3,567
  • 2
  • 16
  • 32
  • So how do you find the lines of code for a project using Checkstyle? – Felix Feb 26 '13 at 01:29
  • Checkstyle is a coding standards compliance tool, not a metrics display tool. Just as your ambulance nurses probably aren't the best suited to perform open heart surgery when they got you to the hospital, so Checkstyle passes the baton to tools like [Sonar](http://nemo.sonarqube.org/) for visualization. – Visionary Software Solutions Sep 05 '13 at 06:08
0

The HONEST answer is that Checkstyle simply doesn't offer LOC or LLOC. In fact, as far as I can see, no Eclipse Juno Plugin for Java offers this eminently useful feature. I wonder why so is that now . . .

Even very crude IDEs like GPS gives a full catalogue of all the usual metrics. It seems to say something about the people at IBM and Oracle.

Jimbo
  • 11
  • Aspersions aside, you're misunderstanding the point of the tool. Checkstyle internally calculates LOC as part of some of its analyses, but its main purpose is not to produce those metrics, hence it doesn't serialize its calculations. Try [Sonar](http://nemo.sonarqube.org/). – Visionary Software Solutions Sep 05 '13 at 06:34