Lines Of Code in Team foundation server
Asked Answered
B

3

14

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?

Bimah answered 11/3, 2013 at 14:50 Comment(5)
This 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?Liddy
Lines 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 wrongRoer
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.Pegpega
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.Erasme
There 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.Viceregent
N
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.

enter image description here

Naara answered 8/10, 2013 at 23:55 Comment(1)
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.Berwick
V
19

This is how I get lines of code for TFS/Visual Studio projects:

  1. Open solution
  2. Open window: View -> Other Windows -> Code Metrics Results
  3. Run metrics: Click the icon at the top left - Calculate Code Metrics for Solution
    • Metrics collected
    • Has Lines of Code column
Virginiavirginie answered 29/10, 2015 at 18:10 Comment(3)
Does Code Metrics take into account form.Designer.cs code when calculating Lines of Code?Primula
In case anyone is wondering about the above, Code Metrics does include Windows Forms designer code - "Code generated for Windows forms is not ignored, because it is code that the developer can see and change."Monseigneur
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.Virginiavirginie
N
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.

enter image description here

Naara answered 8/10, 2013 at 23:55 Comment(1)
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.Berwick
D
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.
Dallasdalli answered 8/8, 2018 at 10:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.