views:

655

answers:

5

I have been tasked with figuring out how many lines of code I've written this year. Not very exciting for a number of reasons, but it seems like it could make a nice SO question.

So in your favorite version control tool, how do you tell how many lines of code have been modified? In my particular answer blank lines and comments happen to count to simplify the time allotted to determining the answer, but feel free to elaborate.

In my particular case I'm using svn, so I'm going to get rid of all the --- and other misc output that svn log and svn diff output.

+16  A: 

I'd just try and get an idea of what management thought would be good, then tell them a number that is way bigger than that. You can spend the rest of the week reading Dilbert.

rikh
Excellent advice that fits exactly the usefulness of such a metric! I'd give it a +10 if I could.
sbi
After you reach the 'way bigger' number multiply by 10 just in case someone else in your office reads the above answer
somacore
I only wish that I could do this.
Nathan Feger
Unless your management wants a small number, in which case you should tell them a number lower than the specified threshold.
William Pursell
Tip from experience - make a note of what you said so that next time they ask you it's not unfeasably different!
Phil Nash
Now go and apply somacore's hint to itself recursively.
sbi
+6  A: 

Use StatSVN. I use it at work and it's great, it'll break down LOC by developer by month. It'll draw pretty graphs, tell you what day of the week and what time you check in the most code. It'll tell you exactly what you need to know.

FigBug
I'm running it now, I'm not sure how it deals with branches though.
Nathan Feger
@Nathan: I just tried it. By default, it will count branched off code as if it was typed. But from what I saw it seems to be possible to have it disregard branches completely. Then only code that got merged into the trunk would show up. But I have only very quickly browsed through the docs...
sbi
+1  A: 

Fisheye can tell you how many lines of code were committed per developer. There is a nice charting feature that can give you pretty graphs for this.

Taylor Leese
+1  A: 

In Clearcase, take the config spec and add:

time  <date-time>
<rules for choosing branches or labels>
end time

Make a second view, and compare the two. If multiple developers are working on the same files, I have no clue. I can't say I'm thrilled by using Clearcase, ever.

Dean J
A: 

If you are using subversion you can use the svn log command with the --xml switch and you can pull the lines of code from there. You can see the options of svn log using svn help log. Since your output is xml you can run through this xml and aggregate your line counts in code and go from there.

Michael Mann