Archived

This topic is now archived and is closed to further replies.

Source code tools

This topic is 5829 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
hm... what if i write something like

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites