Source code tools

Started by
8 comments, last by hagen 22 years, 2 months ago
Hi, Does anyone has/knows of any development tools that give you statistics of you code such as source code lines (without comments of curse) Thanks. /\ /__\ C.Z. Hagen
//__ C.Z. HagenI want to play with MetallicA!
Advertisement
If number of lines is all you want, write one!

If you want more functionality, tell us and we might be able to help. Versioning, merges, diffs, etc? CVS.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
Be very simple to make one. Search for a '';''. When this is found then search for a ''\n''. If both are found then that''s a line of code.

Then ++ lines;

- seb
hm... what if i write something like

// FIXME: doesn''t seem right; better use CUtilWorker?

Then it''ll count that. BUt how ofen do you put a ";" in a comment. And at the end of the day does it matter if it says "30,028 lines" instead of "30,017 lines"...

- seb
Just search for newlines. Then check to see if something other than whitespace was used in between both newline characters, and if it was increment the line count.
Depends on how accurate you want to get. We usually don''t include comments in our source lines of code (SLOC) counts.

With some of the methods listed here, comments would be counted or code that was commented out would be counted. If you''re talking about a couple of files, this difference might not matter, but when we run it on directories of files with totals of 50,000 lines of code, it matters.

We use something called CDOC, but I''m sure there has to be a lot of freeware out there that will do what you want. Some of those tools will also print out a call tree and other goodies.
If you use Visual C++, you can grab the Project Line Counter add in (and I also recommend WndTabs).

http://www.wndtabs.com/plc/

If you want more tools, there is one tool no Visual C++ user should be without and that is Visual Assist. Quite awesome.

http://www.wholetomato.com

-Mark
Perfect!
Thanks dude the PLC it is very good.


/\
/__\ C.Z. Hagen
//__ C.Z. HagenI want to play with MetallicA!
quote:Original post by BSXrider
Be very simple to make one. Search for a ';'. When this is found then search for a '\n'. If both are found then that's a line of code.

Then ++ lines;

- seb


How about if and while statements..... Anyway, try this.. Just cut and paste
// Don't come crying if this doesn't work but atleast it's a start...// No warranty whatsoever.. LineCounter.cpp#include <iostream.h>#include <fstream.h>void main (int argc, char *argv[]){	ifstream file;	if(argc !=2)	// Is there any command line argument. If not exit..	{		cout << "Usage: LineCounter 'filename'" << endl;		return;	}	file.open(argv[1], ios::in | ios::nocreate);		if(file.fail())	// File error. Display text and exit	{		cout << "File don't exist. Please check path and name!" << endl;		return;	}	char line[255];	// char buffer.. Just keep your lines shorter then 256 chars.. 	unsigned long lines = 0;  // For really big'n'nasty projects	while(!file.eof())	{		file.eatwhite();	// Get rid of all whitespace		file.getline(line,255,'\n');		if(line[0] != '/' && line[1] != '/')		{			lines++;		}	}	file.close();	// Don't forget to close the file	cout << "Number of lines: " << lines << endl;	// Wohaaaa!	return;}// Counted 32 lines in this source.. Guess it works   


Ehhrrmm.... 31 Lines.... sorry... And it only accepts C++ style comments......





Edited by - Rickmeister on February 1, 2002 8:55:38 PM

This topic is closed to new replies.

Advertisement