Sonarqube扫描c++代码

本文指导如何下载cppcheck插件,配置Sonarqube以扫描C++代码,并提供关键步骤,包括规则设置、XML文件路径及示例配置。通过实例展示如何查看扫描结果并优化项目质量检测。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Sonarqube扫描c++代码

1.下载cppcheck和插件

插件的下载地址为:https://github.com/SonarOpenCommunity/sonar-cxx
cppcheck下载地址:http://cppcheck.net/

然后生成xml文档
我生成的xml文件:
生成的error:
在这里插入图片描述

在这里插入图片描述

2.配置sonarqube

2.1 配置相应的规则

2.2 配置相应的xml文件路径

在这里插入图片描述
这里的路径要和配置文件的路径保持一致。

3.进行配置文件

官网给的hello-world很有参考价值:
https://github.com/SonarOpenCommunity/sonar-cxx/tree/master/integration-tests/testdata/hello_world

sonar-project.properties

# metadata
sonar.projectKey=hello_world

# disable SCM support
sonar.scm.disabled=true

# file extensions assigned to the cxx programming language
sonar.cxx.file.suffixes=.cxx,.cpp,.cc,.c,.hxx,.hpp,.hh,.h

# comma-separated paths to directories containing source files
sonar.sources=src

# comma-separated list of directories where the plugin should search for include files
sonar.cxx.includeDirectories=src

# paths to the cppcheck report
sonar.cxx.cppcheck.reportPaths=reports/cppcheck.xml

# 需要添加上传的url!,此处没有写。

4.查看结果

扫描成功后的结果为:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值