软件度量多个指标依赖于代码行统计,如每千行代码发现bug等,所以代码行是一个基础数据。
Cccc开源工具, 从http://cccc.sourceforge.net/下载,支持linux ,win32 c/c++代码。
在linux上执行./build_posixgcc.sh && make install 部署cccc.
[liangjz@b2b_plat_1367 src]$ cccc --help
Usage:
cccc [options] file1.c ...
Process files listed on command line.
If the filenames include '-', read a list of files from standard input.
Command Line Options: (default arguments/behaviour specified in braces)
--help * generate this help message
--outdir=<dname> * directory for generated files {.cccc}
--html_outfile=<fname> * name of main HTML report {<outdir>/cccc.html}
--xml_outfile=<fname> * name of main XML report {<outdir>/cccc.xml}
--db_infile=<fname> * preload internal database from named file
{empty file}
--db_outfile=<fname> * save internal database to file {<outdir>/cccc.db}
--opt_infile=<fname> * load options from named file {hard coded, see below}
--opt_outfile=<fname> * save options to named file {<outdir>/cccc.opt}
--lang=<string> * use language specified for files specified
after this option (c,c++,ada,java, no default)
--report_mask=<hex> * control report content
--debug_mask=<hex> * control debug output content
(refer to ccccmain.cc for mask values)
Refer to ccccmain.cc for usage of --report_mask and --debug_mask.
Refer to cccc_opt.cc for hard coded default option values, including default
extension/language mapping and metric treatment thresholds.
Cccc不能对一个目录下的文件做递归式的扫描。
[liangjz@b2b_plat_1367 client]$ cccc *.*
...
Primary HTML output is in .cccc/cccc.html
Detailed HTML reports on modules and source are in .cccc
Primary XML output is in .cccc/cccc.xml
Detailed XML reports on modules are in .cccc
Database dump is in .cccc/cccc.db
[liangjz@b2b_plat_1367 .cccc]$ ll .cccc
可以看到生成的文件不同于源代码类。
将结果都下载都本地可看到
Procedural Metrics,Object Oriented Design,Structural Metrics Summary 等不同维度的数据。
Html格式的报告有很好的注释,黄色的可能需要再深入分析。
CCCC度量数据可结合测试风险完善测试计划。