静态分析工具可在研发过程中应用或者QA做冒烟测试check研发的source时应用,尽早发现缺陷.本次试验在已安装python运行环境的redhat linux 2.6内核上执行.
参考 http://blog.oolanguage.com/erpingwu/google-style-guide-%E4%B9%8B-cpplint/
下载 http://google-styleguide.googlecode.com/svn/trunk/cpplint/cpplint.py
[liangjz@b2b_plat_1367 erosa_cap]$ python ~/cpplint.py --filter=
可以查看到filter的内容.
以下采用cpplint忽略空格,可读性,legal方面的规则扫描工程代码(结果有删节).输出结果上有较多的建设性建议.具体含义可看:http://www.cppblog.com/Fox/category/6273.html?Show=All
[liangjz@b2b_plat_1367 erosa_cap]$ python ~/cpplint.py --filter=-whitespace,-readability,-legal *.*
.
CapNetManager.cpp:2: Include the directory when naming .h files [build/include] [4]
CapNetManager.cpp:54: Use int16/int64/etc, rather than the C type short [runtime/int] [4]
CapNetManager.h:1: #ifndef header guard has wrong style, please use: EROSA_EROSA_CAP_CAPNETMANAGER_H_ [build/header_guard] [5]
CapNetManager.h:41: #endif line should be "#endif // EROSA_EROSA_CAP_CAPNETMANAGER_H_" [build/header_guard] [5]
CapNetManager.h:15: Do not use namespace using-directives. Use using-declarations instead. [build/namespaces] [5]
Erosa_cap.cpp:4: Found C system header after C++ system header. Should be: Erosa_cap.h, c system, c++ system, other. [build/include_order] [4]
Erosa_cap.cpp:265: If you can, use sizeof(szTmp) instead of 128 as the 2nd arg to snprintf. [runtime/printf] [3]
Erosa_cap.cpp:262: Add #include <string> for string [build/include_what_you_use] [4]
Parse.cpp:58: Use int16/int64/etc, rather than the C type short [runtime/int] [4]
Parse.cpp:2241: Is this a non-const reference? If so, make const or use a pointer. [runtime/references] [2]
Parse.cpp:451: Add #include <algorithm> for min [build/include_what_you_use] [4]
Parse.h:7: Do not use namespace using-directives. Use using-declarations instead. [build/namespaces] [5]
RedoFileScan.cpp:238: Almost always, snprintf is better than strcat [runtime/printf] [4]
RedoFileScan.cpp:387: sscanf can be ok, but is slow and can overflow buffers. [runtime/printf] [1]
RedoManager.cpp:231: Consider using localtime_r(...) instead of localtime(...) for improved thread safety. [runtime/threadsafe_fn] [2]
…
Total errors found: 230