At 10:06 AM 5/27/99 -0600, [log in to unmask] wrote:
>Our process group in its infinite stupidity has dictated that we now
>provide lines of code for changes, but we must also provide new lines
>vs changes lines, and of course did not provide any kind of tool that
>would do this. My present project is a very Ada program which seems
>to always be changing. Is there any kind of tool that would work on
>a PC, SUN, or VAX that could provide the numbers or are we destined
>to try to do this by hand?
As John Woodruff previously replied, you can do this with diff.
I have a few comments on source code volatility metrics:
1. IEEE Std 1045 Annex D (as well as other software standards)
defines two ways of counting changed lines of code:
-- basic (new, deleted, reused)
-- detailed (added, removed, modified, reused)
It is possible to compute the basic counts from the detailed
counts, but not vice versa. As long as you're collecting data
you may as well collect the detailed change counts.
2. Use context diff to collect detailed change counts:
diff -cbw file.old file.new > file.diff
added = `grep "^+ " file.diff | wc -l`
removed = `grep "^- " file.diff | wc -l`
modified = `grep "^! " file.diff | wc -l`
(Doing this from memory, so above may have an error.)
Reused lines may be computed as:
reused = size of file.new - added - modified
reused = size of file.old - removed - modified
3. Diff doesn't always find the minimal set of file differences.
You can reduce these differences by telling diff to be careful.
Otherwise, diff may inflate your source code volatility metric.
Check you diff man pages to see if there is "slow but sure"
flag (for GNU diff the -d flag produces minimal set of file
4. Finally, you may want to strip comments from your code before
generating change metrics.
Joseph P Vlietstra [log in to unmask]
Aerojet Electronic Systems [log in to unmask]
1100 West Hollyvale Street (626) 812-2865
Azusa, CA 91702