代码统计工具

标签: 代码 统计 工具 | 发表时间:2015-02-01 20:02 | 作者:lp895876294
出处:http://www.iteye.com

代码统计工具:cloc(count lines of code)能够兼容windows和linux操作系统

下载url:http://sourceforge.net/projects/cloc/files/cloc/

下面以windows系统为例说明配置过程:

  • 下载cloc,并为cloc配置环境变量,使在windows命令行下所有目录可以执行cloc命令。我下载后cloc名称为cloc-1.62.exe,并且配置好了环境变量。
  • 执行cloc-1.62可以查看到命令参数信息。
    Input Options
      --extract-with=<cmd>      This option is only needed if cloc is unable
                                to figure out how to extract the contents of
                                the input file(s) by itself.
                                Use <cmd> to extract binary archive files (e.g.:
                                .tar.gz, .zip, .Z).  Use the literal '>FILE<' as
                                a stand-in for the actual file(s) to be
                                extracted.  For example, to count lines of code
                                in the input files
                                   gcc-4.2.tar.gz  perl-5.8.8.tar.gz
                                on Unix use
                                  --extract-with='gzip -dc >FILE< | tar xf -'
                                or, if you have GNU tar,
                                  --extract-with='tar zxf >FILE<'
                                and on Windows use, for example:
                                  --extract-with="\"c:\Program Files\WinZip\WinZip
    .exe\" -e -o >FILE< ."
                                (if WinZip is installed there).
      --list-file=<file>        Take the list of file and/or directory names to
                                process from <file> which has one file/directory
                                name per line.  See also --exclude-list-file.
      --unicode                 Check binary files to see if they contain Unicode
                                expanded ASCII text.  This causes performance to
                                drop noticably.
    
    Processing Options
      --autoconf                Count .in files (as processed by GNU autoconf) of
                                recognized languages.
      --by-file                 Report results for every source file encountered.
      --by-file-by-lang         Report results for every source file encountered
                                in addition to reporting by language.
      --diff <set1> <set2>      Compute differences in code and comments between
                                source file(s) of <set1> and <set2>.  The inputs
                                may be pairs of files, directories, or archives.
                                Use --diff-alignment to generate a list showing
                                which file pairs where compared.  See also
                                --ignore-case, --ignore-whitespace.
      --diff-timeout <N>        Ignore files which take more than <N> seconds
                                to process.  Default is 10 seconds.
                                (Large files with many repeated lines can cause
                                Algorithm::Diff::sdiff() to take hours.)
      --follow-links            [Unix only] Follow symbolic links to directories
                                (sym links to files are always followed).
      --force-lang=<lang>[,<ext>]
                                Process all files that have a <ext> extension
                                with the counter for language <lang>.  For
                                example, to count all .f files with the
                                Fortran 90 counter (which expects files to
                                end with .f90) instead of the default Fortran 77
                                counter, use
                                  --force-lang="Fortran 90",f
                                If <ext> is omitted, every file will be counted
                                with the <lang> counter.  This option can be
                                specified multiple times (but that is only
                                useful when <ext> is given each time).
                                See also --script-lang, --lang-no-ext.
      --force-lang-def=<file>   Load language processing filters from <file>,
                                then use these filters instead of the built-in
                                filters.  Note:  languages which map to the same
                                file extension (for example:
                                MATLAB/Objective C/MUMPS;  Pascal/PHP;
                                Lisp/OpenCL) will be ignored as these require
                                additional processing that is not expressed in
                                language definition files.  Use --read-lang-def
                                to define new language filters without replacing
                                built-in filters (see also --write-lang-def).
      --ignore-whitespace       Ignore horizontal white space when comparing files
                                with --diff.  See also --ignore-case.
      --ignore-case             Ignore changes in case; consider upper- and lower-
                                case letters equivalent when comparing files with
                                --diff.  See also --ignore-whitespace.
      --lang-no-ext=<lang>      Count files without extensions using the <lang>
                                counter.  This option overrides internal logic
                                for files without extensions (where such files
                                are checked against known scripting languages
                                by examining the first line for #!).  See also
                                --force-lang, --script-lang.
      --max-file-size=<MB>      Skip files larger than <MB> megabytes when
                                traversing directories.  By default, <MB>=100.
                                cloc's memory requirement is roughly twenty times
                                larger than the largest file so running with
                                files larger than 100 MB on a computer with less
                                than 2 GB of memory will cause problems.
                                Note:  this check does not apply to files
                                explicitly passed as command line arguments.
      --read-binary-files       Process binary files in addition to text files.
                                This is usually a bad idea and should only be
                                attempted with text files that have embedded
                                binary data.
      --read-lang-def=<file>    Load new language processing filters from <file>
                                and merge them with those already known to cloc.
                                If <file> defines a language cloc already knows
                                about, cloc's definition will take precedence.
                                Use --force-lang-def to over-ride cloc's
                                definitions (see also --write-lang-def ).
      --script-lang=<lang>,<s>  Process all files that invoke <s> as a #!
                                scripting language with the counter for language
                                <lang>.  For example, files that begin with
                                   #!/usr/local/bin/perl5.8.8
                                will be counted with the Perl counter by using
                                   --script-lang=Perl,perl5.8.8
                                The language name is case insensitive but the
                                name of the script language executable, <s>,
                                must have the right case.  This option can be
                                specified multiple times.  See also --force-lang,
                                --lang-no-ext.
      --sdir=<dir>              Use <dir> as the scratch directory instead of
                                letting File::Temp chose the location.  Files
                                written to this location are not removed at
                                the end of the run (as they are with File::Temp).
      --skip-uniqueness         Skip the file uniqueness check.  This will give
                                a performance boost at the expense of counting
                                files with identical contents multiple times
                                (if such duplicates exist).
      --stdin-name=<file>       Give a file name to use to determine the language
                                for standard input.
      --strip-comments=<ext>    For each file processed, write to the current
                                directory a version of the file which has blank
                                lines and comments removed.  The name of each
     按照代码类型统计文件夹:E:\MY-SVN\projects\system下的代码并生成统计表报告。命令:cloc-1.62 --by-file-by-lang --xml --out=cloc.xml "E:\MY-SVN\projects\system"
  • 为方便生成统计报告,写了一个批处理脚本。在项目根目录下新建一个bin文件夹,并将脚本cloc.bat放入,执行脚本后会在bin目录下生成一个文件名称为code_reports.xml的代码统计报告。报告部分内容如下:
    <languages>
      <language name="Java" files_count="52" blank="336" comment="256" code="1093" />
      <language name="JSP" files_count="6" blank="17" comment="23" code="367" />
      <language name="XML" files_count="4" blank="7" comment="22" code="181" />
      <language name="Maven" files_count="1" blank="9" comment="6" code="63" />
      <language name="Javascript" files_count="4" blank="0" comment="4" code="51" />
      <language name="DOS Batch" files_count="2" blank="1" comment="0" code="20" />
      <language name="JSON" files_count="1" blank="0" comment="0" code="20" />
      <language name="Visualforce Component" files_count="1" blank="0" comment="0" code="19" />
      <language name="HTML" files_count="1" blank="0" comment="0" code="8" />
      <total sum_files="72" blank="370" comment="311" code="1822" />
    </languages>
  • cloc.bat脚本见附件。

 



    本文附件下载:
  • cloc.rar (340 Bytes)


已有 0 人发表留言,猛击->> 这里<<-参与讨论


ITeye推荐



相关 [代码 统计 工具] 推荐:

代码统计工具

- - 企业架构 - ITeye博客
代码统计工具:cloc(count lines of code)能够兼容windows和linux操作系统. 下载url:http://sourceforge.net/projects/cloc/files/cloc/. 下面以windows系统为例说明配置过程:. 下载cloc,并为cloc配置环境变量,使在windows命令行下所有目录可以执行cloc命令.

介绍一个好用的代码统计工具

- - 研发管理 - ITeye博客
想知道了解一下项目的代码规模,得到类数,代码行等统计信息,就用cloc吧,很好,很强大. cloc支持几乎什么的OS,当然也包括Windows,如果是Windows直接下载EXE文件(http://sourceforge.net/projects/cloc/),设置一个PATH环境变量就可以用了.   即可得到代码的统计信息:.

统计SVN代码行数工具-StatSVN - valleylord - 博客园

- -
获取SVN log:svn log -v -r 17461:39224 --xml > logfile.log. 用StatSVN分析:java -jar ~/project/statsvn-0.7.0/statsvn.jar logfile.log . StatSVN是一个Java写的开源代码统计程序,从statCVS移植而来,能够从Subversion版本库中取得信息,然后生成描述项目开发的各种表格和图表.

黑客工具SpyEye源代码泄露

- SotongDJ - Solidot
在Zeus之后,另一个黑客工具包SpyEye的源代码也被泄露到网上. SpyEye是Zeus的竞争对手,它甚至可以删除受害者电脑里的Zeus. 它在地下黑客市场的零售价高达500美元. 安全公司Damballa报导,逆向工程师Xyliton破解了用VMProtect保护的SpyEye 1.3.45,发布了SpyEye 1.3.45 Loader源代码,它将允许恶意黑客开发出更复杂更难以探测的恶意程序.

CSS3 代码生成工具:Create CSS3

- - 我爱水煮鱼
CSS3 具有相当多的新增属性,而且包括阴影、动画、过渡等华丽的效果. 但是由于 CSS3 出来并没有很久,各个浏览器厂商还在开发中,有些属性仍然会带有实验性前缀. 而且类似制作动画、渐变的 CSS3 代码也相当复杂,一旦写错就会导致出现问题. 为此,有人开发了一个生成 CSS3 代码的工具 Create CSS3.

Phabricator —— Facebook 的代码评审工具

- - 开源中国社区最新新闻
在代码审查(Code Review)方面,Facebook做了一个可视化的工具,现已开源,叫Phabricator;工程师可以在页面上非常方便的针对每一段(单行或者多 行)代码进行交互讨论;负责审查的工程师可以接受代码改变,可以提出疑问要求原作者继续修改,可以提出自己不适合以推出该代码审查,等等.

Java静态代码分析工具Infer

- - CSDN博客推荐文章
Java静态代码分析工具Infer. 作者:chszs,转载需注明. 博客主页: http://blog.csdn.net/chszs. Infer是Facebook最新开源的静态程序分析工具,用于在发布移动应用之前对代码进行分析,找出潜在的问题. 目前Facebook使用此工具分析Facebook的App,包括Android、iOS、Facebook Messenger和Instagram等.

开发中统计代码量

- - 开源软件 - ITeye博客
开发中我们想知道到底有多少代码. throw new RuntimeException("异常");. sum1++;//不包括注释换行. sum3++;//包括注释,换行. * 程序名称:java代码行数统计软件. * 说明:支持 整个工程的代码行数统计. out.println("共有 " +sum[5]+" 个类" );.

Chrome 油耗统计工具扩展:我的汽车工具箱

- 深深浅浅 - 谷奥——探寻谷歌的奥秘
感谢扩展作者 cloudme 的自爆. 我的汽车工具箱是Chrome上的第一款油耗统计工具扩展,直接用Google帐号即可登录. 能够比较精确地统计百公里油耗以及每公里的开销. 上海地区的车友还可以直接利用它来查询违章信息. 每天打开浏览器就知道是否违章,省去频繁输入的烦恼. 上海地区违章查询说明:如果正确录入了车牌号码和发动机号(可选,沪牌必须输入此号才能正确查询)之后,如果有违章,扩展按钮的图标会自动更换,让您打开浏览器就能够知道自己的违章状况(为了加快速度,违章信息有一定缓存,缓存时间暂定为一天).