官网介绍:https://cloud.tencent.com/product/tcap 官方开源:https://github.com/Tencent/CodeAnalysis
国内镜像:https://git.code.tencent.com/Tencent_Open_Source/CodeAnalysis
▼
日常编码时,开发者有时可能会没理清楚逻辑,就会制造出一些逻辑上的NPE(Null Pointer Exception,空指针异常)。比如以下代码:
#include <stdio.h>
#include <iostream>
void test(const std::string* abc)
{
if (abc == nullptr && abc->empty()) {
return;
}
printf("%s", "abc");
}
int main() {
return 0;
}
可以看到,第六行的 if 条件判断语句的逻辑有误,因为当 abc 是 nullptr 时,尝试访问 abc->empty() 会导致空指针异常。
▼
▼
进入页面,点击方案->规则配置 -> 自定义规则包-> 添加规则 ->搜索规则名nullPointerRedundantCheck->选择需要添加的规则 ->批量添加规则