I'm looking for reporting tools for TFS, I need to get Lines of Code for individual developer between 2 dates, do you think it is doable via TFS?
Asked
Active
Viewed 2.0k times
14
-
2This is quite a hard problem, since a "line of code" could be anything from a single character change to a full inserted line. Also, would you count a line that is added in one changeset and removed in another as two lines edited, or one, or zero? – Dan Puzey Mar 11 '13 at 14:56
-
7Lines of code (sloc) are VERY misleading. A good developer may think more and write less and a sloppy one can just machine-gun code at 200 wpm and chances are the more the code - the worse it works and harder to maintain. In one occasion I had to rework a sloppy piece of code and shrunk their 10000+ lines of code to about 1500. Unless you combine *somehow* functionality delivered and divide that by sloc you'd be doing it wrong – Sten Petrov Mar 11 '13 at 14:56
-
If you can get just the code changes produced by the individual developer (not the entire source file, just the lines that were changed) you can then do a global search for line endings (usually '\n'). I have to reiterate what others have said - LoC is a mostly worthless metric. – Dan Pichelman Mar 11 '13 at 15:27
-
Lets hope he hasn't "tabified" or "untabified" some pages as they will all count towards the total number of lines. Personally, I think any value that you're looking for in number of lines, is probably completely invaluable in reality and provides a very poor metric of measuring anything other than "Number of lines altered". If you want this to measure productivity, then I'd look for another metric. – gregpakes Mar 11 '13 at 16:36
-
2There is a field in the analysis cube called `Total Churn` which can be filtered by person and date. Again, I'm not 100% how this is counted. Also, the issues both Dans, Sten, and discens provided are true and I agree with them about using code churn as a metric to gauge people on is quite horrendous. – James Tupper Mar 11 '13 at 20:59
3 Answers
19
This is how I get lines of code for TFS/Visual Studio projects:
- Open solution
- Open window: View -> Other Windows -> Code Metrics Results
- Run metrics: Click the icon at the top left - Calculate Code Metrics for Solution
- Metrics collected
- Has Lines of Code column

The Des
- 41
- 8

Robert J. Good
- 1,307
- 10
- 8
-
Does Code Metrics take into account form.Designer.cs code when calculating Lines of Code? – John Grabanski Oct 10 '16 at 16:50
-
1In case anyone is wondering about the above, [Code Metrics **does** include Windows Forms designer code](https://msdn.microsoft.com/en-us/library/bb385914.aspx) - _"Code generated for Windows forms is not ignored, because it is code that the developer can see and change."_ – stuartd Jan 20 '17 at 10:51
-
Code Metrics in VS does not support by-programmer...would need SCM like VSTS, GitHub, etc. A less-than-perfect solution is to: 1. Run metrics before the programmer's code contribution. 2. Run metrics after the programmer's code contribution. 3. Compare LoC differences. – Robert J. Good May 10 '18 at 22:40
7
I did it once per Management request. This may not be the perfect solution but it works. I reported LOC added for a TFS branch. I'm attaching TFS cube screenshot from old version (TFS 2008) since TFS version is missing here. I'm sure new version will be similar.

Manish Jain
- 9,569
- 5
- 39
- 44
-
Do note that this code churn view (still present in 2015) does not distinguish between code you wrote for a feature, and code that was "created by you" as part of a branching operation or any other type of bulk movement. – StingyJack Apr 16 '18 at 23:41
0
Option 2:
- Open Solution.
- Select "Analyze" on the toolbar.
- Click Calculate Code Metrics.
- If you have clicked on a file, it will allow you to calculate for the file, otherwise, select "For solution"
Option 3:
- Open Solution.
- In the Solution Explorer window, right click on the solution and select "Calculate code metrics"
- This again will generate the metrics in the "Code Metrics Results" window.

The Des
- 41
- 8