> 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`
> ....
> 4. Finally, you may want to strip comments from your code before
> generating change metrics.
For stripping comments, you have the irritating task of stripping them
from a copy of the before file. :-)
-bw will not catch changes in spacing _within_ literals
GNU diff also offers -B to ignore added or removed blank lines.
But no diff tool that is not "Ada-aware" will know that the following is not a
"change":
type Color_Code is (Black, Brown, Red, Orange, Yellow, Green, Blue,
Violet, Gray, White, Gold, Silver, None);
Description : constant String := Comp_Type'Image (Composition) & " "
Value_Image (Color_Array);
vs.
type Color_Code is
(Black, Brown, Red,
Orange, Yellow, Green,
Blue, Violet, Gray, White,
Gold, Silver, None);
Description : constant String :=
Comp_Type'Image (Composition) & " " Value_Image (Color_Array);
You can run before & after through the same "pretty-printer" but that runs
the risk of having neither file having the same line breaks.
If you take the diffs in "statements" instead of "lines," then you could
run a converter that puts each statement on one and only one line.
|