Sonarqube SonarCFamily仅检测重复的代码块

Sonarqube SonarCFamily仅检测重复的代码块,sonarqube,sonarqube-scan,Sonarqube,Sonarqube Scan,我试图在ubuntu的C代码库上使用SonarScanner和SonarCFamily插件。我发现扫描器只能检测代码库中的“代码气味-重复代码块”,而不能检测其他形式的错误/漏洞。我故意在代码中添加了内存泄漏,SonarQube无法检测到它,而开源SA工具Cppcheck能够检测到它。sonar-project.properties文件中是否缺少某些设置?我的sonar.properties文件如下所示。服务器/SonarCFamily插件中是否需要任何设置来检测其他形式的SA错误 # must

我试图在ubuntu的C代码库上使用SonarScanner和SonarCFamily插件。我发现扫描器只能检测代码库中的“代码气味-重复代码块”,而不能检测其他形式的错误/漏洞。我故意在代码中添加了内存泄漏,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

找到根本原因-缺少提供项目生成过程的某些元素作为生成包装器的输入。添加这些内容后,SonarQ提供了一份详细的报告。

我遇到了与SonarCFamily完全相同的问题,SonarCFamily只报告代码重复。这是由于作为生成包装器输入的生成过程不正确。在我的例子中,我使用的是SonarScanner.MSBuild,在构建包装行中,我没有指定配置和平台,因此我的项目没有被构建或扫描。最后的工作路线是:

SonarScanner.MSBuild.exe begin/k:“您的密钥”/d:sonar.cfamily.build wrapper output=“bw\u output”

build-wrapper-win-x86-64.exe--out dir bw_output MSBuild.exe your_solution.sln/p:Configuration=Release/p:Platform=x64


SonarScanner.MSBuild.exe end

在应用的配置文件中是否确实有规则?您可以在项目主页的右下角看到使用了哪些配置文件。谢谢您的回复。以下是根据项目主页应用的配置文件:质量配置文件(C)C-default-2017(Python)py-default-2017(Web)Web-default-2017(XML)xml-default-2017 For c-default-2017以下是规则摘要:规则Active-Inactive总计133 105 Bug 37 21漏洞2 0代码气味94 84不推荐使用的规则您的bw_输出文件是否为非空?这些文件是否为非空?bw_输出目录是否为非空,包含两个文件:505字节的build-wrapper-dump.json和build-wrapper.log在99430字节中,我在c-default-2017配置文件中看到了相当多的非活动规则。这可能是导致这种行为的原因吗?您能确定构建的哪些特定元素丢失了吗?如果您有关于它的任何相关信息,为什么会导致问题?我的团队在尝试分析项目时遇到了完全相同的问题。谢谢