Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Track changes in code over time

I would like to collect some statistics of the code that we have in our TFS installation to be able to see how some aspects of the code changes over time. Basically I'd like to see if we learn something from the lessons about Clean Code and Refactoring that we got.

The report I'd like to see is:

  1. Changes in the average number of lines per method in solution between date1 and date2. (are we refactoring long methods)

  2. Changes in the average number of methods per class in solution between date1 and date2 (are we refactoring classes that do many things)

  3. Changes in the average number of usings per class in solution between date1 and date2 (are we limiting the dependences needed)

The report could a list of values that could be drawn as a line to show how the values changes over time.

I know there are API:s in TFS and that I can write it myself but I hope to get an answer that says I don't have to :-)

like image 301
Roland Avatar asked Apr 01 '12 18:04

Roland


1 Answers

Unfortunately, TFS doesn't explicitly track this data. It does track code churn (which you can read about here) but that will only tell you about the number of lines added, deleted and changed over time.

As you mentioned, you could do this via the TFS API. If you are going to look at doing that, you will probably want to start with the Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer.QueryHistory API. That will give you the list of changes that have happened to a file over time and from there you would need to build your own parsing and diffing logic.

Thanks, Taylor

like image 99
Taylor Lafrinere Avatar answered Oct 10 '22 12:10

Taylor Lafrinere