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