Question

My question concerns LoC metrics. I have to provide statistics of inserted, changed and removed lines. My users use ClearCase and the example below based on it, however I believe that my question is general.

Please have a look on the following example (taken from ClearCase documents). It compares two file versions, /main/1 (on the left side) and /main/3 (right side).

    ******************************** (file summary) 
    <<< file 1: util.c@@/main/1
    >>> file 2: util.c@@/main/3
    ********************************
    ----------[after 15]------|-------[inserted 16]------ (header) 
                              | char *s;        (difference) 
                              |-
    ---------[changed 18]-----|----[changed to 19-21]---- (header) 
    return ctime(&clock);     | s = ctime(&clock); (difference) 
                           -  | s[ strlen(s)-1 ] = '\0';
                              | return s;
                              |-

There's no doubt that 1 line was INSERTED (line 16).

My question refers to the change on line 18: how many lines do you count here?

  • 3 CHANGED lines?
  • 1 CHANGED line?
  • 1 CHANGED line and 2 INSERTED lines?
  • Do you think something else...?

Please let me know what you think about (and why...). Thank you.

Was it helpful?

Solution

This example is from the cleartool diff man page, and that diff is not your usual diff format.

For ClearCase:

---------[changed X]----------|----------[changed to Y]---------

One or more lines changed in place.

  • X indicates which lines in the first file were changed.
  • Y indicates where the replacement lines occur in the second file.

So here:

  • 1 line changed
  • replaced by 3 lines

There is no direct equivalent with the diff unified format used by the other tools (like git), which means this question, using the default cleartool format, is specific to ClearCase.

If the cleartool diff used the -diff_format option, that would causes both the headers and differences to be reported in the style of the UNIX and Linux diff utility, which would let a more common interpretation of that diff.


Whe it comes to LOC and diff, a good reference is CLOC, which will give a diff loc focusing on lines whic are:

  • same
  • modified
  • added
  • removed

In your case:

  • 1 line modified
  • 2 lines added

OTHER TIPS

Most SCM systems let you scan files as they are submitted as part of a pre- or post- commit hook. You could run any scanning tool you like and record the statistics somewhere, perhaps as an attribute on the file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top