使用Sonar cxx社区插件v1.3.3,SonarQube 7.9.5中未报告Cppcheck错误

使用Sonar cxx社区插件v1.3.3,SonarQube 7.9.5中未报告Cppcheck错误,sonarqube,sonarqube-scan,cppcheck,Sonarqube,Sonarqube Scan,Cppcheck,我让SonarQube社区版(v7.9.5)服务器运行SonarCXX社区插件v1.3.3 现在,对于一个测试C++项目,我已经生成了CPPCHECK(V2.3)分析报告,并运行声纳扫描仪()如下: $ pwd /testproj $ ls file1.cc $ cat file1.cc int main() { char a[10]; a[10] = 0; return 0; } $ cppcheck --enable=all --xml . 2> cpp

我让SonarQube社区版(v7.9.5)服务器运行SonarCXX社区插件v1.3.3

现在,对于一个测试C++项目,我已经生成了CPPCHECK(V2.3)分析报告,并运行声纳扫描仪()如下:

$ pwd
/testproj

$ ls
file1.cc

$ cat file1.cc 
int main()
{
    char a[10];
    a[10] = 0;
    return 0;
}

$ cppcheck --enable=all --xml . 2> cppcheck_issues.xml

$ cat cppcheck_issues.xml 
<?xml version="1.0" encoding="UTF-8"?>
<results version="2">
    <cppcheck version="2.3"/>
    <errors>
        <error id="arrayIndexOutOfBounds" severity="error" msg="Array &apos;a[10]&apos; accessed at index 10, which is out of bounds." verbose="Array &apos;a[10]&apos; accessed at index 10, which is out of bounds." cwe="788" hash="11923574308940205340">
            <location file="file1.cc" line="4" column="2" info="Array index out of bounds"/>
        </error>
        <error id="unreadVariable" severity="style" msg="Variable &apos;a[10]&apos; is assigned a value that is never used." verbose="Variable &apos;a[10]&apos; is assigned a value that is never used." cwe="563" hash="9507758794529763218">
            <location file="file1.cc" line="4" column="7"/>
            <symbol>a[10]</symbol>
        </error>
    </errors>
</results>

$ sonar-scanner \
    -Dsonar.host.url=<sonar-host-url>\
    -Dsonar.login=<sonar-token>\
    -Dsonar.projectName=testproj\
    -Dsonar.projectKey=testproj\
    -Dsonar.projectVersion=0.1\
    -Dsonar.cxx.cppcheck.reportPath=cppcheck_issues.xml\
    -Dsonar.exclusions=cppcheck_issues.xml
INFO: Scanner configuration file: /code/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 4.5.0.2216
INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
INFO: Linux 4.1.12-124.43.4.el7uek.x86_64 amd64
INFO: User cache: /root/.sonar/cache
INFO: Scanner configuration file: /code/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: Analyzing on SonarQube server 7.9.5
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=142ms
INFO: Server id: 22633092-AXeMotAnTu7ckErSxqZC
INFO: User cache: /root/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=73ms
INFO: Load/download plugins (done) | time=141ms
INFO: Process project properties
INFO: Execute project builders
INFO: Execute project builders (done) | time=9ms
INFO: Project key: testproj
INFO: Base dir: /testproj
INFO: Working dir: /testproj/.scannerwork
INFO: Load project settings for component key: 'testproj'
INFO: Load project settings for component key: 'testproj' (done) | time=74ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=99ms
INFO: Load active rules
INFO: Load active rules (done) | time=1167ms
WARN: SCM provider autodetection failed. Please use "sonar.scm.provider" to define SCM of your project, or disable the SCM Sensor in the project settings.
INFO: Indexing files...
INFO: Project configuration:
INFO:   Excluded sources: cppcheck_issues.xml
INFO: 1 file indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: Quality profile for c++: Sonar way
INFO: ------------- Run sensors on module testproj
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=41ms
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$1 (file:/root/.sonar/cache/866bb1adbf016ea515620f1aaa15ec53/sonar-javascript-plugin.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of net.sf.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
INFO: Sensor C++ (Community) SquidSensor [cxx]
INFO: Load project repositories
INFO: Load project repositories (done) | time=31ms
INFO: Sensor C++ (Community) SquidSensor [cxx] (done) | time=312ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=9ms
INFO: Sensor JavaXmlSensor [java]
INFO: Sensor JavaXmlSensor [java] (done) | time=3ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=23ms
INFO: ------------- Run sensors on project
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=27ms
INFO: No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
INFO: 1 file had no CPD blocks
INFO: Calculating CPD for 0 files
INFO: CPD calculation finished
INFO: Analysis report generated in 157ms, dir size=79 KB
INFO: Analysis report compressed in 22ms, zip size=12 KB
INFO: Analysis report uploaded in 58ms
INFO: ANALYSIS SUCCESSFUL, you can browse <sonar-host-url>/dashboard?id=testproj
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at <sonar-host-url>/api/ce/task?id=AXeQLS1KTu7ckErSxt5M
INFO: Executing post-job 'Final report'
INFO: Turn debug info on to get more details (sonar-scanner -X -Dsonar.verbose=true ...).
INFO: Analysis total time: 5.510 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 7.283s
INFO: Final Memory: 12M/44M
INFO: ------------------------------------------------------------------------
$pwd
/测试项目
$ls
file1.cc
$cat file1.cc
int main()
{
chara[10];
a[10]=0;
返回0;
}
$cppcheck--enable=all--xml。2> cppcheck_issues.xml
$cat cppcheck_issues.xml
a[10]
声纳扫描仪\
-Dsonar.host.url=\
-Dsonar.login=\
-Dsonar.projectName=testproj\
-Dsonar.projectKey=testproj\
-Dsonar.projectVersion=0.1\
-Dsonar.cxx.cppcheck.reportPath=cppcheck\u issues.xml\
-Dsonar.exclusions=cppcheck_issues.xml
信息:扫描仪配置文件:/code/sonar Scanner/conf/sonar-Scanner.properties
信息:项目根配置文件:无
信息:声纳扫描仪4.5.0.2216
信息:Java 11.0.3采用OpenJDK(64位)
信息:Linux 4.1.12-124.43.4.el7uek.x86_64 amd64
信息:用户缓存:/root/.sonar/cache
信息:扫描仪配置文件:/code/sonar Scanner/conf/sonar-Scanner.properties
信息:项目根配置文件:无
信息:分析SonarQube服务器7.9.5
信息:默认语言环境:“en_US”,源代码编码:“UTF-8”(分析依赖于平台)
信息:加载全局设置
信息:加载全局设置(完成)|时间=142ms
信息:服务器id:22633092-AXeMotAnTu7ckErSxqZC
信息:用户缓存:/root/.sonar/cache
信息:加载/下载插件
信息:加载插件索引
信息:加载插件索引(完成)|时间=73ms
信息:加载/下载插件(完成)|时间=141ms
信息:流程项目属性
信息:执行项目生成器
信息:执行项目生成器(完成)|时间=9ms
信息:项目密钥:testproj
信息:基本目录:/testproj
信息:工作目录:/testproj/.scannerwork
信息:加载组件键的项目设置:“testproj”
信息:加载组件键的项目设置:“testproj”(完成)|时间=74ms
信息:加载质量配置文件
信息:加载质量配置文件(完成)|时间=99ms
信息:加载活动规则
信息:加载活动规则(完成)|时间=1167ms
警告:SCM提供程序自动检测失败。请使用“sonar.scm.provider”定义项目的scm,或在项目设置中禁用scm传感器。
信息:索引文件。。。
信息:项目配置:
信息:排除的来源:cppcheck_issues.xml
信息:1文件索引
信息:由于包含/排除模式,0个文件被忽略
信息:c++的质量配置文件:声纳方式
信息:------------在模块testproj上运行传感器
信息:加载度量存储库
信息:加载度量存储库(完成)|时间=41ms
警告:发生了非法的反射访问操作
警告:net.sf.cglib.core.reflectils$1(文件:/root/.sonar/cache/866bb1adbf016ea515620f1aaa15ec53/sonar javascript plugin.jar)对方法java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)的非法反射访问
警告:请考虑将此报告给NET.SF.CGLYB.Cyr.TraceCtudies的维护者1美元。
警告:使用--invalize access=warn以启用对进一步非法访问操作的警告
警告:所有非法访问操作将在未来版本中被拒绝
信息:C++传感器(社区)
信息:加载项目存储库
信息:加载项目存储库(完成)|时间=31ms
信息:传感器C++(社区)ScIdSc[cx](完成)时间=312MS
信息:传感器JaCoCo XML报告导入器[JaCoCo]
信息:传感器JaCoCo XML报告导入器[JaCoCo](完成)|时间=9毫秒
信息:传感器JavaXmlSensor[java]
信息:传感器JavaXmlSensor[java](完成)|时间=3ms
信息:传感器HTML[web]
信息:传感器HTML[web](完成)|时间=23毫秒
信息:------------在项目上运行传感器
信息:传感器零覆盖传感器
信息:传感器零覆盖传感器(完成)|时间=27ms
信息:未检测到SCM系统。您可以使用“sonar.scm.provider”属性显式指定它。
信息:1个文件没有CPD块
信息:正在计算0个文件的CPD
信息:CPD计算完成
信息:157ms内生成的分析报告,目录大小=79 KB
信息:分析报告以22ms压缩,zip大小=12KB
信息:58毫秒内上传分析报告
信息:分析成功,您可以浏览/dashboard?id=testproj
信息:请注意,一旦服务器处理了提交的分析报告,您将能够访问更新的仪表板
信息:有关在/api/ce/task?id=AXeQLS1KTu7ckErSxt5M处处理报告的详细信息
信息:执行作业后“最终报告”
信息:打开调试信息以获取更多详细信息(sonar scanner-X-Dsonar.verbose=true…)。
信息:分析总时间:5.510秒
信息:------------------------------------------------------------------------
信息:执行成功
信息:------------------------------------------------------------------------
信息:总时间:7.283s
信息:最终内存:12M/44M
信息:------------------------------------------------------------------------
现在项目已在SonarQube中成功创建/更新;但是,SonarQube没有报道这些问题。有人可以提出原因是什么?

1: SONAR.CXX.ExxIX。源代码被配置为SonarQube服务器配置中C++(Community)插件的“.cc”值。而且,没有其他插件使用相同的配置密钥


注2:在ce.log中未发现错误/警告

在进一步挖掘后发现问题原因

问题原因:默认的质量文件对应于C++(Community),默认情况下它们的所有规则都被禁用,并且也没有选择启用它们。

修复:创建一个新的质量文件,扩展默认的一个,然后启用该规则,最后将它作为C++的默认质量配置文件(Community)来解决这个问题。 更新(2月16日至21日):从sonar cxx团队得到澄清,这也是有意的,