SonarCFamily只检测代码 - 重复代码块

时间:2018-05-24 14:36:19

标签: sonarqube sonarqube-scan

我试图在我的C代码库上使用SonarCamner与SonarCFamily插件在ubuntu上。我看到扫描仪只能检测到代码气味 - 重复的代码块"在我的代码库中没有其他形式的错误/漏洞。我有意在代码中添加了内存泄漏,而SonarQube无法在开源SA工具Cppcheck能够检测到它时检测到它。我错过了sonar-project.properties文件中的一些设置吗?我的sonar.properties文件如下。服务器/ SonarCFamily插件是否需要该工具来检测其他形式的SA错误?

# must be unique in a given SonarQube instance
sonar.projectKey=c-sa-test
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=c-sa-test
sonar.projectVersion=1.0

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set. 
sonar.sources=src

# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8
sonar.host.url=http://localhost:9000
sonar.cfamily.build-wrapper-output=bw_output
sonar.c.file.suffixes=.c,.h
sonar.cpp.file.suffixes=.cc,.cpp,.cxx,.c++,.hh,.hpp,.hxx,.h++,.ipp

2 个答案:

答案 0 :(得分:1)

找到根本原因 - 缺少提供项目构建过程的一些元素作为构建包装器的输入。一旦添加了这些,SonarQ提供了详细的报告。

答案 1 :(得分:0)

在SonarCFamily仅报告代码重复的情况下,我遇到了完全相同的问题。这是由于错误的构建过程作为对构建包装程序的输入。在我的情况下,我使用的是SonarScanner.MSBuild,在构建包装程序行中,我没有指定Configuration和Platform,因此没有构建或扫描我的项目。最后的工作线是:

SonarScanner.MSBuild.exe开始/ k:“您的密钥” /d:sonar.cfamily.build-wrapper-output=“bw_output”

build-wrapper-win-x86-64.exe --out-dir bw_output MSBuild.exe your_solution.sln / p:配置=发布/ p:平台= x64

SonarScanner.MSBuild.exe结束