【问题标题】:Line of code statistics with out comments没有注释的代码行统计
【发布时间】:2013-07-10 10:11:34
【问题描述】:

我正在尝试获取我的 xcode 代码的代码行统计信息。为此,我在终端中执行了以下命令以获取所有可能的代码。

find . "(" -name "*.m" -or -name "*.mm" -or -name "*.cpp" -or -name "*.h" -or -name "*.xml" ")" -print0 | xargs -0 wc -l | sort

它还为我提供了包括 cmets 在内的代码行数。谁能告诉我如何在没有 cmets 的情况下获取代码行统计信息。

【问题讨论】:

    标签: xcode shell lines-of-code


    【解决方案1】:

    考虑使用cloc,它会给你一个很好的输出,比如:

    7892 text files.
    4289 unique files.                                          
    9574 files ignored.
    
    http://cloc.sourceforge.net v 1.56  T=58.0 s (43.9 files/s, 7442.5 lines/s)
    --------------------------------------------------------------------------------
    Language                      files          blank        comment           code
    --------------------------------------------------------------------------------
    Objective C                     872          44323          20568         198133
    HTML                             34           1032              8          76432
    C/C++ Header                    908          16427          35415          19872
    D                               684              0              0           8299
    C                                 8            889            534           4040
    MUMPS                             3            618              0           2781
    Bourne Shell                     18            175            327            622
    Ruby                              2             87             15            380
    XML                              10              0              0            264
    CSS                               1             41              8            219
    Python                            1              9             16             41
    Objective C++                     2             15             12             26
    Bourne Again Shell                1              4              4             10
    YAML                              1              0              0              9
    make                              1              2              0              7
    --------------------------------------------------------------------------------
    SUM:                           2546          63622          56907         311135
    --------------------------------------------------------------------------------
    

    【讨论】:

    • 只需将文件复制到您 PATH 上的文件夹中(因此复制到 /usr/local/bin/cloc 之类的地方)。然后cd 到你的项目并以cloc . 运行它。默认情况下,所有依赖项都应安装在您的计算机上。
    猜你喜欢
    • 1970-01-01
    • 2013-07-11
    • 1970-01-01
    • 1970-01-01
    • 2011-08-02
    • 2017-03-30
    • 1970-01-01
    • 2012-10-16
    • 2017-02-28
    相关资源
    最近更新 更多