Search code examples
metricscheckstylecode-metrics

Can Checkstyle return lines of code for a project


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


Solution

  • 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