Tools to count lines of code

I’ve been asked to give a report about the number of lines of codes (SLOC) in a project in order to evaluate its complexity. I’m not a big fan of this metric (but that’s a whole discussion in itself), and I was too lazy to write a grep command or python script to do the job. I found several tools, and two of them emerged out of the crowd :


Really nice command line tool. Extremely fast, many options available, easy to use in a script to collect the stats on a regular basis. Unfortunately, I was particularly interested in the –list-file option, which allows you to specify a file with all the directories and files to take into account/ignore. I needed this option to collect stats for several programs sharing some code, while excluding some external dependencies code. Unfortunately, it never worked. Whn using this option, CLOC 1.6 for Windows always failed with error :

make_file_list(workspace/telium2/EPayKit/PaymentEngineTeliumDesjApp/src/main/c /
EnginePlatformResManager.cpp) undef size at c:\Program Files\Cloc\cloc-1.60.exe
line 2928.

But if you don’t need the –list-file option, CLOC is a great little tool.

Code Analyzer
Code Analyzer was my second choice, but eventually, it’s the one which did the job. I wasn’t initially fond of it, because it’s not a command line tool but a graphical app (but not sure command li
ne mode doesn’t exist), and it’s way slower than CLOC. But it gave proper stats, offered all the options I needed to include different folders while excluding some subfolders. That’ll be my best choice if ever I have to do this kind of thing again.


Leave a Reply

Your email address will not be published. Required fields are marked *