Wednesday, June 20, 2012

CLOC - Count Lines of source code

Hello readers, Recently i came to know about a tool which is very powerful and provides lots of details about your source code. It supports many languages including c,c++,scripting,xml,sql  etc.

The tool is "CLOC" which stands for 'Count Lines Of Code'.

Lets see how to download, how to use it with an example.

1. CLOC overview:

The following overview is taken from official website.

'cloc counts blank lines, comment lines, and physical lines of source code in many programming languages. Given two versions of a code base, cloc can compute differences in blank, comment, and source lines. It is written entirely in Perl with no dependencies outside the standard distribution of Perl v5.6 and higher (code from some external modules is embedded within cloc) and so is quite portable. cloc is known to run on many flavors of Linux, Mac OS X, AIX, Solaris, IRIX, z/OS, and Windows. (To run the Perl source version of cloc on Windows one needs ActiveState Perl 5.6.1 or higher, Cygwin, or MobaXTerm with the Perl plug-in installed. Alternatively one can use the Windows binary of cloc generated with perl2exe to run on Windows computers that have neither Perl nor Cygwin.)'




2. How to download
To download perl version of cloc tool, click the link below

3. How to use

Use above link to download './cloc-1.56.pl' perm version of cloc tool. Make sure that you enable execution permission on cloc-1.56.pl file using 'chmod u+x cloc-1.56.plcommand.

If your source code is located in directory 'project_code'
You just need to run following command.


cloc # ./cloc-1.56.pl project_code/



cloc output

In the above out put, you can see that your project source contains files of different languages , c,c++,Shell,SQL and xml. It shows number of file, blank lines, comment lines(langues specific) and code lines.

Please read the help page of cloc tool for more features.

More details about 'cloc' can be found at http://cloc.sourceforge.net/
Thanks. Please share the post.
Pin It
Related Posts Plugin for WordPress, Blogger...