程序质量管理(二)——关于静态代码扫描

腾讯开源了一款静态代码扫描工具:

http://code.tencent.com/tscancode.html

这个工具可以扫描发现代码中潜在的漏洞隐患,比如解引用为空,客户端不同步问题等。

墙裂推荐在开发过程中作为日常扫描,可以帮助发现很多潜在的Bug。

TScanCode提供了命令行工具,可以很方便地和持续集成工具(例如Jenkins、Hudson)进行整合,作为一个例行的定时扫描任务:


图一 检查扫描结果中是否存在错误的批处理


图二 过滤掉误报,重建TScanCode能够识别的XML结果文件的批处理


图三 过滤误报的批处理

扫描二维码关注公众号,回复: 4146488 查看本文章


图四 过滤误报的批处理


图五 TScanCode的命令行扫描批处理


图六 例行扫描的结果,发现了两个问题


由于我这个项目只需要扫描CSharp脚本,所以只做了CSharp的扫描批处理,如果需要扫描其它语言,可使用如下脚本:

 @echo off
rem TscanCode web account

rem set your src file path
set srcpath="F:/test"
set cppresult=./log/cppresult.xml
set csharpresult=./log/csharpresult.xml
set luaresult=./log/luaresult.xml

./TscanCode --xml --enable=all --lua ./log %srcpath% 2>%cppresult%
./TscSharp --xml --lua ./log %srcpath% 2>%csharpresult%
./tsclua --xml --csharp ./log -fr ./log/csharp.lua.exp -fr ./log/cpp.lua.exp %srcpath% 2>%luaresult% 

猜你喜欢

转载自blog.csdn.net/weixin_42163773/article/details/80242732
今日推荐