Hi,
Do any of you know of a program that will create statistics on the code of a projet?
I mean, like the number of lines in each file, the comment and actual code there is...
I would need to run on GNU/Linux.
Printable View
Hi,
Do any of you know of a program that will create statistics on the code of a projet?
I mean, like the number of lines in each file, the comment and actual code there is...
I would need to run on GNU/Linux.
Not meaning to sound like a smartass or anything, but what about just writing your own utility to do this? You should already have wc to give you a line count, but it should not be overly difficult to write a modified version that parses out commented lines and the like.
~/
I have been thinking of writing my own tool, and might end up doing so anyway, but I though that any tool that is already written would have already gotten rid of a lot of bugs I'd introduce. I'll give it a try, but suggestions of already-written software are still wellcome.
I guess you're only considering using // style comments? How would you count something like if(a) /* Is a true? */
is that a comment line or a code line?
you would just say something like
If the line starts with a / then dont count it
befcause
if(a) /*my coment blah blah*/
is still one line of code, but
// my comment
if(a)
it wont count the first and itll just be one line :)
What about this?
There are lots of different things to consider.Code:int x = 0; /* a comment.. lalalala
some more stuff...
*/ x = 5;
The field of dreams
http://www.chris-lott.org/resources/cmetrics/
If you write it, they will run it.
That's precisely why I was searching for something that had already all of this sorted out. The first line could be counted as `composite' and added to the count of both. The second line would just be a comment line and the third would be composite again.Quote:
Originally Posted by Spitball
Of course, now I have to sort out how I'm souposed to recognize that, but that's another story.
The program I made last night can already count the total number of lines, but I'm fighting to get it to count the blank ones for some reason.
EDIT:
Tried c_count from the link salem posted. It's good, but I still see a line-counting bug I fixed in my app. The last line doesn't contain a \n character and so it doesn't count it.
well couldnt you search for a "//" or a "/*" and if you find a "/*" search until you find a "*/" and what ever is in between those you count (or dont count depending on what you want to do with it).
The way I'm making it, there are different functions that control each count. A count for total lines is one function and updates one counter, a comment-counter updates another counter. None of these functions have any knowledge of what happens with the other counters.Quote:
Originally Posted by DeepFyre
An exception may have to be the comment- and code-counter, since the code-counter needs to know what a comment is, so I may do it all in one function.
Then comes the problem of wether to count blank lines inside comments as blank lines or not count them at all. Of course I could also count the lines of code and then take that number from the total lines.
I'll try to tacke a few of these problems a bit later on. I'm trying to build PlaneShift (man, what a load of dependencies!) right now and need to eat a bit as well.
Lies, Damned Lies and Statistics!
Sure you're measuring something - but what exactly?
I mean, if you're doing this in a production environment, it won't take too long for all the engineers to figure out how to write their code to make the "statistics" look "good". But simple statistics like this tell you nothing about the quality of the code in the file.
I'm just curious about how much code I've written in a particular project. There's no production enviroment and I'm not going to argue that a project is better than anotehr just because there's more code.Quote:
Originally Posted by Salem
Once you've calibrated it to your style of writing (say 20% of your source lines are blank or comment lines), then it's simple and quick, and probably not too far off any other answer you can come up with.Code:wc *.[ch]
Yes, but it's still a chalenge to write a program to do this. wc still gives a useful result, since most of those lines do something useful (comments are also useful)
Thanks, it's nice, but unless it's in C#, I don't know how you expect me to run it on Linux.
Oh, not really, didn't see that you wanted this on linux. Sorry.