您将如何测量插入/更改/删除的代码行(LoC)? [英] How would you measure inserted / changed / removed code lines (LoC)?

查看:167
本文介绍了您将如何测量插入/更改/删除的代码行(LoC)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题涉及到LoC指标。我必须提供插入,更改和删除行的统计信息。我的用户使用ClearCase和基于它的例子,但是我相信我的问题是一般的。



请看下面的例子(摘自ClearCase文档) 。它比较两个文件版本, / main / 1 (在左侧)和 / main / 3 (右侧)。


  ***************** ***************(文件摘要)
<<<文件1:util.c @@ / main / 1
>>>文件2:util.c @@ / main / 3
********************************
---------- [15后] ------ | ------- [插入16] ------(头)
| char * s; (区别)
| -
--------- [改为18] ----- | ---- [改为19-21] ----(首标)
返回ctime(& clock); | s = ctime(& clock); (差异)
- | s [strlen(s)-1] ='\0';
|返回s;
| -


毫无疑问,1行是INSERTED(第16行)。



我的问题涉及第18行的更改:您在此计算多少行?


  • 3 CHANGED行?

  • 1 CHANGED行吗?

  • 1 CHANGED行和2个INSERTED行?

  • ...?



请让我知道您的想法(以及为什么...)。谢谢。

解决方案

这个例子来自 cleartool diff man page ,diff是不是通常的 diff格式



对于ClearCase:

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




改变了一行或多行。


  • X表示第一个文件中的哪些行被更改。

  • Y表示替换行出现在第二个文件中的位置。

所以在这里:


  • 1行更改

  • 由3行代替
  • >


与其他工具(如git)使用的diff统一格式没有直接的关系,这意味着这个问题,使用默认的cleartool格式,特定于ClearCase。



如果cleartool diff使用 -diff_format 选项,这会导致头文件和差异文件以UNIX和Linux diff实用程序的风格报告,这会让diff更常见的解释。 b
$ b

对于LOC和diff,一个很好的参考是 CLOC a> ,它将提供 差异loc ,重点关注线w hic是:
$ b


  • 相同

  • 已修改

  • 已添加

  • 已删除



  • 您的情况:


    • 1行修改

    • 添加了2行


    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.

    解决方案

    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

    这篇关于您将如何测量插入/更改/删除的代码行(LoC)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆