2

Given two project versions, I would like to calculate code churn metrics.

EXAMPLE:

Input: Two folders containing C and Header files of two versions of the project


Output: List of number of lines added/changed/removed in each file

I tried some tools, namely, BeyondCompare and WinMerge. The problem was, the first required that the all files would be in the same directory, otherwise you can only compare them but get no metrics, the second was mainly a visualization tool, didn't give me metrics either.

Muath
  • 4,351
  • 12
  • 42
  • 69
Nader Alexan
  • 2,127
  • 22
  • 36

3 Answers3

2

One of the tools you might consider is WebDiff

Alexander Serebrenik
  • 3,567
  • 2
  • 16
  • 32
1

For .NET code such task can be achieved through a NDepend Code Query LINQ (CQLinq) query such as (notice how you can choose code metrics):

from t in JustMyCode.Types
where t.IsPresentInBothBuilds() &&
      t.CodeWasChanged() // Only match types where code has been changed 
                         // between the two versions
let tOld = t.OlderVersion()
select new { t,
  newLoc = t.NbLinesOfCode,
  oldLoc = tOld.NbLinesOfCode,
  newNbMethods =t.Methods.Count(),
  oldNbMethods =t.Methods.Count(),
  newNbFields =t.Fields.Count(),
  oldNbFields =t.Fields.Count(),
}

enter image description here

Patrick from NDepend team
  • 13,237
  • 6
  • 61
  • 92
0

Are your versions stored in a version control system (e.g., SVN, Git)? If yes, then you can compute your churn metrics by looking at the version control system log (which already gives lines added/changed/removed), even if the two versions are not consecutive commits.

Bogdan Vasilescu
  • 407
  • 4
  • 22