代码统计工具: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脚本见附件。
相关推荐
ozG4 プログラムアナライザー 一款日语的代码统计工具,支持多种文件,分类统计,分包统计,等
代码统计工具 cct---Count_Code Tool_CCTsetup
代码统计工具代码统计工具代代码统计工具代码统计工具码统计工具代码统计工具
源代码统计工具 欢迎大家使用代码统计工具,在前几个月中,我用VB.net开发了一个代码统计工具,应为VB.net需要Framework支持,所以我将软件的开发环境改为Microsoft Visual C++ 6.0。本人对C++不怎么了解,这是用...
免费的源代码统计工具,能统计包括:行数、工数、成本、质量指标等信息,支持20多种代码格式。 具有统计迅速、准确的优点,是程序开发人员的必备工具。可以对 C++、VB.Net、VB、C#、JAVA、Delphi、ASP.Net、ASP、...
源代码统计工具。 简单的源代码统计工具,包括总行数,注释行数等
SrcCount 代码统计工具 SrcCount 代码统计工具 html js等
自己做了一个代码统计工具,目前只设置了统计c/c++代码文件,当然你可以根据你的实际情况编译修改,还支持多语言切换。
Mac 代码统计工具,可以统计各种.c,.cpp,.h,.m,等代码的行数
ICodeStat代码统计工具。代码统计主要包括:注释行、空白行、代码行、总行数(不包括空白行)、总文件数、注释率、空白率。统计输出格式以类似表格的输出方式展现,看起来一目了然。
SourceCount代码统计工具,可以统计出代码行数。方便实用,无需注册。 SourceCount代码行数统计工具
本工具当前版本1.3,在原版本上增加了对VHDL和Verilog代码的统计、增加了按照函数进行代码量统计、增加了另存为Excel格式(.csv格式)功能;增加了对单片机代码进行按照每个函数进行分离为一个文件,用于代码单元...
源代码统计工具 可以统计代码行数里面有三种不同的统计方式
统计某一个版本的代码包相对于一个原始的基线代码包,变动的代码量 以及变动的代码量中各语言非空非注释行(NBNC)的结果
vb代码统计工具vb代码统计工具vb代码统计工具vb代码统计工具vb代码统计工具
linecount代码统计工具,支持各种语言,非常好用。。。
代码统计工具,代码统计工具,代码统计工具,代码统计工具,代码统计工具,代码统计工具,代码统计工具,代码统计工具,代码统计工具,代码统计工具,代码统计工具,代码统计工具,
统计.java文件里所有的代码行数,注释行数
JAVA代码统计工具,可以按人统计,很不错JAVA代码统计工具,可以按人统计,很不错